将选定的按钮值从fb Messenger传递到对话框流 [英] passing selected button value from fb messenger to dialog flow

查看:169
本文介绍了将选定的按钮值从fb Messenger传递到对话框流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法理解通过webhook来回传递参数的简单方式.我正在尝试使用对话框流和fb Messenger来构建一个简单的机器人.我要求向最终用户显示两个按钮以选择蛋糕类型.我可以使用以下自定义响应显示选项:

I am failing to understand the simple passing of parameters to and fro via webhook. i am trying to build a simple bot using dialog flow and fb messenger. i have requirement to show two buttons to the end user to pick a cake type. i am able to show the options using the below custom response:

{
  "facebook": {
    "attachment": {
      "type": "template",
      "payload": {
        "template_type": "button",
        "text": "What kind of cake would you like?",
        "buttons": [
          {
            "type": "postback",
            "payload": "witheggs",
            "title": "Contain Eggs"
          },
          {
            "type": "postback",
            "payload": "noeggs",
            "title": "Eggless"
          }
        ]
      }
    }
  }
}

一旦用户点击两个按钮之一,然后如何在对话框流中将其设置为某个变量,然后询问下一个问题?

once user tap one of the two buttons then how do i set it to some variable in dialog flow and then ask next set of question?

推荐答案

我想您在这里缺少几个步骤.在我向您解释该怎么做之前,请确保知道postback是什么!按下Postback时,文本将作为用户查询发送到dialogflow.com.

I guess you're missing few steps here. Before, I explain you what to do, be sure to know what a postback is! Postback, when tapped, the text is sent as a user query to dialogflow.com.

第1步:我创建了一个具有自定义有效负载的意图,如下所示:

Step-1: I created an intent with custom payload as follows:

步骤2:现在,我在输入noeggs的用户输入中创建了一个新的意图,该意图的类型为postback&有效负载为上一张图片中的noeggs.

Step-2: Now, I created a new intent where I have entered user says as noeggs which is of type postback & payload as noeggs the in previous image.

第3步:保存并保存在FB Messenger中进行测试.

Step-3: Save & test it in FB Messenger.

因此,基本上,这里发生的是,当您单击Eggless按钮时,作为noeggs的回发将作为用户查询发送到dialogflow.com,其中意图与用户说的与noeggs&发回响应.

So basically, what has happened here is, when you click on Eggless button, postback as noeggs is sent as user query to dialogflow.com where there is an intent which matches user says with noeggs & sends response back.

这篇关于将选定的按钮值从fb Messenger传递到对话框流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆