Skip to content

Commit 8a0a3de

Browse files
committed
Add Socket Mode in README
1 parent 97a55d8 commit 8a0a3de

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,39 @@ python app.py
4949
ngrok http 3000
5050
```
5151

52+
## Running a Socket Mode app
53+
54+
If you use [Socket Mode](https://api.slack.com/socket-mode) for running your app, `SocketModeHandler` is available for it.
55+
56+
```python
57+
import os
58+
from slack_bolt import App
59+
from slack_bolt.adapter.socket_mode import SocketModeHandler
60+
61+
# Install the Slack app and get xoxb- token in advance
62+
app = App(token=os.environ["SLACK_BOT_TOKEN"])
63+
64+
# Add functionality here
65+
66+
if __name__ == "__main__":
67+
# Create an app-level token with connections:write scope
68+
handler = SocketModeHandler(app, os.environ["SLACK_APP_TOKEN"])
69+
handler.start()
70+
```
71+
72+
Run the app this way:
73+
74+
```bash
75+
export SLACK_APP_TOKEN=xapp-***
76+
export SLACK_BOT_TOKEN=xoxb-***
77+
python app.py
78+
79+
# SLACK_SIGNING_SECRET is not required
80+
# Running ngrok is not required
81+
```
82+
5283
## Listening for events
84+
5385
Apps typically react to a collection of incoming events, which can correspond to [Events API events](https://api.slack.com/events-api), [actions](https://api.slack.com/interactivity/components), [shortcuts](https://api.slack.com/interactivity/shortcuts), [slash commands](https://api.slack.com/interactivity/slash-commands) or [options requests](https://api.slack.com/reference/block-kit/block-elements#external_select). For each type of
5486
request, there's a method to build a listener function.
5587

0 commit comments

Comments
 (0)