我試圖通過它們的API將附件添加到鬆散消息。我使用他們推薦的python包裝。我可以發送和接收基本消息,但是當我嘗試以2個按鈕的形式添加附件時,它會失敗。我做了一個懶散的應用程序,並將它們連接到他們的API中。我仔細審查了API,無法弄清楚發生了什麼。將附件添加到Slackbot
def process_message(message, channel):
intro_msg = json.loads('{
"text": "What would you like to do?",
"attachments": [
{
"text": "Choose an action",
"fallback": "You are unable to choose an option",
"callback_id": "lunch_intro",
"color": "#3AA3E3",
"attachment_type": "default",
"actions": [
{
"name": "enroll",
"text": "Enroll",
"type": "button",
"value": "enroll"
},
{
"name": "leave",
"text": "Leave",
"type": "button",
"value": "leave"
}
]
}
]
}')
r = sc.api_call("chat.postMessage", channel=channel, attachments=intro_msg)
的響應是唯一{u'ok': False, u'error': u'no_text'}
你可以告訴我,當你直接傳遞字典對象時,你看到了什麼,而不是使用'dict'對象創建'intro_msg'。 –