Lambda Function returned an error in Connect Contact Flow logs, but Lambda itself working fine

0

I have set up a configuration between Salesforce and AWS Connect. In this configuration Amazon provided us with built-in Lambda package that is used to add, update or lookup Salesforce records. In my case, I am using this lambda package for lookup into salesforce. Salesforce save data in the form of Contact and Account. When I try to fetch data from Salesforce Contact using lambda function in Connect Contact Flow, it works absolutely fine. But when I try to fetch Salesforce Account fields using Lambda function in Connect Contact Flow, It is not working.
Although Connect Contact Flow properly calls my lambda function, and Lambda function is working fine as you can see my lambda function logs below:

Response: 
{
    "searchRecords": [
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v48.0/sobjects/Contact/0035pWFcaAAG"
            },
            "Id": "0035p00003dWFcaAAG",
            "Name": "Artur Bensch",
            "Account": {
                "attributes": {
                    "type": "Account",
                    "url": "/services/data/v48.0/sobjects/Account/0015p000OcQAAV"
                },
                "City_CB__c": "Cologne"
            }
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v48.0/sobjects/Contact/0035p000xtxAAA"
            },
            "Id": "0035p000txAAA",
            "Name": "test us",
            "Account": {
                "attributes": {
                    "type": "Account",
                    "url": "/services/data/v48.0/sobjects/Account/0015p00ts3SAAQ"
                },
                "City_CB__c": "Berlin"
            }
        }
    ]
}

It is not throwing any error, I have checked all logs very carefully, but when I see contact flow logs, it says "The Lambda Function Returned An Error." Also you can see in the Contact Flow logs.

{
    "Results": "The Lambda Function Returned An Error.",
    "ContactId": "ab679f96-a75f-4fdfc-8sdfds0-a656542e2f8",
    "ContactFlowId": "arn:aws:connect:eu-central-1:048600317115:instance/ba40-72b-a94d-a5b3bfde8b2f/contact-flow/b8fb79cc",
    "ContactFlowName": "outboundWhisperFlow",
    "ContactFlowModuleType": "InvokeExternalResource",
    "Timestamp": "2022-05-30T06:43:58.108Z",
    "Parameters": {
        "FunctionArn": "arn:aws:lambda:eu-central-1:048600317115:function:serverlessrepo-AmazonConnectSalesforce-sfInvokeAPI-JrqDuYg",
        "Parameters": {
            "sf_operation": "phoneLookup",
            "sf_phone": ".+4915251121195",
            "sf_fields": "Id, Name, account.City_CB__c"
        },
        "TimeLimit": "8000"
    }
}

It is very unexpected behavior by Contact Flow logs, because my Lambda function is running without any error then why contact flow is saying Lambda Function returned an error, it is very frustrating.

2개 답변
0

try setting your parameters to

     "Parameters": {
            "sf_operation": "search",
            "sf_object": "Account",
            "q": ".+4915251121195",
            "sf_fields": "Id, Name, City_CB__c"
        },

The phoneLookup operation only searches against the Contact object in Salesforce as far as I can tell, so adding the City_CB__c as a field causes it to fail. The documentation on the provided lambda leaves a bit to be desired.

ledge
답변함 2년 전
0

Looking at what is being return it seems your object might be too complex based on the limitations that the contact flow can handle based on their documentation - The output returned from the function must be a flat object of key/value pairs, with values that include only alphanumeric, dash, and underscore characters. Nested and complex objects are not supported. The size of the returned data must be less than 32 KB of UTF-8 data. can be found here - https://docs.aws.amazon.com/connect/latest/adminguide/connect-lambda-functions.html#verify-function

답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠