Я новичок в слабом API и пытаюсь реализовать интерактивные сообщения, используя команду косой черты с помощью flask и python.Я застрял на последнем шаге, где я хочу обновить оригинальное сообщение вместо его замены.
Каждый раз, когда я посылаю ответ по нажатию кнопки, оригинальное сообщение заменяется.
Я могу извлечь original_message из полезной нагрузки, но не уверен, как добавить ответ пользователя к этому сообщению.Вот мой код:
@application.route("/summarize", methods=['POST'])
def hello():
attach_json = {
"response_type": "in_channel",
"text": "Interested in outing?",
"attachments": [
{
"text": "Response",
"fallback": "You are unable to choose any option",
"callback_id": "confirmation",
"color": "#3AA3E3",
"attachment_type": "default",
"actions": [
{
"name": "confirm_btn",
"text": "Yes",
"type": "button",
"value": "yes"
},
{
"name": "confirm_btn",
"text": "No",
"type": "button",
"value": "No"
},
{
"name": "confirm_btn",
"text": "Can't decide",
"type": "button",
"value": "unavailable"
}
]
}
]
}
print(request.get_data())
#return Response("test", status=200)
return Response(response=json.dumps(attach_json), status=200, mimetype="application/json")
@application.route("/actions", methods=['POST'])
def actions():
statement = None
slack_req = json.loads(request.form.get('payload'))
response = '{"text": "Hi, <@' + slack_req["user"]["id"] + '>"}'
user = slack_req["user"]["name"]
user_response = slack_req["actions"][0]["value"]
orig_message = slack_req["original_message"]
if user_response == "yes":
statement = user + "chose " + user_response
print(slack_req)
return Response(response=statement, status=200, mimetype="application/json")
if __name__ == "__main__":
application.run(debug=True)
Буду очень признателен за любую помощь!