I want to hyperlink a particular text in lambda function content. I tried doing this but didn't work.
if (intentName == "greetings") {
var message = {
'contentType': 'PlainText',
'content': '<a href="www.google.com">click here</a>'
}
responseMsg = close( sessionAttributes, 'Fulfilled', message );
}
I know we can hyperlink response card, but i want to hyperlink a particular text in content. Any idea how to do it or any alternative? i am using javascript.
Edit 1 : I am able to do it by Attachments through attachment :
function close(sessionAttributes,fulfillmentState,message){
return{
sessionAttributes,
dialogAction: {
type: 'Close',
fulfillmentState,
message,
"responseCard": {
"contentType": "application/vnd.amazonaws.card.generic",
"genericAttachments": [
{
'title': 'Google',
'attachmentLinkUrl': 'https://www.google.com',
}
]
}
}
};
}
I was trying this out on HTML a few months ago, you can check out my question at LexResponse output does not understand HTML data
The answer that worked was a JS function that looks like this:
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;
}
Please note that this is only to RENDER the response in HTML.
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