I am new to Amazon Lex. I am trying to return a hyperlink as part of the "content" response from Lambda function to the Amazon Lex. Basically I have doing the following:
var message = {
'contentType': 'PlainText',
'content': 'We offer x,y,z. For more information, visit our <a href="www.xyz.com">website</a>'
}
This returns the whole response as a string whereas I am expecting the html part to be rendered before displaying on the chatbot. I don't want to use a responseCard below my response. Is that possible to include hyperlink in the content returned? Thanks
PLEASE NOTE THAT THIS IS FOR RENDERING THE CONVERSATION ON A HTML PAGE
I had this same issue when I was developing a HTML page to render the chat between an user and the chatbot. I managed to solve it using the following Javascript Function:
function showResponse(lexResponse) {
var conversationDiv = document.getElementById('conversation');
var responsePara = document.createElement("P");
responsePara.className = 'lexResponse';
if (lexResponse.message) {
var message = lexResponse.message.replace(/"/g, '\'');
responsePara.innerHTML = message;
responsePara.appendChild(document.createElement('br'));
}
conversationDiv.appendChild(responsePara);
conversationDiv.scrollTop = conversationDiv.scrollHeight;
}
For Reference, you can refer to the question I asked regarding this same issue: LexResponse output does not understand HTML data
Rendering of the content is the job of client. The test console window of Lex does not support hyperlinks rendering.
However if you deploy your chatbot to some channel like facebook or slack, it will work just fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With