代码之家  ›  专栏  ›  技术社区  ›  Luqman NurHakim Samsul Kahar

Amazon Lex chatbot插槽出现问题

  •  0
  • Luqman NurHakim Samsul Kahar  · 技术社区  · 8 年前

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

    enter image description here

    1 回复  |  直到 8 年前
        1
  •  2
  •   sid8491    8 年前

    取消选中所需复选框后,在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 question , this question , this question , this documentation 等

    使用它,查看文档了解其他内容,并对进一步的疑问进行评论。

    希望有帮助。