Skip to content

Commit 6ea1533

Browse files
committed
refactor(config): migrate messenger config to platform-specific tokens
BREAKING CHANGE: Configuration structure updated for multi-platform support Old structure (deprecated): messenger: bot-token: <token> app-token: <token> New structure (required): telegram-bot-token: <token> discord-bot-token: <token> slack-bot-token: <token> slack-app-token: <token> Benefits: - Enables multiple messaging platforms to run simultaneously - Clearer, more intuitive configuration naming - Platform-specific tokens better reflect actual platform APIs - Improved security: tokens only loaded for enabled platforms Migration guide: - Telegram: messenger.bot-token → telegram-bot-token - Discord: Create new discord-bot-token config - Slack: messenger.bot-token → slack-bot-token, messenger.app-token → slack-app-token - Update any scripts using the old config structure Files changed: - config.yaml: Added platform-specific token options - hooks/common.sh: Updated create_openclaw_config() and validate_config() - Documentation: Updated README, FAQ, GETTING_STARTED, and docs/index.html - CI/CD: Updated test.yaml to use new config options
1 parent a61c81f commit 6ea1533

7 files changed

Lines changed: 88 additions & 113 deletions

File tree

.github/workflows/test.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,7 @@ jobs:
194194
--config ai-provider="anthropic" \
195195
--config ai-model="claude-sonnet-3-5" \
196196
--config api-key="test-key" \
197-
--config messenger="telegram" \
198-
--config bot-token="123456:TEST"
197+
--config telegram-bot-token="123456:TEST"
199198
200199
- name: Wait for deployment
201200
run: |

FAQ.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,24 +181,19 @@ This allows access from other machines on your network (without SSH tunnel). **N
181181

182182
**Telegram:**
183183
```bash
184-
juju config openclaw \
185-
messenger="telegram" \
186-
bot-token="YOUR_TELEGRAM_BOT_TOKEN"
184+
juju config openclaw telegram-bot-token="YOUR_TELEGRAM_BOT_TOKEN"
187185
```
188186

189187
**Discord:**
190188
```bash
191-
juju config openclaw \
192-
messenger="discord" \
193-
bot-token="YOUR_DISCORD_BOT_TOKEN"
189+
juju config openclaw discord-bot-token="YOUR_DISCORD_BOT_TOKEN"
194190
```
195191

196192
**Slack:**
197193
```bash
198194
juju config openclaw \
199-
messenger="slack" \
200-
bot-token="xoxb-YOUR-BOT-TOKEN" \
201-
app-token="xapp-YOUR-APP-TOKEN"
195+
slack-bot-token="xoxb-YOUR-BOT-TOKEN" \
196+
slack-app-token="xapp-YOUR-APP-TOKEN"
202197
```
203198

204199
---
@@ -667,9 +662,10 @@ ssh -L 18789:127.0.0.1:18789 ubuntu@<gateway-ip>
667662
| `ai-provider` | (required) | anthropic, openai, google |
668663
| `ai-model` | (required) | Model name for selected provider |
669664
| `api-key` | (required) | API key for AI provider |
670-
| `messenger` | - | telegram, discord, or slack |
671-
| `bot-token` | - | Bot token for messenger |
672-
| `app-token` | - | Slack app token (Slack only) |
665+
| `telegram-bot-token` | - | Telegram bot token from @BotFather |
666+
| `discord-bot-token` | - | Discord bot token |
667+
| `slack-bot-token` | - | Slack bot token (xoxb-...) |
668+
| `slack-app-token` | - | Slack app token (xapp-...) |
673669
| `install-method` | npm | npm, pnpm, bun, or source |
674670
| `version` | latest | OpenClaw version to install |
675671
| `enable-browser-tool` | false | Enable Playwright browser |

GETTING_STARTED.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,10 @@ juju deploy openclaw --config anthropic-api-key="your-key-here"
152152
### Configuration
153153
```bash
154154
# Enable Telegram
155-
juju config openclaw \
156-
enable-telegram=true \
157-
telegram-bot-token="123456:ABC-DEF"
155+
juju config openclaw telegram-bot-token="123456:ABC-DEF"
158156

159157
# Enable Discord
160-
juju config openclaw \
161-
enable-discord=true \
162-
discord-bot-token="YOUR.TOKEN.HERE"
158+
juju config openclaw discord-bot-token="YOUR.TOKEN.HERE"
163159
```
164160

165161
### Accessing Gateway
@@ -210,12 +206,10 @@ juju status openclaw
210206
### Messaging Channels
211207
| Option | Type | Default |
212208
|--------|------|---------|
213-
| `enable-telegram` | boolean | false |
214209
| `telegram-bot-token` | string | - |
215-
| `enable-discord` | boolean | false |
216210
| `discord-bot-token` | string | - |
217-
| `enable-slack` | boolean | false |
218211
| `slack-bot-token` | string | - |
212+
| `slack-app-token` | string | - |
219213

220214
### Security
221215
| Option | Type | Default |

README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,24 +119,28 @@ juju config openclaw \
119119

120120
**Enable Telegram**
121121
```bash
122-
juju config openclaw \
123-
messenger="telegram" \
124-
bot-token="123456:ABC-DEF"
122+
juju config openclaw telegram-bot-token="123456:ABC-DEF"
125123
```
126124

127125
**Enable Discord**
128126
```bash
129-
juju config openclaw \
130-
messenger="discord" \
131-
bot-token="YOUR.DISCORD.TOKEN"
127+
juju config openclaw discord-bot-token="YOUR.DISCORD.TOKEN"
132128
```
133129

134130
**Enable Slack**
135131
```bash
136132
juju config openclaw \
137-
messenger="slack" \
138-
bot-token="xoxb-xxx" \
139-
app-token="xapp-xxx"
133+
slack-bot-token="xoxb-xxx" \
134+
slack-app-token="xapp-xxx"
135+
```
136+
137+
**Enable Multiple Platforms Simultaneously**
138+
```bash
139+
juju config openclaw \
140+
telegram-bot-token="123456:ABC-DEF" \
141+
discord-bot-token="YOUR.DISCORD.TOKEN" \
142+
slack-bot-token="xoxb-xxx" \
143+
slack-app-token="xapp-xxx"
140144
```
141145

142146
### Security Configuration
@@ -177,9 +181,10 @@ juju config openclaw log-level="debug"
177181
| `ai-provider` | string | - | AI provider: anthropic, openai, google, bedrock, ollama |
178182
| `ai-model` | string | - | AI model name |
179183
| `api-key` | string | - | API key for selected provider |
180-
| `messenger` | string | - | Messaging platform: telegram, discord, slack |
181-
| `bot-token` | string | - | Bot token for selected messenger |
182-
| `app-token` | string | - | Slack app token (required for Slack) |
184+
| `telegram-bot-token` | string | - | Telegram bot token from @BotFather |
185+
| `discord-bot-token` | string | - | Discord bot token |
186+
| `slack-bot-token` | string | - | Slack bot token (xoxb-...) |
187+
| `slack-app-token` | string | - | Slack app token (xapp-...) |
183188
| `dm-policy` | string | pairing | DM policy: pairing, open, closed |
184189
| `sandbox-mode` | string | non-main | Sandbox: all, non-main, none |
185190
| `install-method` | string | npm | Install method: npm, pnpm, bun, source |

config.yaml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,33 @@ options:
3636
For OpenAI: OpenAI API key
3737
For Google: Google Gemini API key
3838
39-
messenger:
39+
telegram-bot-token:
4040
type: string
4141
default: ""
4242
description: |
43-
Messaging platform to enable: 'telegram', 'discord', or 'slack'.
44-
Leave empty to disable messaging channels.
43+
Telegram bot token from @BotFather (e.g., 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11).
44+
Leave empty to disable Telegram messaging.
4545
46-
bot-token:
46+
discord-bot-token:
4747
type: string
4848
default: ""
4949
description: |
50-
Bot token for the selected messenger platform.
51-
For Telegram: Bot token from @BotFather
52-
For Discord: Bot token from Discord Developer Portal
53-
For Slack: Bot token (xoxb-...) from Slack App settings
50+
Discord bot token from Discord Developer Portal.
51+
Leave empty to disable Discord messaging.
5452
55-
app-token:
53+
slack-bot-token:
5654
type: string
5755
default: ""
58-
description: Slack app token (xapp-...) - only required for Slack messenger
56+
description: |
57+
Slack bot token (xoxb-...) from Slack App settings.
58+
Leave empty to disable Slack messaging.
59+
60+
slack-app-token:
61+
type: string
62+
default: ""
63+
description: |
64+
Slack app token (xapp-...) from Slack App settings.
65+
Required when slack-bot-token is configured.
5966
6067
dm-policy:
6168
type: string

docs/index.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ <h1>Juju Charm for<br><span class="gradient-text">OpenClaw</span></h1>
506506
juju config openclaw anthropic-api-key="your-key-here"
507507

508508
# Enable messaging platforms
509-
juju config openclaw enable-telegram=true telegram-bot-token="your-token"</code></pre>
509+
juju config openclaw telegram-bot-token="your-token"</code></pre>
510510
</div>
511511
</div>
512512
</section>
@@ -603,7 +603,7 @@ <h3>Configure AI Provider</h3>
603603
<div class="step-content">
604604
<h3>Enable Messaging Channels (Optional)</h3>
605605
<p>Connect your preferred messaging platforms</p>
606-
<code>juju config openclaw \<br> enable-telegram=true \<br> telegram-bot-token="123456:ABC-DEF"</code>
606+
<code>juju config openclaw telegram-bot-token="123456:ABC-DEF"</code>
607607
</div>
608608
</div>
609609

@@ -669,20 +669,20 @@ <h3>🌐 Gateway Settings</h3>
669669
<h3>💬 Messaging Platforms</h3>
670670
<dl>
671671
<div class="config-option">
672-
<dt>enable-telegram</dt>
673-
<dd>Enable Telegram channel integration</dd>
672+
<dt>telegram-bot-token</dt>
673+
<dd>Telegram bot token from @BotFather</dd>
674674
</div>
675675
<div class="config-option">
676-
<dt>telegram-bot-token</dt>
677-
<dd>Telegram bot token</dd>
676+
<dt>discord-bot-token</dt>
677+
<dd>Discord bot token from Developer Portal</dd>
678678
</div>
679679
<div class="config-option">
680-
<dt>enable-discord</dt>
681-
<dd>Enable Discord channel integration</dd>
680+
<dt>slack-bot-token</dt>
681+
<dd>Slack bot token (xoxb-...)</dd>
682682
</div>
683683
<div class="config-option">
684-
<dt>enable-slack</dt>
685-
<dd>Enable Slack channel integration</dd>
684+
<dt>slack-app-token</dt>
685+
<dd>Slack app token (xapp-...)</dd>
686686
</div>
687687
</dl>
688688
</div>

hooks/common.sh

Lines changed: 32 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -133,46 +133,36 @@ generate_config() {
133133
"channels": {
134134
EOF
135135

136-
# Add messenger config based on selected platform
137-
local messenger
138-
messenger="$(config-get messenger)"
139-
140-
if [ -n "$messenger" ]; then
141-
local bot_token
142-
bot_token="$(config-get bot-token)"
143-
144-
case "$messenger" in
145-
telegram)
146-
if [ -n "$bot_token" ]; then
147-
cat >> "$config_file" <<EOF
136+
# Add platform-specific messenger configs
137+
local telegram_bot_token discord_bot_token slack_bot_token slack_app_token
138+
telegram_bot_token="$(config-get telegram-bot-token)"
139+
discord_bot_token="$(config-get discord-bot-token)"
140+
slack_bot_token="$(config-get slack-bot-token)"
141+
slack_app_token="$(config-get slack-app-token)"
142+
143+
if [ -n "$telegram_bot_token" ]; then
144+
cat >> "$config_file" <<EOF
148145
"telegram": {
149-
"botToken": "${bot_token}"
146+
"botToken": "${telegram_bot_token}"
150147
},
151148
EOF
152-
fi
153-
;;
154-
discord)
155-
if [ -n "$bot_token" ]; then
156-
cat >> "$config_file" <<EOF
149+
fi
150+
151+
if [ -n "$discord_bot_token" ]; then
152+
cat >> "$config_file" <<EOF
157153
"discord": {
158-
"token": "${bot_token}"
154+
"token": "${discord_bot_token}"
159155
},
160156
EOF
161-
fi
162-
;;
163-
slack)
164-
local app_token
165-
app_token="$(config-get app-token)"
166-
if [ -n "$bot_token" ] && [ -n "$app_token" ]; then
167-
cat >> "$config_file" <<EOF
157+
fi
158+
159+
if [ -n "$slack_bot_token" ] && [ -n "$slack_app_token" ]; then
160+
cat >> "$config_file" <<EOF
168161
"slack": {
169-
"botToken": "${bot_token}",
170-
"appToken": "${app_token}"
162+
"botToken": "${slack_bot_token}",
163+
"appToken": "${slack_app_token}"
171164
},
172165
EOF
173-
fi
174-
;;
175-
esac
176166
fi
177167

178168
# Close channels object (remove trailing comma if exists)
@@ -389,34 +379,18 @@ validate_config() {
389379
errors=$((errors + 1))
390380
fi
391381

392-
local messenger
393-
messenger="$(config-get messenger)"
382+
local slack_bot_token slack_app_token
383+
slack_bot_token="$(config-get slack-bot-token)"
384+
slack_app_token="$(config-get slack-app-token)"
394385

395-
if [ -n "$messenger" ]; then
396-
case "$messenger" in
397-
telegram|discord)
398-
if [ -z "$(config-get bot-token)" ]; then
399-
log_error "$messenger messenger selected but no bot-token configured"
400-
errors=$((errors + 1))
401-
fi
402-
;;
403-
slack)
404-
if [ -z "$(config-get bot-token)" ]; then
405-
log_error "Slack messenger selected but no bot-token configured"
406-
errors=$((errors + 1))
407-
fi
408-
if [ -z "$(config-get app-token)" ]; then
409-
log_error "Slack messenger selected but no app-token configured"
410-
errors=$((errors + 1))
411-
fi
412-
;;
413-
*)
414-
if [ "$messenger" != "" ]; then
415-
log_error "Invalid messenger value: $messenger (valid: telegram, discord, slack)"
416-
errors=$((errors + 1))
417-
fi
418-
;;
419-
esac
386+
if [ -n "$slack_bot_token" ] && [ -z "$slack_app_token" ]; then
387+
log_error "Slack bot-token configured but app-token is missing"
388+
errors=$((errors + 1))
389+
fi
390+
391+
if [ -z "$slack_bot_token" ] && [ -n "$slack_app_token" ]; then
392+
log_error "Slack app-token configured but bot-token is missing"
393+
errors=$((errors + 1))
420394
fi
421395

422396
return $errors

0 commit comments

Comments
 (0)