响应卡未显示-Amazon Lex [英] Response cards not showing -Amazon lex

查看:65
本文介绍了响应卡未显示-Amazon Lex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个lex chatbot并将其集成到网站中.它工作正常.我知道我必须从lambda调用响应卡.我也这样做.此外,我在lex console中启用了repsonse card复选框.这一切,我在网站上看不到按钮.除了响应卡,还有其他显示按钮的方法吗?

I have created a lex chatbot and integrated it into website .Its working fine.I got to know that I have to invoke response cards from lambda .I did that too.Also,I enabled repsonse card checkbox in lex console.After all this,I am not able too see the buttons in the website.Is there any other way to display the buttons other than response cards?

下面是代码:在这里,完成后,我给了响应卡,这意味着在消息嘿,您的票已被举起"之后,将显示按钮.这将在lex test chatbot中显示./p>

Below is the code:Here,after the fulfillment,I have given the response card which means that after the message "Hey your ticket has been raised",the buttons will be displayed.This displays in lex test chatbot.

import json
import logging
import re
import http.client
import mimetypes

logger = logging.getLogger()
logger.setLevel(logging.DEBUG)


def close():
    val=  {
             "dialogAction":
            {
                "fulfillmentState":"Fulfilled",
                "type":"Close",
                "message":
                 {
                     "contentType":"PlainText",
                     "content":"Hey your ticket has been raised"
                 },
                'responseCard': {
                'version': '0',
                'contentType': 'application/vnd.amazonaws.card.generic',
                'genericAttachments': [
                    {
                    'title': 'title1',
                    'subTitle': 'subtitle',
                    "buttons":[ 
                     {
                        "text":"button 1",
                        "value":"value 1"
                     },
                     {
                        "text":"button 2",
                        "value":"value 2"
                     },
                     {
                        "text":"button 3",
                        "value":"value 3"
                     }
                        ]
                    }
                    ]
                                 }
                    }
                }
    print(val)
    return val
    

def lambda_handler(event, context):
   
    slots = event['currentIntent']['slots']
    empidemployee= event['currentIntent']["slots"]["empidemployee"]
    latestdesc= event['currentIntent']["slots"]["latestdesc"]
    latestservice= event['currentIntent']["slots"]["latestservice"]
    latestimpactvalue= event['currentIntent']["slots"]["latestimpactvalue"]
    latesturgency= event['currentIntent']["slots"]["latesturgency"]
    basicinfo=event['currentIntent']["slots"]["basicinfo"]
    val=close()
    return val
    

推荐答案

我相信您的问题是版本号.尝试将其设置为1'1'.

I believe your problem is the version number. Try setting it to 1 or '1'.

我找不到关于原因的明确解释,但至少这里有一些证据:

I couldn't find a clear explanation as to why, but here are some evidences at least:

从AWS示例文档中:动态生成响应卡

From the AWS example doc: Generating Response Cards Dynamically

responseCard: {
    "version": 1,
        ...
}

我还对您正在使用的lex-web-ui文件以及

I also looked deeper into the lex-web-ui files you are using and in the lex-web-ui.js file it has this:

shouldDisplayResponseCard: function shouldDisplayResponseCard() {
  return this.message.responseCard && (this.message.responseCard.version === '1' || this.message.responseCard.version === 1) && this.message.responseCard.contentType === 'application/vnd.amazonaws.card.generic' && 'genericAttachments' in this.message.responseCard && this.message.responseCard.genericAttachments instanceof Array;
},

然后专门检查(this.message.responseCard.version === '1' || this.message.responseCard.version === 1)以便显示.

And that specifically checks for (this.message.responseCard.version === '1' || this.message.responseCard.version === 1) in order to display.

这篇关于响应卡未显示-Amazon Lex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆