Amazon Lex中的响应卡中的超链接按钮

编程入门 行业动态 更新时间:2024-10-11 05:22:39
本文介绍了Amazon Lex中的响应卡中的超链接按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用Amazon lex制作响应卡,以给出响应卡,该响应卡具有指向另一个网站的按钮.以下是我在AWS Lambda python中使用的代码.我已经在Facebook Messenger上发布了聊天机器人.但是,每当我在fb Messenger中选择按钮时,该按钮中的链接似乎都无法将我带到该网站.有什么办法可以将响应卡按钮变成超链接按钮?

I am trying to make a response card in amazon lex to give out a response card that has a button that leads to another website. Below is the code that I have used in aws lambda python. I have published the chatbot on facebook messenger. But whenever I select the button in fb messenger, the link in the button does not seem to bring me to the website. Is there any way to make the response card button turn into hyperlink button?

def location(intent_request): session_attributes = intent_request['sessionAttributes'] if intent_request['sessionAttributes'] is not None else {} return { 'dialogAction': { 'type': 'Close', 'fulfillmentState': 'Fulfilled', 'message': { 'contentType': 'PlainText', 'content': 'Here is a map' }, 'responseCard': { 'version': '17', 'contentType': 'application/vnd.amazonaws.card.generic', 'genericAttachments': [ { 'title': 'Here is a list of hospitals', 'subTitle': 'Below is a map', "buttons":[ { "text":"Show Google Maps", "value":"www.google/maps/search/?api=1&query=nearby+hospitals" } ] } ] } } }

推荐答案

到目前为止,您无法使用按钮进行操作.这些按钮具有两个参数text和value. 单击按钮时,按钮的value发送到服务器,而text附加到聊天室.因此,它只会将值发送回Lex,但不能打开功能作为超链接.

As of now you cannot do that using the buttons. The buttons have two parameters text and value. When you click on a button, the value of button is sent to the servers and the text is appended to the chat. So it will just send the value back to Lex but cannot open function as hyperlink.

但是,您可以在响应卡中使用图像来实现相同的功能. imageUrl是要显示的图像的URL,而attachmentLinkUrl是要打开的URL.因此,我建议您删除按钮并使用要显示的地图图像,并在attachmentLinkUrl中提供您的超链接. 另外,如果要显示多个超链接,则可以在单个responseCard中显示多个卡片(最多10张).

However you can use image in the response card for the same functionality. imageUrl is the url of the image to be displayed, and attachmentLinkUrl is the url which you want to open. So I would suggest you to remove buttons and use an image of map to be shown and provide your hyperlink in attachmentLinkUrl. Also, if you want to show multiple hyperlink, you can show multiple cards (upto 10) in a single responseCard.

以下是示例代码:

return { 'dialogAction': { 'type': 'Close', 'fulfillmentState': 'Fulfilled', 'message': { 'contentType': 'PlainText', 'content': message }, 'responseCard': { 'version': '0', 'contentType': 'application/vnd.amazonaws.card.generic', 'genericAttachments': [ { 'title': 'Here is a list of hospitals', 'subTitle': 'Below is a map', 'attachmentLinkUrl': 'www.google/maps/search/?api=1&query=nearby+hospitals', 'imageUrl': 'images.sftcdn/images/t_optimized,f_auto/p/95612986-96d5-11e6-af7c-00163ec9f5fa/3771854867/google-maps-screenshot.png' }, { 'title': 'Here is a list of medical shops', 'subTitle': 'Below is a map', 'attachmentLinkUrl': 'www.google/maps/search/?api=1&query=nearby+medical+shops', 'imageUrl': 'images.sftcdn/images/t_optimized,f_auto/p/95612986-96d5-11e6-af7c-00163ec9f5fa/3771854867/google-maps-screenshot.png' } ] } } }

您也可以查看此,以获取有关响应卡的详细信息. 希望对您有所帮助.

You can check this as well for details about response cards. Hope it helps.

更多推荐

Amazon Lex中的响应卡中的超链接按钮

本文发布于:2023-11-28 06:00:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641211.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:超链接   按钮   Amazon   Lex

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!