如何处理dialogflow中的自定义有效载荷的答案? [英] How to handle the answer of a custom payload in dialogflow?

查看:71
本文介绍了如何处理dialogflow中的自定义有效载荷的答案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个机器人可以使用Dialogflow for Slack很好地处理欢迎意图.但是,我不知道如何处理 welcome intent 的答案以解雇第二篇文章.实际上,输出 await_answer1 上下文的 welcome intent 在json中显示了以下模板:

I have a bot that handles well the welcome intent using Dialogflow for Slack. However I don't know how to deal with the answer to the welcome intent to fire the second post. Indeed, the welcome intent, which outputs a await_answer1 context, shows the following template in json:

{
  "slack": {
    "text": "",
    "attachments": [
      {
        "blocks": [
          {
            "type": "section",
            "text": {
              "type": "mrkdwn",
              "text": "*How have you been feeling?* Poll by <fakeLink.toUser.com|Mihailo>"
            }
          },
          {
            "type": "divider"
          },
          {
            "type": "section",
            "text": {
              "type": "mrkdwn",
              "text": ":tired_face: *I’ve been feeling more exasperated and hopeless*"
            },
            "accessory": {
              "type": "button",
              "text": {
                "emoji": true,
                "type": "plain_text",
                "text": "Vote"
              },
              "value": "1"
            }
          },
          {
            "accessory": {
              "value": "2",
              "type": "button",
              "text": {
                "emoji": true,
                "type": "plain_text",
                "text": "Vote"
              }
            },
            "type": "section",
            "text": {
              "type": "mrkdwn",
              "text": ":expressionless: *Generally, less freaked out than other people*"
            }
          },
          {
            "accessory": {
              "type": "button",
              "text": {
                "emoji": true,
                "type": "plain_text",
                "text": "Vote"
              },
              "value": "3"
            },
            "type": "section",
            "text": {
              "type": "mrkdwn",
              "text": ":relieved: *More calm and hopeful*"
            }
          },
          {
            "type": "divider"
          },
        ]
      }
    ]
  }
}

我想处理答案.因此,我创建了一个 answer1 意图,该意图将 await_answer1 作为输入上下文.训练短语是上述模板的输出: 1 2 3 4 5 .并且默认的文本响应是 Interesting!.但是,选择答案后的是 Fallback intent ,而不是 answer1 .因此,如何在dialogflow中处理自定义有效载荷的答案?

And I would like to handle the answer. So I created an answer1 intent which takes the await_answer1 as an input context. The training phrases are the output of the above template : 1, 2, 3, 4, 5. And the Default text response is Interesting! However after selecting the answer is the Fallback intent rather than answer1. Therefore, how to handle thee answer of a custom payload in dialogflow?

我尝试添加 block_id :

{
  "slack": {
    "text": "",
    "attachments": [
      {
        "blocks": [
          {
            "type": "section",
            "text": {
              "type": "mrkdwn",
              "text": "*How have you been feeling?* Poll by <fakeLink.toUser.com|Mihailo>"
            }
          },
          {
            "type": "divider"
          },
          {
            "accessory": {
              "type": "button",
              "text": {
                "emoji": true,
                "type": "plain_text",
                "text": "Vote"
              },
              "value": "1"
            },
            "type": "section",
            "block_id": "1",
            "text": {
              "type": "mrkdwn",
              "text": ":tired_face: *I’ve been feeling more exasperated and hopeless*"
            }
          },
          {
            "accessory": {
              "type": "button",
              "text": {
                "emoji": true,
                "type": "plain_text",
                "text": "Vote"
              },
              "value": "2"
            },
            "type": "section",
            "block_id": "2",
            "text": {
              "type": "mrkdwn",
              "text": ":expressionless: *Generally, less freaked out than other people*"
            }
          },
          {
            "type": "section",
            "text": {
              "type": "mrkdwn",
              "text": ":relieved: *More calm and hopeful*"
            },
            "accessory": {
              "type": "button",
              "text": {
                "emoji": true,
                "type": "plain_text",
                "text": "Vote"
              },
              "value": "3"
            }
          },
          {
            "type": "section",
            "block_id": "4",
            "text": {
              "type": "mrkdwn",
              "text": ":fearful: *More scared and panicked*"
            },
            "accessory": {
              "value": "4",
              "type": "button",
              "text": {
                "emoji": true,
                "type": "plain_text",
                "text": "Vote"
              }
            }
          },
          {
            "type": "section",
            "block_id": "5", 
            "text": {
              "type": "mrkdwn",
              "text": ":open_mouth: *More surprised and baffled*"
            },
            "accessory": {
              "value": "5",
              "type": "button",
              "text": {
                "emoji": true,
                "type": "plain_text",
                "text": "Vote"
              }
            }
          }
        ]
      }
    ]
  }
}

但是,当我单击按钮时,DialogFlow bot落在DefaultFallback意图上,而不是转到应该处理 await_answer1 上下文的 answer1 意图上.

Yet when I click on the button the DialogFlow bot falls on the DefaultFallback intent rather than going to the answer1 intent that should handle the await_answer1 context.

推荐答案

您必须在块排列的每个元素的自定义有效负载中包含一个block_id,并且此值必须在您打算进行的训练中,因为当您收到互动,您将收到此block_id.例如

You must include a block_id in your custom payload in each element of the block arrangement and this value must be in the training phrases of your intention since when you receive an interaction you receive this block_id. For example

  {
      "type": "section",
      "text": {
          "type": "mrkdwn",
          "text": "*How have you been feeling?* Poll by <fakeLink.toUser.com|Mihailo>"
        },
       block_id: "section_1"
     }

我希望这是您想要的,但是您可以写信给我,以帮助您解决疑虑.

I hope it is what you are looking for but you can write to me to help you solve your doubts.

这篇关于如何处理dialogflow中的自定义有效载荷的答案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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