or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

app-configuration.mdcontext-and-utilities.mdevent-listeners.mdframework-integration.mdindex.mdoauth-and-installation.md

app-configuration.mddocs/

0

# App Configuration & Setup

1

2

Core application setup patterns for Slack Bolt, covering both single-workspace and multi-workspace configurations, OAuth flows, Socket Mode, and essential middleware configuration options.

3

4

## Capabilities

5

6

### Basic App Initialization

7

8

Create a basic Bolt app for single-workspace development with hardcoded tokens.

9

10

```python { .api }

11

class App:

12

def __init__(

13

self,

14

*,

15

logger=None,

16

name: str = None,

17

process_before_response: bool = False,

18

raise_error_for_unhandled_request: bool = False,

19

signing_secret: str = None,

20

token: str = None,

21

token_verification_enabled: bool = True,

22

client=None,

23

before_authorize=None,

24

authorize=None,

25

user_facing_authorize_error_message: str = None,

26

installation_store=None,

27

installation_store_bot_only: bool = True,

28

request_verification_enabled: bool = True,

29

ignoring_self_events_enabled: bool = True,

30

ignoring_self_assistant_message_events_enabled: bool = True,

31

ssl_check_enabled: bool = True,

32

url_verification_enabled: bool = True,

33

attaching_function_token_enabled: bool = True,

34

oauth_settings: OAuthSettings = None,

35

oauth_flow: OAuthFlow = None,

36

verification_token: str = None,

37

listener_executor=None,

38

assistant_thread_context_store=None

39

):

40

"""

41

Initialize a Bolt app instance.

42

43

Args:

44

token (str): Bot user OAuth access token (xoxb-...) or user token (xoxp-...)

45

signing_secret (str): Slack app signing secret for request verification

46

logger: Custom logger instance

47

name (str): App name for identification

48

process_before_response (bool): Enable FaaS mode for serverless deployment

49

raise_error_for_unhandled_request (bool): Whether to raise error for unmatched requests

50

client: Custom Slack WebClient instance

51

oauth_settings (OAuthSettings): OAuth configuration for multi-workspace apps

52

installation_store: Custom installation data store

53

assistant_thread_context_store: Store for AI assistant thread contexts

54

"""

55

```

56

57

### AsyncApp for Asynchronous Applications

58

59

Asynchronous version of the main App class for high-performance applications.

60

61

```python { .api }

62

class AsyncApp:

63

def __init__(self, **kwargs):

64

"""

65

Initialize an async Bolt app instance.

66

67

Args:

68

Same parameters as App class

69

"""

70

```

71

72

### Built-in HTTP Server

73

74

Start the app with Bolt's built-in HTTP server for development and simple deployments.

75

76

```python { .api }

77

def start(

78

self,

79

port: int = 3000,

80

path: str = "/slack/events",

81

host: str = "0.0.0.0"

82

):

83

"""

84

Start the built-in HTTP server.

85

86

Args:

87

port (int): Port number to listen on

88

path (str): URL path for Slack event handling

89

host (str): Host address to bind to

90

"""

91

92

async def start_async(

93

self,

94

port: int = 3000,

95

path: str = "/slack/events",

96

host: str = "0.0.0.0"

97

):

98

"""Async version of start() method."""

99

```

100

101

### Environment Variables

102

103

Common environment variable patterns for configuration:

104

105

```python

106

import os

107

from slack_bolt import App

108

109

app = App(

110

token=os.environ.get("SLACK_BOT_TOKEN"),

111

signing_secret=os.environ.get("SLACK_SIGNING_SECRET")

112

)

113

```

114

115

### FaaS Mode Configuration

116

117

Configure for serverless/FaaS deployment (AWS Lambda, Google Cloud Functions):

118

119

```python

120

app = App(

121

token=os.environ.get("SLACK_BOT_TOKEN"),

122

signing_secret=os.environ.get("SLACK_SIGNING_SECRET"),

123

process_before_response=True # Enable FaaS mode

124

)

125

```

126

127

### Custom WebClient Configuration

128

129

Use a custom Slack WebClient with specific configuration:

130

131

```python

132

from slack_sdk import WebClient

133

from slack_bolt import App

134

135

client = WebClient(

136

token=os.environ.get("SLACK_BOT_TOKEN"),

137

timeout=30,

138

retry_handlers=[RateLimitErrorRetryHandler(max_retry_count=2)]

139

)

140

141

app = App(

142

client=client,

143

signing_secret=os.environ.get("SLACK_SIGNING_SECRET")

144

)

145

```

146

147

### Middleware Configuration

148

149

Control built-in middleware behavior:

150

151

```python

152

app = App(

153

token=os.environ.get("SLACK_BOT_TOKEN"),

154

signing_secret=os.environ.get("SLACK_SIGNING_SECRET"),

155

# Middleware configuration

156

request_verification_enabled=True, # Verify request signatures

157

ignoring_self_events_enabled=True, # Ignore bot's own events

158

ssl_check_enabled=True, # Verify SSL certificates

159

token_verification_enabled=True # Verify token authenticity

160

)

161

```

162

163

### Socket Mode Configuration

164

165

Configure Socket Mode for development and certain deployment scenarios:

166

167

```python

168

from slack_bolt import App

169

from slack_bolt.adapter.socket_mode import SocketModeHandler

170

171

app = App(

172

token=os.environ.get("SLACK_BOT_TOKEN"),

173

signing_secret=os.environ.get("SLACK_SIGNING_SECRET")

174

)

175

176

# Add event listeners...

177

178

if __name__ == "__main__":

179

handler = SocketModeHandler(

180

app=app,

181

app_token=os.environ.get("SLACK_APP_TOKEN") # xapp-... token

182

)

183

handler.start()

184

```

185

186

### Multi-Workspace OAuth Configuration

187

188

Setup OAuth flow for multi-workspace app installation:

189

190

```python

191

from slack_bolt import App

192

from slack_bolt.oauth import OAuthSettings

193

194

oauth_settings = OAuthSettings(

195

client_id=os.environ.get("SLACK_CLIENT_ID"),

196

client_secret=os.environ.get("SLACK_CLIENT_SECRET"),

197

scopes=["chat:write", "commands", "app_mentions:read"],

198

install_path="/slack/install",

199

redirect_uri_path="/slack/oauth_redirect",

200

success_url="https://your-domain.com/success",

201

failure_url="https://your-domain.com/failure"

202

)

203

204

app = App(

205

signing_secret=os.environ.get("SLACK_SIGNING_SECRET"),

206

oauth_settings=oauth_settings

207

)

208

```

209

210

### Custom Authorization

211

212

Implement custom authorization logic:

213

214

```python

215

def custom_authorize(enterprise_id, team_id, user_id, logger):

216

# Custom authorization logic

217

# Return AuthorizeResult or None

218

return AuthorizeResult(

219

enterprise_id=enterprise_id,

220

team_id=team_id,

221

user_id=user_id,

222

bot_token="xoxb-...",

223

bot_user_id="U123456789"

224

)

225

226

app = App(

227

signing_secret=os.environ.get("SLACK_SIGNING_SECRET"),

228

authorize=custom_authorize

229

)

230

```

231

232

### Installation Store Configuration

233

234

Use custom installation store for multi-workspace apps:

235

236

```python

237

from slack_bolt.oauth.oauth_settings import OAuthSettings

238

from slack_bolt.oauth.installation_store import FileInstallationStore

239

240

# File-based installation store

241

installation_store = FileInstallationStore(base_dir="./data/installations")

242

243

oauth_settings = OAuthSettings(

244

client_id=os.environ.get("SLACK_CLIENT_ID"),

245

client_secret=os.environ.get("SLACK_CLIENT_SECRET"),

246

scopes=["chat:write", "commands"],

247

)

248

249

app = App(

250

signing_secret=os.environ.get("SLACK_SIGNING_SECRET"),

251

oauth_settings=oauth_settings,

252

installation_store=installation_store

253

)

254

```

255

256

### AI Assistant Configuration

257

258

Configure AI assistant features with thread context management:

259

260

```python

261

from slack_bolt import App

262

from slack_bolt.context.assistant.thread_context_store import FileAssistantThreadContextStore

263

264

thread_context_store = FileAssistantThreadContextStore(

265

base_dir="./data/assistant_contexts"

266

)

267

268

app = App(

269

token=os.environ.get("SLACK_BOT_TOKEN"),

270

signing_secret=os.environ.get("SLACK_SIGNING_SECRET"),

271

assistant_thread_context_store=thread_context_store

272

)

273

```

274

275

### Logging Configuration

276

277

Setup custom logging for debugging and monitoring:

278

279

```python

280

import logging

281

from slack_bolt import App

282

283

# Configure logging

284

logging.basicConfig(level=logging.DEBUG)

285

logger = logging.getLogger(__name__)

286

287

app = App(

288

token=os.environ.get("SLACK_BOT_TOKEN"),

289

signing_secret=os.environ.get("SLACK_SIGNING_SECRET"),

290

logger=logger

291

)

292

```

293

294

## Usage Examples

295

296

### Development Setup

297

298

Simple development configuration with Socket Mode:

299

300

```python

301

import os

302

from slack_bolt import App

303

from slack_bolt.adapter.socket_mode import SocketModeHandler

304

305

app = App(

306

token=os.environ["SLACK_BOT_TOKEN"],

307

signing_secret=os.environ["SLACK_SIGNING_SECRET"]

308

)

309

310

@app.message("hello")

311

def say_hello(message, say):

312

say(f"Hi <@{message['user']}>!")

313

314

if __name__ == "__main__":

315

handler = SocketModeHandler(app, os.environ["SLACK_APP_TOKEN"])

316

handler.start()

317

```

318

319

### Production Multi-Workspace Setup

320

321

Production-ready OAuth configuration with database storage:

322

323

```python

324

import os

325

from slack_bolt import App

326

from slack_bolt.oauth import OAuthSettings

327

from your_app.stores import DatabaseInstallationStore

328

329

oauth_settings = OAuthSettings(

330

client_id=os.environ["SLACK_CLIENT_ID"],

331

client_secret=os.environ["SLACK_CLIENT_SECRET"],

332

scopes=["chat:write", "commands", "app_mentions:read"],

333

install_path="/slack/install",

334

redirect_uri_path="/slack/oauth_redirect"

335

)

336

337

app = App(

338

signing_secret=os.environ["SLACK_SIGNING_SECRET"],

339

oauth_settings=oauth_settings,

340

installation_store=DatabaseInstallationStore(),

341

process_before_response=True # For serverless deployment

342

)

343

344

# Add your event listeners here...

345

```

346

347

## Related Topics

348

349

- [OAuth & Multi-Workspace Installation](./oauth-and-installation.md) - Detailed OAuth flow configuration

350

- [Web Framework Integration](./framework-integration.md) - Integration with FastAPI, Flask, Django

351

- [Context Objects & Utilities](./context-and-utilities.md) - BoltContext and utility functions

352

- [Event Listeners & Request Handling](./event-listeners.md) - Setting up event handlers and decorators