[英]Slack Bot Interactive Messages
我是Slack Bot集成的新手。 我想在邮件上显示按钮,所以我的代码是
message = {
"text": "Would you like to play a game?",
"attachments": [
{
"text": "Choose a game to play",
"attachment_type": "default",
"actions": [
{
"name": "chess",
"text": "Chess",
"type": "button",
"value": "chess"
}
]
}
]
}
return sc.api_call("chat.postMessage",
as_user="true",
channel=channel_id,
text=message)
但在Slack频道中,我看到了
text=Would+you+like+to+play+a+game%3F&attachments=%5B%7B%27text%27%3A+%27Choose+a+game+to+play%27%2C+%27attachment_type%27%3A+%27default%27%2C+%27actions%27%3A+%5B%7B%27text%27%3A+%27Chess%27%2C+%27type%27%3A+%27button%27%2C+%27name%27%3A+%27chess%27%2C+%27value%27%3A+%27chess%27%7D%5D%7D%5
为什么会这样?
谢谢
我尚未亲自测试过,但我认为您可以尝试执行以下操作:
message = "Would you like to play a game?"
attachments = [{
"text": "Choose a game to play",
"attachment_type": "default",
"actions": [
{
"name": "chess",
"text": "Chess",
"type": "button",
"value": "chess"
}
]}]
sc.api_call("chat.postMessage",
channel=channel_id,
text=message,
as_user="true",
attachments=attachments)
万一它不起作用,我将尝试在附件中包括一个“ title”字段,如下所示:
attachments = [{
"title": "new title",
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.