Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hyperlink in content in Amazon Lex

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',
                    }
                ]
            }
        }
    };
}
like image 674
Noob Avatar asked May 08 '26 07:05

Noob


1 Answers

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.

like image 157
Arun Balasubramaniam Avatar answered May 11 '26 11:05

Arun Balasubramaniam