我开始在 Python 中使用 Slack API。
到目前为止,我能够很好地连接它并发送消息。
我想创建一个对话框选项,以便用户可以输入变量并且我能够做到,但是当我尝试提交对话框时,出现错误消息:我们在连接时遇到了一些问题。再试一次?
这是代码:
@app.route("/test", methods=["POST"])
def message_actions():
data = request.form
user_id = data.get('user_id')
client.api_call(api_method="dialog.open",
json={"trigger_id": data.get("trigger_id"),
"dialog": {
"title": "Request a coffee",
"submit_label": "Submit",
"callback_id": user_id + "coffee_order_form",
"elements": [{
"label": "Coffee Type",
"type": "select",
"name": "meal_preferences",
"placeholder": "Select a drink",
"options": [
{
"label": "Cappuccino",
"value": "cappuccino"
},
{
"label": "Latte",
"value": "latte"
},
{
"label": "Pour Over",
"value": "pour_over"
},
{
"label": "Cold Brew",
"value": "cold_brew"
}
]
}
]
}}
)
return make_response("", 200)