facebook Messenger和dialogflow ::从多个通用模板按钮分别检测每个事件 [英] facebook messenger and dialogflow:: detect each event individually from multiple generic templates button

查看:137
本文介绍了facebook Messenger和dialogflow ::从多个通用模板按钮分别检测每个事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 chatbot ,而 dialogflow 是我的nlp平台.目前,我正在使用通用模板在Messenger上展示我的产品.

现在,当客户单击多个模板按钮中的立即购买按钮时,我要检测单击了哪个模板 button (检测单个事件),并希望从 dialogflow 为不同的产品设置不同的消息.

完成这项工作的一种方法是使用 context ,但是我想知道是否可以在不使用 context 的情况下实现相同的结果?

任何建议将不胜感激.谢谢!

解决方案

您可以使用

在这种情况下:和微波"是称为对象的实体的一部分

在对Messenger的响应中,您可以包括对此参数的引用,例如:

  {"facebook":{附件":{"type":"template",有效载荷":{"template_type":"button",按钮":[{"payload":"trigger buy $ objects",标题":立即购买",类型":回发"}]," text":"购买$ objects!"}}}} 

将显示以下参数:

当用户点击按钮时,消息程序将向对话流发送有效载荷的内容,在这种情况下:触发购买烤面包机".请注意,在有效负载中,引用 $ objects 也被实际的参数"toaster"代替.

因此,您可以在Dialogflow中使用训练短语(如触发购买烤面包机")创建新的意图.来捕捉将要购买的物品的这些动作.

您还可以使用webhook实现为 postback按钮响应的生成以及接收答案的意图添加更多逻辑.

I am working with chatbot and dialogflow is my nlp platform. Currently, I am using generic templates to show my products on messenger.

Now, when customer clicks on buy now button from multiple templates buttons I want to detect which template button has been clicked (detect individual event) and want to set different message for different product from dialogflow.

One way to do the job is using context but I want to know whether it is possible to achieve the same outcome without using context or not?

Any suggestion will be appreciated. Thanks!

解决方案

You can use the payload field in the postback button to send a specific message back to dialogflow when the button is clicked.

If you combine this with the parameters, you can use them to trigger specific intents, or just to send the information of the product clicked. For example:

Imagine an intent with the following phrases:

In this case: "toaster" and "microwave" are part of an entity called objects

In the response to messenger, you can include reference to this parameter, for example:

{
  "facebook": {
    "attachment": {
      "type": "template",
      "payload": {
        "template_type": "button",
        "buttons": [
          {
            "payload": "trigger buy $objects",
            "title": "Buy Now",
            "type": "postback"
          }
        ],
        "text": "Buy the $objects!"
      }
    }
  }
}

Which will show the parameter:

When the user clicks on the button, messenger will send dialogflow the content of the payload, in this case: "trigger buy toaster". Note that in the payload the reference $objects is also replaced by the actual parameter "toaster".

So you can create a new intent in Dialogflow with training phrases as "trigger buy toaster" to catch these actions with the object that is going to be purchased.

You can also use the webhook fulfillment to add more logic to the generation of the postback button responses and to the intent that receives the answer.

这篇关于facebook Messenger和dialogflow ::从多个通用模板按钮分别检测每个事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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