You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Dialogflow CX:如何通过Dialogflow Messenger卡片按钮传递参数?

Dialogflow CX卡片按钮带参数触发自定义事件的解决方案

完全可以在Dialogflow Messenger中实现卡片按钮触发自定义事件时附带参数,你的JSON写法本身是正确的,只需在Dialogflow CX端完成对应配置即可接收参数(比如房产唯一ID)。

关键配置步骤

  • 确认事件与参数的绑定:你在按钮event字段中定义的parameters会被Dialogflow Messenger完整发送给CX代理,无需额外修改前端payload。
  • CX代理端参数接收配置:
    1. 创建或编辑绑定more_details_event的意图,在意图的「事件触发器」中添加more_details_event;
    2. 在意图的「参数」列表中添加selectedPropertyId参数,设置参数类型为字符串(匹配你传递的ID格式);
    3. 保存意图后,测试时点击卡片按钮,即可在CX会话参数中看到selectedPropertyId的对应值,也可在webhook中直接调用该参数。

你的代码示例(已格式化)

{
  "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"
          }
        }
      }
    ]
  ]
}

额外说明

如果测试中参数未正常接收,可检查:

  • 意图是否正确绑定了目标自定义事件;
  • 参数名称是否与payload中的selectedPropertyId完全一致(大小写敏感);
  • CX代理的测试会话是否清空了旧参数,避免干扰。

内容的提问来源于stack exchange,提问作者FlashMaddison

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 05:23:12