aws-samples / aws-lex-web-ui

Sample Amazon Lex chat bot web interface
Other
745 stars 471 forks source link

customizing lex response #170

Closed MeerZaheen closed 5 years ago

MeerZaheen commented 5 years ago

I set ui.AllowSuperDangerousHTMLInMessage to "true" but I'm not sure how to configure my lambda function?

<-----lambda function---->

let output - "output" + HUB + ":\n";

ddb.query(params).promise() .then(data => { console.log("data received:". data); if (data.items.length <1){ console.log("no items found"); return resolve({ sessionAttributes, dialogAction:{ type: 'close', fullfillmentstate, "message": { "contentType": "PlainText", "content": "There are no Data" } } });

bobpskier commented 5 years ago

There are two ways to emit content that takes advantage of either markdown or html from a lex lambda based handler.

Lex response typically contain a dialogAction with a message property. The message has attributes of contentType and content. Set the contentType to 'CustomPayload' and the content to contain markdown. Return this as the response from your lambda handler. The is described at https://docs.aws.amazon.com/lex/latest/dg/lambda-input-response-format.html#using-lambda-response-format.

The second method is to use an older technique which was specific to the lex-web-ui. You can set a session attribute named either appContext.altMessages.markdown or appContext.altMessages.html. See https://github.com/aws-samples/aws-lex-web-ui/tree/master/lex-web-ui#markdown-and-html-support.