亚马逊Lex聊天机位插槽有问题

问题描述 投票:0回答:1

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

enter image description here

python-3.x aws-lambda amazon-lex
1个回答
2
投票

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

使用它并查看其他事项的文档并发表评论以获得进一步的疑问。

希望能帮助到你。

© www.soinside.com 2019 - 2024. All rights reserved.