← Back to Plugins
Channels

Telegram Approval Buttons

JairFC By JairFC 👁 906 views ▲ 0 votes

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

GitHub

Install

openclaw plugins install @openclaw-community/telegram-approval-buttons

Configuration Example

{
  "plugins": {
    "entries": {
      "telegram-approval-buttons": {
        "enabled": true,
        "config": {
          "chatId": "123456789"  // Your Telegram user/chat ID
        }
      }
    }
  }
}

README

# telegram-approval-buttons

OpenClaw plugin that adds **inline keyboard buttons** to exec approval messages in Telegram.  
Instead of typing `/approve <id> allow-once`, just tap a button.

## Features

- **One-tap approvals** โ€” โœ… Allow Once ยท ๐Ÿ” Always ยท โŒ Deny
- **Auto-resolve** โ€” edits the message after a decision is made (removes buttons, shows result)
- **Expiry handling** โ€” stale approvals are automatically cleaned up and marked as expired
- **Self-diagnostics** โ€” `/approvalstatus` command checks config, Telegram connectivity, and stats
- **Graceful fallback** โ€” if button delivery fails, the original plain-text message goes through
- **Zero dependencies** โ€” uses only Node.js built-in `fetch`

## 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's Telegram integration converts the `callback_data` 
(`/approve <id> <action>`) into a synthetic text message โ€” no webhook needed.

## Installation

### From extensions directory (local)

```bash
# Copy the plugin into your extensions directory
cp -r telegram-approval-buttons ~/.openclaw/extensions/

# Restart the gateway
openclaw gateway restart
```

### From npm (when published)

```bash
openclaw plugins install @openclaw-community/telegram-approval-buttons
openclaw gateway restart
```

## Configuration

The plugin auto-detects most settings from your existing Telegram channel config.

### Minimal (zero-config if Telegram is already set up)

```jsonc
{
  "plugins": {
    "entries": {
      "telegram-approval-buttons": {
        "enabled": true,
        "config": {
          "chatId": "123456789"  // Your Telegram user/chat ID
        }
      }
    }
  }
}
```

### Full options

```jsonc
{
  "plugins": {
    "entries": {
      "telegram-approval-buttons": {
        "enabled": true,
        "config": {
          // Required: Telegram chat ID for approval messages
          "chatId": "123456789",
          
          // Optional: bot token (auto-detected from channels.telegram.token)
          "botToken": "123:ABC...",
          
          // Optional: minutes before stale approvals are cleaned up (default: 10)
          "staleMins": 10,
          
          // Optional: verbose diagnostic logging (default: false)
          "verbose": false
        }
      }
    }
  }
}
```

### 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`        |

## Commands

| Command            | Description                                  | Auth required |
|--------------------|--------------------------------------------- |---------------|
| `/approvalstatus`  | Show plugin health, config, and pending stats | Yes           |

## Architecture

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

Each module has a **single responsibility** and can be modified independently:

- **telegram-api.ts** โ€” swap transport, add retry logic, or mock for testing
- **approval-parser.ts** โ€” adapt if OpenClaw changes its approval text format
- **message-formatter.ts** โ€” customize the look and feel of messages
- **approval-store.ts** โ€” replace with persistent storage if needed
- **diagnostics.ts** โ€” extend health checks or add auto-repair logic

## Diagnostics

Send `/approvalstatus` in Telegram to get a health report:

```
๐ŸŸข Approval Buttons Status

Config: chatId=โœ“ ยท token=โœ“
Telegram: โœ“ connected (@your_bot)
Pending: 0 ยท Processed: 5
Uptime: 42m
```

## Compatibility

- OpenClaw โ‰ฅ 2026.2.9
- Node.js โ‰ฅ 22 (uses built-in `fetch`)
- Telegram Bot API (no webhook configuration needed)

## License

MIT
channels

Comments

Sign in to leave a comment

Loading comments...