Dialogflow CX - 使用自定义负载通过自定义事件传回参数

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

在 Dialogflow CX 中,我使用自定义负载在 Dialogflow Messenger 中生成一系列卡片。每张卡都有一个按钮,单击时可以正确触发代理中的自定义事件。

我找不到有关如何在单击按钮时包含参数的文档。在 Dialogflow ES 中,我记得能够通过信使中的事件来执行此操作。

使用 Dialogflow Messenger 是否可以做到这一点?根据生成的卡传回唯一的 ID?

我可以使用芯片,但如果上面有十六进制 ID,它们看起来不太好,例如“属性 d4g1c9 的更多详细信息”

我已经浏览了 stackoverflow 和其他来源,但还没有找到答案,所以提前感谢任何有见解的人!

这是我用来生成卡片和按钮的 JSON 片段。

{
   "richContent":[
      [
         {
            "type":"image",
            "rawUrl":"https://seanmaddison.uk/images/luxury-art-deco-apartment-interior.jpg",
            "accessibilityText":"Primary image"
         },
         {
            "type":"description",
            "title":"ABC Tower apartment",
            "text":[
               "Line 1",
               "Line 2",
               "Line 3",
               "Line 4"
            ]
         },
         {
            "type":"button",
            "icon":{
               "type":"chevron_right",
               "color":"#FF9800"
            },
            "text":"More details",
            "event":{
               "name":"more_details_event",
               "parameters":{
                  "selectedPropertyId":"999888"
               }
            }
         }
      ],
      [
         {
            "type":"image",
            "rawUrl":"https://seanmaddison.uk/images/apartment2.jpg",
            "accessibilityText":"Primary image"
         },
         {
            "type":"description",
            "title":"Torch Tower 3BR",
            "text":[
               "Line 1",
               "Line 2",
               "Line 3",
               "Line 4"
            ]
         },
         {
            "type":"button",
            "icon":{
               "type":"chevron_right",
               "color":"#FF9800"
            },
            "text":"More details",
            "event":{
               "name":"more_details_event",
               "parameters":{
                  "selectedPropertyId":"111222"
               }
            }
         }
      ]
   ]
}```
postback dialogflow-cx
2个回答
0
投票

将 "parameters":{"selectedPropertyId":"111222"} 添加到 Button 事件仅适用于 Dialogflow ES。


0
投票

@FlashMaddison,你能分享一下javascript解决方案吗?。

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