I am currently trying to send multiple messages from AWS Lambda to Lex in Python 3.6, but Lex considers my answers as incorrect.
I got multiple errors such as :
- Received invalid response from Lambda: Can not construct instance of Message, problem: contentType must not be null
- "content" can not be blank
- Syntax error in module 'lambda_function': unexpected character after line continuation character [after trying to escape my JSON]
- Received invalid response from Lambda: Can not deserialize instance of java.lang.String out of START_OBJECT token at...
So basically, I am doing this like this :
messages = [
{
'contentType': 'PlainText',
'group': 0,
'value': 'Applying this criteria, you have %d result(s) left.' % len(json.loads(session_attributes['results']))
},
{
'contentType': 'PlainText',
'group': 1,
'value': 'What do you want to do next ?'
}
]
format_message('PlainText', messages)
with format_message which TEMPORARILY looks like this (because I've tried many MANY things to make it work... without any success) -- but this one does not work either :
def format_message(message_type, content):
return {'messages': content}
In the end, it gives this format of response (with other lex pre-requisites such as slots etc. but I won't display them here because I don't think it is relevant) :
{'message': {'messages': [{'group': 0, 'contentType': 'PlainText', 'value': 'Applying this criteria, you have 1 result(s) left.'}, {'group': 1, 'contentType': 'PlainText', 'value': 'What do you want to do next ?'}]
I have tried to convert 'messages' array into a string, send it as a JSON etc. but nothing seems to work.
I read all of the documentation listed in this issue...
Have someone already found a solution please ?
Thank you,