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.