gpt4 book ai didi

aws-sdk - 如何使用 PutIntent 方法在 Lex 中添加响应卡?

转载 作者:行者123 更新时间:2023-12-05 07:28:58 24 4
gpt4 key购买 nike

我正在尝试使用 putIntent() 在 lex 中添加响应卡。在 AWS 中,putIntent 方法接受 responseCard 作为字符串,但如何添加 titlesubTitleImageUrl button 值和 button 名称在通过 putIntent 使用响应卡参数创建 Intent 时?

那么谁能帮我解决这个问题。提供示例输入,其中响应卡作为字符串,可以包含上述属性。提前谢谢你。

"slots": [
{
"description": "string",
"name": "string",
"priority": number,
"responseCard": "string",
"sampleUtterances": [ "string" ],
"slotConstraint": "string",
"slotType": "string",
"slotTypeVersion": "string",
"valueElicitationPrompt": {
"maxAttempts": number,
"messages": [
{
"content": "string",
"contentType": "string",
"groupNumber": number
}
],
"responseCard": "string" --(how to pass title, imageUrl and other attributes)
}

最佳答案

看起来您从 Lex API PutIntent 获得了完整响应格式的正确插槽部分.

responseCard 格式可以在 Lambda Input Response Format 找到

"responseCard": {
"version": integer-value,
"contentType": "application/vnd.amazonaws.card.generic",
"genericAttachments": [
{
"title":"card-title",
"subTitle":"card-sub-title",
"imageUrl":"URL of the image to be shown",
"attachmentLinkUrl":"URL of the attachment to be associated with the card",
"buttons":[
{
"text":"button-text",
"value":"Value sent to server on button click"
}
]
}
]
}

假设您以上述格式创建 responseCard 对象作为名为 responseCard 的变量,然后将该对象设为要传入 PutIntent 尝试:

JSON.stringify(responseCard) 如果使用 Node.js,或者
json.dumps(responseCard, separators=(',',':')) 如果使用 Python。

关于aws-sdk - 如何使用 PutIntent 方法在 Lex 中添加响应卡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53068783/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com