【发布时间】:2020-07-01 22:46:16
【问题描述】:
编辑:因为我问了这个问题,所以我创建了一个 ngrok URL,以便在用户按下按钮时接收 Slack POST。
但是,每次我按下按钮时,我都会收到:"POST / HTTP/1.1" 404 -
我使用的是本地 Flask URL,代码如下:
from flask import Flask, request
app = Flask(__name__)
@app.route('/payload', methods=['POST'])
def incoming_slack_message():
req = request.get_json(Force=True)
info = request.form['channel_id']
print(req)
print(info)
print('did it work???')
return 'action successful'
@app.route('/slack/blocks', methods=['POST'])
def incoming_slack_options():
req = request.get_json(Force=True)
info = request.form['payload']
print(req)
print(info)
print('Did it work here??')
return 'ok'
if __name__ == '__main__':
app.run(port=3000, debug = True)
我已经读到我需要在块中包含一个 callback_id 但无论何时我都会得到TypeError: 'NoneType' object is not subscriptable
这是我使用的块,少了 callback_id
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Once your machine is selected, click here."
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "Change",
},
"value": "click_me_123",
"action_id": "button"
}
}
我确信我的烧瓶代码有问题,因为我对 Flask 知之甚少。我不认为我的 Slack Block 有什么问题,但我仍然觉得应该有一个 callback_id。感谢您的时间。
【问题讨论】:
标签: python url post flask slack-api