[英]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.