为什么在 dialogflow 中创建的丰富消息不会出现在 Slack 上测试的机器人中?
Why rich message created in dialogflow wouldn't appear in a bot tested on Slack?
我为默认欢迎意图创建了两个答案。
一个是默认的,另一个是显示在 Slack 中的文本响应,另一个使用 Slack 作为我的机器人的通道,单击添加响应开始使用 Dialogflows 创建仅用于 Slack 的响应 UI.
第二个如下,a default template for polling from the docs:
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Where should we order lunch from?* Poll by <fakeLink.toUser.com|Mark>"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":sushi: *Ace Wasabi Rock-n-Roll Sushi Bar*\nThe best landlocked sushi restaurant."
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Vote"
},
"value": "click_me_123"
}
},
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_1.png",
"alt_text": "Michael Scott"
},
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_2.png",
"alt_text": "Dwight Schrute"
},
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_3.png",
"alt_text": "Pam Beasely"
},
{
"type": "plain_text",
"emoji": true,
"text": "3 votes"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":hamburger: *Super Hungryman Hamburgers*\nOnly for the hungriest of the hungry."
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Vote"
},
"value": "click_me_123"
}
},
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_4.png",
"alt_text": "Angela"
},
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_2.png",
"alt_text": "Dwight Schrute"
},
{
"type": "plain_text",
"emoji": true,
"text": "2 votes"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":ramen: *Kagawa-Ya Udon Noodle Shop*\nDo you like to shop for noodles? We have noodles."
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Vote"
},
"value": "click_me_123"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "No votes"
}
]
},
{
"type": "divider"
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Add a suggestion"
},
"value": "click_me_123"
}
]
}
]
}
打招呼时应该会出现类似下图的内容:
但是,如果在 Integrations 中启动测试后出现第一条消息,则第二条消息永远不会出现,即使在右侧的小对话框中也是如此。
我认为问题是我需要制作机器人 public,因为似乎要使用丰富的消息,我们必须复制 Dialogflow 给出的“事件请求 URL”值并将其粘贴到我的 Slack 应用程序设置的交互式消息部分的 'Request URL' 字段中。但是机器人甚至不检索默认消息。
实现我的机器人所遵循的步骤
- 在 Slack 应用程序中,转到 'Bot users' 部分并单击 'Add a Bot User' 按钮。
- 在 Slack 应用程序的“基本信息”部分,复制 'Client ID'、'Client Secret' 和 'Verification Token' 并将它们的值粘贴到下面的相应字段中。
- 启动机器人。
- 复制下面的 'OAuth URL' 值并将其粘贴到 Slack 应用程序设置的“OAuth 和权限”部分的 'Redirect URL(s)' 字段中。节省 URL 秒。
- 从下面的字段中复制活动请求 URL 并将其粘贴到 Slack 应用的“活动订阅”部分中的请求 URL。
- 在“事件订阅”部分启用事件。
- Select "Subscribe to Bot Events" 部分中的必要事件,例如 message.im、message.group、message.channel、im_created。这些事件将定义您的机器人将响应的消息类型(直接消息、通道消息等)。保存更改。我选择了 message.im、message.groups、message.channels、im_created
- 在 Slack 应用程序设置中,转到 'Manage Distribution' 并使用 'Add to Slack' 按钮将机器人添加到您的 Slack 团队(它在那里被窃听)
为了能够使用自定义负载发送您想要的响应,您应该首先添加 Dialogflow 向 slack 发送请求所需的格式。
{
"slack": {
"text": "Testing custom payloads",
"attachments": []
}
}
在附件中,添加块格式,然后它应该会在 slack 中将消息发送给您的机器人。
最终消息如下所示:
{
"slack": {
"text": "",
"attachments": [{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Where should we order lunch from?* Poll by <fakeLink.toUser.com|Mark>"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":sushi: *Ace Wasabi Rock-n-Roll Sushi Bar*\nThe best landlocked sushi restaurant."
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Vote"
},
"value": "click_me_123"
}
},
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_1.png",
"alt_text": "Michael Scott"
},
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_2.png",
"alt_text": "Dwight Schrute"
},
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_3.png",
"alt_text": "Pam Beasely"
},
{
"type": "plain_text",
"emoji": true,
"text": "3 votes"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":hamburger: *Super Hungryman Hamburgers*\nOnly for the hungriest of the hungry."
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Vote"
},
"value": "click_me_123"
}
},
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_4.png",
"alt_text": "Angela"
},
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_2.png",
"alt_text": "Dwight Schrute"
},
{
"type": "plain_text",
"emoji": true,
"text": "2 votes"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":ramen: *Kagawa-Ya Udon Noodle Shop*\nDo you like to shop for noodles? We have noodles."
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Vote"
},
"value": "click_me_123"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "No votes"
}
]
},
{
"type": "divider"
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Add a suggestion"
},
"value": "click_me_123"
}
]
}
]
}]
}
}
我为默认欢迎意图创建了两个答案。
一个是默认的,另一个是显示在 Slack 中的文本响应,另一个使用 Slack 作为我的机器人的通道,单击添加响应开始使用 Dialogflows 创建仅用于 Slack 的响应 UI.
第二个如下,a default template for polling from the docs:
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Where should we order lunch from?* Poll by <fakeLink.toUser.com|Mark>"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":sushi: *Ace Wasabi Rock-n-Roll Sushi Bar*\nThe best landlocked sushi restaurant."
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Vote"
},
"value": "click_me_123"
}
},
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_1.png",
"alt_text": "Michael Scott"
},
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_2.png",
"alt_text": "Dwight Schrute"
},
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_3.png",
"alt_text": "Pam Beasely"
},
{
"type": "plain_text",
"emoji": true,
"text": "3 votes"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":hamburger: *Super Hungryman Hamburgers*\nOnly for the hungriest of the hungry."
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Vote"
},
"value": "click_me_123"
}
},
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_4.png",
"alt_text": "Angela"
},
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_2.png",
"alt_text": "Dwight Schrute"
},
{
"type": "plain_text",
"emoji": true,
"text": "2 votes"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":ramen: *Kagawa-Ya Udon Noodle Shop*\nDo you like to shop for noodles? We have noodles."
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Vote"
},
"value": "click_me_123"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "No votes"
}
]
},
{
"type": "divider"
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Add a suggestion"
},
"value": "click_me_123"
}
]
}
]
}
打招呼时应该会出现类似下图的内容:
但是,如果在 Integrations 中启动测试后出现第一条消息,则第二条消息永远不会出现,即使在右侧的小对话框中也是如此。
我认为问题是我需要制作机器人 public,因为似乎要使用丰富的消息,我们必须复制 Dialogflow 给出的“事件请求 URL”值并将其粘贴到我的 Slack 应用程序设置的交互式消息部分的 'Request URL' 字段中。但是机器人甚至不检索默认消息。
实现我的机器人所遵循的步骤
- 在 Slack 应用程序中,转到 'Bot users' 部分并单击 'Add a Bot User' 按钮。
- 在 Slack 应用程序的“基本信息”部分,复制 'Client ID'、'Client Secret' 和 'Verification Token' 并将它们的值粘贴到下面的相应字段中。
- 启动机器人。
- 复制下面的 'OAuth URL' 值并将其粘贴到 Slack 应用程序设置的“OAuth 和权限”部分的 'Redirect URL(s)' 字段中。节省 URL 秒。
- 从下面的字段中复制活动请求 URL 并将其粘贴到 Slack 应用的“活动订阅”部分中的请求 URL。
- 在“事件订阅”部分启用事件。
- Select "Subscribe to Bot Events" 部分中的必要事件,例如 message.im、message.group、message.channel、im_created。这些事件将定义您的机器人将响应的消息类型(直接消息、通道消息等)。保存更改。我选择了 message.im、message.groups、message.channels、im_created
- 在 Slack 应用程序设置中,转到 'Manage Distribution' 并使用 'Add to Slack' 按钮将机器人添加到您的 Slack 团队(它在那里被窃听)
为了能够使用自定义负载发送您想要的响应,您应该首先添加 Dialogflow 向 slack 发送请求所需的格式。
{
"slack": {
"text": "Testing custom payloads",
"attachments": []
}
}
在附件中,添加块格式,然后它应该会在 slack 中将消息发送给您的机器人。
最终消息如下所示:
{
"slack": {
"text": "",
"attachments": [{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Where should we order lunch from?* Poll by <fakeLink.toUser.com|Mark>"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":sushi: *Ace Wasabi Rock-n-Roll Sushi Bar*\nThe best landlocked sushi restaurant."
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Vote"
},
"value": "click_me_123"
}
},
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_1.png",
"alt_text": "Michael Scott"
},
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_2.png",
"alt_text": "Dwight Schrute"
},
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_3.png",
"alt_text": "Pam Beasely"
},
{
"type": "plain_text",
"emoji": true,
"text": "3 votes"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":hamburger: *Super Hungryman Hamburgers*\nOnly for the hungriest of the hungry."
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Vote"
},
"value": "click_me_123"
}
},
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_4.png",
"alt_text": "Angela"
},
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_2.png",
"alt_text": "Dwight Schrute"
},
{
"type": "plain_text",
"emoji": true,
"text": "2 votes"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":ramen: *Kagawa-Ya Udon Noodle Shop*\nDo you like to shop for noodles? We have noodles."
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Vote"
},
"value": "click_me_123"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "No votes"
}
]
},
{
"type": "divider"
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"emoji": true,
"text": "Add a suggestion"
},
"value": "click_me_123"
}
]
}
]
}]
}
}