【发布时间】:2019-03-07 19:31:05
【问题描述】:
我创建了一个具有简单 lex 意图的简单机器人。此 lex 意图只有一个插槽 slotTwo。
然后我将它与 python lambda 函数联系起来。我想从 lambda 函数内部访问该槽的值。
python lambda 函数接收参数context 和event。下面的链接显示了参数event 的结构。
https://docs.aws.amazon.com/lex/latest/dg/lambda-input-response-format.html
I copy it here too:
{
"currentIntent": {
"name": "intent-name",
"slots": {
"slot name": "value",
"slot name": "value"
},
"slotDetails": {
"slot name": {
"resolutions" : [
{ "value": "resolved value" },
{ "value": "resolved value" }
],
"originalValue": "original text"
},
"slot name": {
"resolutions" : [
{ "value": "resolved value" },
{ "value": "resolved value" }
],
"originalValue": "original text"
}
},
"confirmationStatus": "None, Confirmed, or Denied (intent confirmation, if configured)"
},
"bot": {
"name": "bot name",
"alias": "bot alias",
"version": "bot version"
},
"userId": "User ID specified in the POST request to Amazon Lex.",
"inputTranscript": "Text used to process the request",
"invocationSource": "FulfillmentCodeHook or DialogCodeHook",
"outputDialogMode": "Text or Voice, based on ContentType request header in runtime API request",
"messageVersion": "1.0",
"sessionAttributes": {
"key": "value",
"key": "value"
},
"requestAttributes": {
"key": "value",
"key": "value"
}
}
但是,当我打印出这个参数的内容时,我只看到了插槽,我可以直接访问它的值,一级。
START RequestId: 60a541d8-b3c8-48b0-a7a3-6b3f65d96482 Version: $LATEST
{
"slotTwo": "some text here"
}
来自 lambda 控制台的测试工作正常。它能够检索值并继续执行逻辑。 但是,当我从 Lex 测试机器人时,它不起作用。 知道为什么吗? 非常感谢 酯类
【问题讨论】:
-
您是如何尝试获取槽值的?您尝试了吗:
event.currentIntent.slots.slotOne如果这不是简单的答案,那么我们至少需要查看您的一些 Lambda 代码来提供帮助。
标签: python lambda amazon-lex