Programing/Python
[slack_bolt] app.event 또는 app.action에서 reply 하기
mjune.kim
2024. 4. 15. 13:29
Reply 로 메세지를 생성하기 위해서는 아래와 같이 thread_ts 를 say로 전달해 주면 된다.
app.event
@app.event("message")
def handle_message_events(body, event, say):
say({
"channel": body["event"]["channel"],
"text": "This is a threaded reply!",
"thread_ts": body.get("thread_ts", body["event"]["ts"]), # Use thread_ts if available, otherwise use ts
})
app.action
@app.action("action_id")
def button_click(ack, body, say):
# Acknowledge the action
ack()
say({
"channel": body['channel']['id'],
"text": "This is a threaded reply!",
"thread_ts": body.get("thread_ts", body["message"]["ts"]), # Use thread_ts if available, otherwise use ts
})