Bridge common messengers (Telegram, WhatsApp, Slack, Discord) into pi.
Remote users can interact with your pi coding agent via their messenger app.
pi-messenger-bridge.mp4
- 🔐 Challenge-based authentication (6-digit codes)
- 📱 Multi-messenger support (Telegram, WhatsApp, Slack, Discord)
- 🎯 Event-driven architecture (no polling loops)
- 🔒 Trusted user management with transport-namespaced IDs
- 📊 Live status widget (toggleable)
- 💾 Persistent config (auth state, auto-connect, widget preference)
- 🔧 Tool call visibility for remote users
- 📝 Multi-turn conversation support
- 🔑 Secure permissions (chmod 600 for config files, 700 for directories)
- 🐛 Debug mode for troubleshooting
pi install npm:pi-messenger-bridgeCreate a bot via @BotFather and get your token.
/msg-bridge configure telegram <bot-token>Or set via environment variable:
export PI_TELEGRAM_TOKEN="your-bot-token-here"Configure WhatsApp (requires QR code scan):
/msg-bridge configure whatsappScan the QR code with WhatsApp mobile app (Linked Devices).
Or set custom auth path:
export PI_WHATSAPP_AUTH_PATH="/path/to/whatsapp-auth"Create a Slack app with Socket Mode enabled. You need both tokens:
/msg-bridge configure slack <bot-token> <app-token>Or set via environment variables:
export PI_SLACK_BOT_TOKEN="xoxb-..."
export PI_SLACK_APP_TOKEN="xapp-..."Create a Discord bot in the Developer Portal. Enable "Message Content Intent" in Bot settings.
/msg-bridge configure discord <bot-token>Or set via environment variable:
export PI_DISCORD_TOKEN="your-bot-token"/msg-bridge connectWhen a user messages your bot for the first time, they'll receive a 6-digit challenge code. The code is displayed in your pi terminal. Share it with the user (e.g., via DM).
The user enters the code in the bot chat to become a trusted user.
/msg-bridgeor/msg-bridge help— Show available commands/msg-bridge status— Show connection and user status/msg-bridge connect— Connect to configured messengers/msg-bridge disconnect— Disconnect all transports/msg-bridge configure <platform> <token>— Set transport credentials/msg-bridge widget— Toggle status widget on/off
Config is stored at ~/.pi/msg-bridge.json with secure permissions (chmod 600).
Example config:
{
"telegram": { "token": "..." },
"whatsapp": { "authPath": "..." },
"slack": { "botToken": "...", "appToken": "..." },
"discord": { "token": "..." },
"auth": {
"trustedUsers": ["telegram:123", "whatsapp:456"],
"adminUserId": "telegram:789"
},
"autoConnect": true,
"showWidget": true,
"debug": false
}Environment variables override file config:
PI_TELEGRAM_TOKEN— Telegram bot tokenPI_WHATSAPP_AUTH_PATH— WhatsApp session directory (default:~/.pi/msg-bridge-whatsapp-auth)PI_SLACK_BOT_TOKEN— Slack bot token (xoxb-...)PI_SLACK_APP_TOKEN— Slack app token (xapp-...)PI_DISCORD_TOKEN— Discord bot tokenMSG_BRIDGE_DEBUG— Enable debug logging (true/false)
- Config file:
~/.pi/msg-bridge.json(chmod 600 - owner read/write only) - Config directory:
~/.pi/(chmod 700 - owner only) - WhatsApp auth:
~/.pi/msg-bridge-whatsapp-auth/(chmod 700 - owner only) - Environment variables take precedence over config file
- Challenge-based authentication for all new users
- Transport-namespaced user IDs prevent impersonation
Enable debug mode to see detailed logs:
{
"debug": true
}Or:
export MSG_BRIDGE_DEBUG=trueUses pi's native sendUserMessage() and turn_end events for two-way communication.
No tool-loop hacks needed — this is the pi-native way.
MIT