An open API service indexing awesome lists of open source software.

https://github.com/JairFC/openclaw-telegram-approval-buttons

OpenClaw plugin: Inline keyboard buttons for exec approval messages in Telegram
https://github.com/JairFC/openclaw-telegram-approval-buttons

approval exec inline-keyboard openclaw openclaw-extension plugin telegram typescript

Last synced: 4 months ago
JSON representation

OpenClaw plugin: Inline keyboard buttons for exec approval messages in Telegram

Awesome Lists containing this project

README

          

--Closed #30695.

# ๐Ÿ” Approval Buttons for OpenClaw

> One-tap `exec` approvals in **Telegram** and **Slack** โ€” no more typing `/approve allow-once`.

## What does this look like?


Plugin workflow: approval request โ†’ allowed โ†’ health check

## What does this do?

OpenClaw's Discord has built-in approval buttons. **Telegram and Slack don't** โ€” you're stuck typing long `/approve` commands. This plugin fixes that for both.

**Features:**
- โœ… **One-tap approvals** โ€” Allow Once ยท ๐Ÿ” Always ยท โŒ Deny
- ๐Ÿ’ฌ **Multi-channel** โ€” works on Telegram (inline keyboard) and Slack (Block Kit buttons)
- ๐Ÿ”„ **Auto-resolve** โ€” edits the message after decision (removes buttons, shows result)
- โฐ **Expiry handling** โ€” stale approvals auto-cleaned and marked as expired
- ๐Ÿฉบ **Self-diagnostics** โ€” `/approvalstatus` checks health and stats for both channels
- ๐Ÿ›ก๏ธ **Graceful fallback** โ€” if buttons fail, the original text goes through
- ๐Ÿ“ฆ **Zero dependencies** โ€” uses only Node.js built-in `fetch`

## Quick Start

### Step 1: Install the plugin

```bash
openclaw plugins install telegram-approval-buttons
```

That's it โ€” OpenClaw downloads it from npm and enables it automatically.

Alternative: install from source (for development)

```bash
git clone https://github.com/JairFC/openclaw-telegram-approval-buttons.git
```

Then add the path manually to your `openclaw.json`:

```jsonc
{
"plugins": {
"load": {
"paths": ["/path/to/openclaw-telegram-approval-buttons"]
}
}
}
```

### Step 2: Configure approvals and plugin

Open your `~/.openclaw/openclaw.json` and add two things:

1. **Exec approvals targeting Telegram** โ€” without this, approvals stay as plain text
2. **Plugin config with your bot token and chat ID** โ€” the plugin needs these to send buttons

```jsonc
{
"approvals": {
"exec": {
"enabled": true,
"mode": "targets",
"targets": [
{
"channel": "telegram",
"to": ""
}
]
}
},
"plugins": {
"entries": {
"telegram-approval-buttons": {
"enabled": true,
"config": {
"botToken": "",
"chatId": ""
}
}
}
}
}
```

> ๐Ÿ’ก **Where to find these values:**
> - **Bot token** โ€” the token you got from [@BotFather](https://t.me/BotFather) when creating your bot. It's the same token OpenClaw uses for Telegram.
> - **Chat ID** โ€” your Telegram user ID. Send a message to [@userinfobot](https://t.me/userinfobot) to get it, or check `openclaw logs --follow` after sending a message to your bot.

### Step 3: Restart and verify

```bash
openclaw gateway restart
```

Then send `/approvalstatus` in your Telegram chat. You should see:

```
๐ŸŸข Approval Buttons Status

Telegram: chatId=โœ“ ยท token=โœ“
โœ“ connected (@your_bot)
Slack: not configured

Pending: 0 ยท Processed: 0
Uptime: 1m
```

> โš ๏ธ **If you see `DISABLED โ€” missing config`**, the plugin can't find your bot token or chat ID. Double-check that `botToken` and `chatId` are set in `plugins.entries.telegram-approval-buttons.config` in your `~/.openclaw/openclaw.json`.

**That's it!** Next time the AI triggers an `exec` approval, you'll get inline buttons instead of text.

## Prerequisites

- **OpenClaw โ‰ฅ 2026.2.9** installed and running
- **Node.js โ‰ฅ 20** (uses built-in `fetch`)
- **Telegram configured** in your `openclaw.json` (bot token + `allowFrom`)
- **Exec approvals targeting Telegram** โ€” see Step 2 above

## How it works

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” message_sending โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ OpenClaw โ”‚ โ”€โ”€ approval text โ”€โ”€โ†’ โ”‚ Plugin โ”‚
โ”‚ Gateway โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ cancel original โ”‚ 1. Parse text โ”‚
โ”‚ โ”‚ โ†โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”‚ 2. Send buttons โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ 3. Track pending โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚
Telegram Bot API
โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Telegram Chat โ”‚
โ”‚ โ”‚
โ”‚ ๐Ÿ” Exec Approval โ”‚
โ”‚ [โœ… Allow] [๐Ÿ”] โ”‚
โ”‚ [โŒ Deny] โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

When you tap a button, OpenClaw converts the `callback_data` into a synthetic text message โ€” **no webhook needed**.

## Configuration

The plugin **auto-detects** `botToken` and `chatId` from your Telegram channel config. Most setups need zero extra configuration.

### Config resolution order

| Setting | Priority 1 (explicit) | Priority 2 (shared config) | Priority 3 (env) |
|------------|-----------------------------|------------------------------------|---------------------------|
| `botToken` | `pluginConfig.botToken` | `channels.telegram.token` | `TELEGRAM_BOT_TOKEN` |
| `chatId` | `pluginConfig.chatId` | `channels.telegram.allowFrom[0]` | `TELEGRAM_CHAT_ID` |

### Advanced options

```jsonc
{
"plugins": {
"entries": {
"telegram-approval-buttons": {
"enabled": true,
"config": {
"chatId": "123456789", // Telegram chat ID
"botToken": "123:ABC...", // Telegram bot token
"slackBotToken": "xoxb-...", // Slack bot OAuth token (optional)
"slackChannelId": "C0123456", // Slack channel/DM ID (optional)
"staleMins": 10, // Minutes before stale cleanup (default: 10)
"verbose": false // Diagnostic logging (default: false)
}
}
}
}
}
```

## FAQ

**Q: I installed the plugin but I still get old text approvals.**
A: Most likely your `approvals.exec` section is missing or doesn't target Telegram. Make sure you have `"mode": "targets"` with a target pointing to `"channel": "telegram"` โ€” see Step 2 above. Restart the gateway after changing the config.

**Q: I installed the plugin but no buttons appear at all.**
A: Make sure `tools.exec.ask` is NOT set to `"off"` in your config. If it's `"off"`, there are no approvals to buttonize. Set it to `"on-miss"` or `"always"`.

**Q: How do I find my Telegram Chat ID?**
A: Send `/start` to [@userinfobot](https://t.me/userinfobot) on Telegram โ€” it replies with your ID. Alternatively, check `https://api.telegram.org/bot/getUpdates` after sending a message to your bot.

**Q: Do I need to set up a webhook?**
A: No! OpenClaw's Telegram integration automatically converts button taps into synthetic text messages. No extra setup needed.

**Q: What happens if the plugin fails to send buttons?**
A: The original plain-text approval message goes through normally. The plugin never blocks approvals.

**Q: Does this work in group chats?**
A: Yes, but the bot needs to be an admin or it needs permission to edit its own messages.

## Troubleshooting

| Problem | Fix |
|---------|-----|
| `DISABLED โ€” missing config` in logs | Add `botToken` and `chatId` to `plugins.entries.telegram-approval-buttons.config` in your `~/.openclaw/openclaw.json`. See Step 2. |
| Still getting old text approvals | Your `approvals.exec` config must target Telegram. See Step 2. |
| `/approvalstatus` says "unknown command" | Plugin didn't load. Run `openclaw plugins install telegram-approval-buttons` and restart the gateway. |
| No buttons appear | Check `tools.exec.ask` is not `"off"`. Run `/approvalstatus` to check config. |
| Buttons show but nothing happens | Bot needs message editing permission. Use a private chat or make bot admin. |
| Buttons say "expired" | Approval timed out before you tapped. Adjust `staleMins` if needed. |

## Architecture

```
telegram-approval-buttons/
โ”œโ”€โ”€ index.ts # Entry point โ€” orchestration only
โ”œโ”€โ”€ types.ts # Shared TypeScript interfaces
โ”œโ”€โ”€ lib/
โ”‚ โ”œโ”€โ”€ telegram-api.ts # Telegram Bot API client
โ”‚ โ”œโ”€โ”€ slack-api.ts # Slack Web API client
โ”‚ โ”œโ”€โ”€ approval-parser.ts # Parse OpenClaw approval text format
โ”‚ โ”œโ”€โ”€ message-formatter.ts # HTML formatting for Telegram messages
โ”‚ โ”œโ”€โ”€ slack-formatter.ts # Block Kit formatting for Slack messages
โ”‚ โ”œโ”€โ”€ approval-store.ts # In-memory pending approval tracker
โ”‚ โ””โ”€โ”€ diagnostics.ts # Config resolution, health checks
โ”œโ”€โ”€ openclaw.plugin.json # Plugin manifest
โ””โ”€โ”€ package.json
```

## Contributing

Issues and PRs welcome. Each file in `lib/` is self-contained with a single responsibility.

## Contributors

- [@JairFC](https://github.com/JairFC) โ€” creator and maintainer
- [@sjkey](https://github.com/sjkey) โ€” Slack support and message simplification (v5.0.0)

## License

[MIT](LICENSE)