BotFramework Composer and Slack Block Kit



如何使用c#懒人适配器从Bot框架Composer Bot发送BlockKit附件?

我试图在。lg中使用这个,但到达slack客户端的唯一消息是:值不能为空。(参数uriString)

# SendSlackResponse()
[Activity
Attachments = ${json(SlackMessage())}
]
# SlackMessage()
- ```
{
"type": "application/json",
"name": "blocks",
"content": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hello, Assistant to the Regional Manager Dwight! *Michael Scott* wants to know where yo``u'd like to take the Paper Company investors to dinner tonight.nn *Please select a restaurant:*"
}
}
]
}
```

问题是第一个type属性必须是" Attachment"。否则,对话管理器将创建一个仅包含属性类型和属性内容的活动,它将添加我的json: https://github.com/microsoft/botbuilder-dotnet/blob/c98feb7c58a5564cd8d31bedf050819af70058a3/libraries/Microsoft.Bot.Builder/ActivityFactory.cs#L210

然后名称属性不是在at .name下,而是在at .content.name下,这使得slack适配器在将活动转换为slack消息时走不同的路径,该消息期望传递一个Uri,因此出现错误:https://github.com/microsoft/botbuilder-dotnet/blob/main/libraries/Adapters/Microsoft.Bot.Builder.Adapters.Slack/SlackHelper.cs L56

可以工作的json(只需要修改根节点的type属性):

{
"type": "Attachment",
"name": "blocks",
"content": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${answer}"
}
},
{
"type": "divider"
},
...MORE JSON HERE....
]
}

最新更新