I have an AWS Lambda (node.js) that returns a value, in this case, an NPI number. Per the AWS documentation (https://docs.aws.amazon.com/connect/latest/adminguide/connect-lambda-functions.html#verify-function), I am returning a JSON flat object:
function successResponse(npi, callback) {
const npiResponse = {
NPI: npi
};
console.log(`Response back to client: ${JSON.stringify(npiResponse)}`);
callback(null, npiResponse);
}
If I look at CloudWatch log for this response, I see:
2020-03-27T16:45:03.026Z afe0c304-bac7-4a03-8692-81b57fb9082b INFO Response back to client:
{
"NPI": 1986799264
}
However, in the AWS Connect log, I see:
{
"Results": "The Lambda Function Returned An Error.",
"ContactId": "ca7db64a-7284-409d-80bf-db44ffe0ae2f",
"ContactFlowId": "arn:aws:connect:us-east-1:611631033586:instance/ffb670d1-4977-42e6-a6f5-af43bec29887/contact-flow/73f1fc14-f26d-4067-aaed-f15982226dff",
"ContactFlowModuleType": "InvokeExternalResource",
"Timestamp": "2020-03-27T16:44:59.355Z",
"ExternalResults": {
"callCenterStatus": "Open"
},
"Parameters": {
"FunctionArn": "arn:aws:lambda:us-east-1:611631033586:function:provider-npi-dev",
"Parameters": {
"NPI": "1986799264"
},
"TimeLimit": "3000"
}
}
The response is rather simple, but I inconsistently get an Lambda error. Thoughts on what I am doing wrong?