Lambda action fails in Architect but works in test

Hi

I think I've tried everything by now :frowning:

I have a simple Lambda function that works fine when I test it, but fails when it gets called by Architect.

I can see that call in the Lambda logs, but it always exits on the "fail" exit in architect. I've even tried calling it from a screen pop script and I get the same failure.

It's based on your fine examples, so I'm getting really frustrated that I can't even get it to work where I need it :wink:

{
"name": "TestLambdaTransform3 - Exported 2022-05-25 @ 8:16",
"integrationType": "aws-lambda-data-actions",
"actionType": "custom",
"config": {
"request": {
"requestUrlTemplate": "arn:aws:lambda:eu-west-1:******:function:testLambdaFunction",
"requestType": "POST",
"headers": {
"Transfer-Encoding": "buffered"
},
"requestTemplate": "{\n "payloadFieldKey": "${input.arrayToTransform}"\n}"
},
"response": {
"translationMap": {
"charSeparatedList": "$.body.message"
},
"translationMapDefaults": {},
"successTemplate": "{"charSeparatedList":${charSeparatedList}}"
}
},
"contract": {
"input": {
"inputSchema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"arrayToTransform": {
"type": "string"
}
}
}
},
"output": {
"successSchema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"charSeparatedList": {
"type": "string"
}
}
}
}
},
"secure": false
}

Here is a picture of the test.

I'll also include the return from the Lambda function:

Execute step 7 output:

{
  "statusCode": 200,
  "body": {
    "message": "Anders And:44559918|Donald Duck:44559918"
  }
}

Flatten step 12:

{
  "charSeparatedList": "Anders And:44559918|Donald Duck:44559918"
}

Please tell me what mistake I have made.

BR
Anders

Hello @Anders_Vejen,

Out of curiosity, I tried to implement and develop the same Lambda function on my AWS account to understand why you are having this failure in both Architect and Script.

1 - Execute Data Action manually

As you can see below, it is working for me when executing the Data Action manually under Admin/Integrations/Actions section (btw I tried to keep the same input/output labels :blush:)

2 - Architect

Then, I created a basic Inbound Call Flow to invoke my Data Action and inspect the result. The good news is that is working just fine.

I put the message into a variable (Flow.message) as literal and pass it as an input to the Data Action. Below the outputs using Participant Data under Workspace/Interactions section :

As you can see, the Data Actions took the Success Path returning the expected string transformed.

3 - Script

I also tried to invoke the Data Action inside a script to see if I get the same result.
Below the result after pressing the Transform button

So, it is working fine for all the cases.

The only way I could reproduce the failure is when I use Literal Mode to my message with double quote ("message")

Literal Mode with double quote => Failure
image

However, if you use Expression mode with double quote to you string, it should be fine.

Regarding your case, in my opinion you may have a problem with the input syntax , and I would suggest to pass the message as literal without " " to see if it is working fine as you did when you successfully tested manually and then review.

I'll let the community add more comments,

Let me know if you have any questions :blush:

Kind Regards,

Charaf

Hi Anders,

Have you tried logging out the input and output of your lambda? These sorts of problems are typical due to sending an unexpected input to your data action.

Have you tried hard coding the input value to your data action in Architect? One thing to note, the "expression" mode and "Literal" modes in architect act differently. I believe that the literal mode does not require escaping, so your input would look something like
[{"Name" : "Anders And", "phone" ...

In fact, if you dumped in the escaped input in your example in "expression" mode and then change it to literal mode it will remove the escaping for you.

--Jason

Hi

Just to let you know I got a working lambda data action just a few minutes ago, thanks to your suggestions.

In my architect flow it was two things. Passing an expression into the data action call instead of a variable and assigning the variable with an expression instead of a literal.

I did find it curious, Charaf, that your Lambda function is in a Web Services Data Action category and not AWS Lambda Data Action as mine, but I guess it is just naming?

BR
Anders

Hi,

I used Web Services Data Actions on purpose because I wanted to get something working quickly. (in my environment I don't have the AWS Lambda data actions integration installed ..).

I'll explore the other way how you did it to see if there is any changes on how to invoke the Lambda (maybe it is easier and more adapted..)

Kind Regards,

Charaf