- Newest
- Most votes
- Most comments
To send Session Attribute value from Connect to Lex, it needs to be done in the Contact Flow. So in the blog post, it will be in the Get Customer Input block in the flow that your chat will kick off, and you can add various values in the Session Attributes values. Then your DialogCodeHook Lambda will get them.
https://docs.aws.amazon.com/connect/latest/adminguide/how-to-use-session-attributes.html
Maybe I am wrong but what I want is when an intent of lex is fulfilled it will call the lambda and then after further processing lambda sends the response back to lex but sessionAttribute in the object sent to lambda by lex is empty. and the tutorial I am following does not use the Get Customer Input block in the connect flow.
above is the tutorial link.
Hi Mehar,
First of all, which tutorial are you using? because the link you mentioned is broken. Is it this one?
Next the code you have mentioned is passing the control to Amazon connect and not lex. Is this line of code creating the same error or a different one? The function is requesting amazon connect to create an outbound call. The "Attributes" option mentioned there contributes to Amazon connect's attribute and not lex's, hence, this will not help you set a Lex bot "session attribute".
Now, coming to the error. First I have a few questions:
- Is the message ""Okay, our representative will call you shortly. Thanks." your intented response to the user or is it something else?
- Have you passed the dialog action type as "close"?
If response for both your questions is no this means this error message will not help you much in detecting where exactly that null value is.
Here are some important points to remember:
- Session Attributes are not mandatory to be set for lex. The response will be valid without it as well.
- The "Invalid Lambda Response" error occurs only when you have missed a mandatory element in the response or the structure of the response being sent is incorrect.
- To see the mandatory elements and the correct structure for your response JSON please see this doc[1]. you can find session attributes inside the "sessionState" field.
- As it will be very difficult for me to give a solution without debugging the code itself. I request you to kindly follow this method while debugging.
- Identify the flow in which you have getting the error.
- trace the lambda function according to the flow( using print statements or logging) to find where exactly the error is being generated from.
- As the error is related to Response Json format issue. Try to print out the final response just before returning it and compare it with the format in the doc[1]. Check if you are missing anything, or if the format is incorrect.
Kindly let me know whatever you find here and I can help you further.
----- Reference ------
[1] https://docs.aws.amazon.com/lexv2/latest/dg/lambda-response-format.html
It looks like you are using the old Lex v1 response format. As has been mentioned above, if you are using Lex v2 the response should look something like this:
{ "sessionState": { "sessionAttributes": {}, "dialogAction": { "type": "Close" }, "intent": { "confirmationState": <<AS PASSED INTO LAMBDA>>, "name": <<AS PASSED INTO LAMBDA>>, "slots": {<<AS PASSED INTO LAMBDA>>}, "state": "Fulfilled" } }, "messages": [ { "contentType": "PlainText", "content": "Okay, our representative will call you shortly. Thanks." } ] }
Relevant content
- asked a year ago
- asked a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated 2 years ago
Can you elaborate a little more what you try to achieve? To note, that Amazon Connect Attributes for a Contact are not automatically Lex Session Attributes.
E.g. where and how are you invoke Amazon Lex in that flow?