如何处理Dialogflow中的自定义有效载荷?

时间:2020-04-24 12:29:35

标签: dialogflow-es slack

我有一个Dialogflow机器人,该机器人触发await_answer1上下文,该上下文应由answer1意图处理。但是,即使将answer1句柄设置为await_answer1并给出输入,它也应该等待:

enter image description here

await_answer1获得以下自定义有效负载的有效负载:

{
  "slack": {
    "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"
            },
            "block_id": "1",
            "type": "section",
            "text": {
              "type": "mrkdwn",
              "text": ":tired_face: *I’ve been feeling more exasperated and hopeless*"
            }
          },
          {
            "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": "2"
            },
            "block_id": "2"
          },
          {
            "accessory": {
              "type": "button",
              "text": {
                "type": "plain_text",
                "text": "Vote",
                "emoji": true
              },
              "value": "3"
            },
            "type": "section",
            "text": {
              "type": "mrkdwn",
              "text": ":relieved: *More calm and hopeful*"
            }
          },
          {
            "block_id": "4",
            "accessory": {
              "type": "button",
              "text": {
                "emoji": true,
                "type": "plain_text",
                "text": "Vote"
              },
              "value": "4"
            },
            "type": "section",
            "text": {
              "type": "mrkdwn",
              "text": ":fearful: *More scared and panicked*"
            }
          },
          {
            "type": "section",
            "text": {
              "type": "mrkdwn",
              "text": ":open_mouth: *More surprised and baffled*"
            },
            "block_id": "5",
            "accessory": {
              "type": "button",
              "text": {
                "emoji": true,
                "type": "plain_text",
                "text": "Vote"
              },
              "value": "5"
            }
          }
        ]
      }
    ]
  }
}

哪个创建:

enter image description here

但是,正如人们看到的那样,它无法处理所选的答案。我怎么知道所选答案中的内容,以查看answer1意向答案中是否存在?

使用Bot Kit构建器,我可以在单击第一个按钮时获得有效载荷:

{
    "type": "block_actions",
    "user": {
        "id": "U0CA5",
        "username": "Amy McGee",
        "name": "Amy McGee",
        "team_id": "T3MDE"
    },
    "api_app_id": "A0CA5",
    "token": "Shh_its_a_seekrit",
    "container": {
        "type": "message",
        "text": "The contents of the original message where the action originated"
    },
    "trigger_id": "12466734323.1395872398",
    "team": {
        "id": "T0CAG",
        "domain": "acme-creamery"
    },
    "response_url": "https://www.postresponsestome.com/T123567/1509734234",
    "actions": [
        {
            "type": "button",
            "block_id": "1",
            "action_id": "pvoS",
            "text": {
                "type": "plain_text",
                "text": "Vote",
                "emoji": true
            },
            "value": "1",
            "action_ts": "1587732582.695699"
        }
    ]
}

但是如何处理这样的有效载荷?

0 个答案:

没有答案