【问题标题】:Trouble with Amazon Lex chatbot slotsAmazon Lex 聊天机器人插槽的问题
【发布时间】:2018-06-04 21:48:42
【问题描述】:

我正在尝试创建一个聊天机器人。聊天机器人会提示问题“你的国籍是什么?(A,B,C)”,如果用户说 C,我想立即结束聊天,说“对不起,C 不适用于申请。只有 A 和 B 可以申请。”我知道我必须在上述问题之后取消选中“必需”复选框,但我不确定在 aws lambda 中输入什么才能发生。

【问题讨论】:

    标签: python-3.x aws-lambda amazon-lex


    【解决方案1】:

    取消选中所需的复选框后,在 lambda 代码中执行以下操作:

    # inside dialogcodehook
    slots = intent_request['currentIntent']['slots']
    nation = slots['nation']
    if nation == 'C':
        return close('I am sorry, C is not applicable to apply. Only A and B can apply.')
    # rest of your code
    
    def close(msg):
    "dialogAction": {
        "type": "Close",
        "fulfillmentState": "Fulfilled",
        "message": {
          "contentType": "PlainText",
          "content": msg
        }
    }
    

    您可能希望看到this questionthis questionthis questionthis documentation 等。

    使用它并查看其他内容的文档并评论以了解更多疑问。

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 2017-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多