我有一个机器人可以使用Dialogflow for Slack很好地处理欢迎意图。但是,我不知道如何处理welcome intent
的答案以触发第二篇文章。实际上,输出welcome intent
上下文的await_answer1
在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中处理自定义有效负载的答案?
我尝试加入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意图上,而不是转到应该处理answer1
上下文的await_answer1
意图上。
答案 0 :(得分:0)
我不确定原因为何,但是如果删除输出和输入上下文,则此设置可以正常工作。
这些是我使用的附件属性,我只更改了value
属性,并将这些值作为示例短语添加到了我的意图中。
"accessory": {
"value": "First",
"type": "button",
"text": {
"emoji": true,
"type": "plain_text",
"text": "Vote"
}
},
"accessory": {
"value": "Second",
"type": "button",
"text": {
"emoji": true,
"type": "plain_text",
"text": "Vote"
}
},
"accessory": {
"type": "button",
"text": {
"emoji": true,
"type": "plain_text",
"text": "Vote"
},
"value": "Third"
如果您想建立一个非常定制的Slack体验,可能值得研究Slack API。当前,在Dialogflow UI中,not supported是OnClick事件和其他特定于Slack的事件,但是您可以将其与webhook中的代码集成在一起,然后从那里更详细地自定义对话。
答案 1 :(得分:0)
您必须在块排列的每个元素的自定义有效载荷中包含一个block_id,并且此值必须在您意图的训练短语中,因为当您收到交互时,您会收到此block_id。例如
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*How have you been feeling?* Poll by <fakeLink.toUser.com|Mihailo>"
},
block_id: "section_1"
}
我希望这是您想要的,但是您可以写信给我,以帮助您解决疑虑。