-
Notifications
You must be signed in to change notification settings - Fork 263
/
Copy pathapp.py
42 lines (35 loc) · 1.22 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
from slack_bolt import App
# Initializes your app with your bot token and signing secret
app = App(
token=os.environ.get("SLACK_BOT_TOKEN"),
signing_secret=os.environ.get("SLACK_SIGNING_SECRET"),
)
# Listens to incoming messages that contain "hello"
# To learn available listener method arguments,
# visit https://slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html
@app.message("hello")
def message_hello(message, say):
# say() sends a message to the channel where the event was triggered
say(
blocks=[
{
"type": "section",
"text": {"type": "mrkdwn", "text": f"Hey there <@{message['user']}>!"},
"accessory": {
"type": "button",
"text": {"type": "plain_text", "text": "Click Me"},
"action_id": "button_click",
},
}
],
text=f"Hey there <@{message['user']}>!",
)
@app.action("button_click")
def action_button_click(body, ack, say):
# Acknowledge the action
ack()
say(f"<@{body['user']['id']}> clicked the button")
# Start your app
if __name__ == "__main__":
app.start(port=int(os.environ.get("PORT", 3000)))