n8n community node for multiple Telegram bots support
This node solves the main limitation of the standard n8n Telegram node - supporting only one bot token per node. With Telegram Multi, you can use multiple bots in a single workflow with flexible authentication methods.
- 🔒 Multiple Authentication Methods: Encrypted credentials, environment variables, or direct input
- 🤖 Multiple Bot Support: Use different bots for different operations in one workflow
- 🔄 Drop-in Replacement: Compatible with standard Telegram node operations
- 🛡️ Security First: Three levels of security with token validation
- 🚀 Production Ready: Complete error handling, validation, and timeout management
npm install n8n-nodes-telegram-multi
Or install directly in n8n:
- Go to Settings → Community Nodes
- Enter:
n8n-nodes-telegram-multi
- Install and restart n8n
Best for production use with sensitive tokens.
Authentication Method: Encrypted Credentials
Credentials: Select your Telegram Multi API credentials
Perfect for multiple bots and dynamic selection.
Authentication Method: Environment Variable
Environment Token: {{$env.BOT_TOKEN_NEWS}}
Quick testing only - not recommended for production.
Authentication Method: Direct Input
Bot Token: 123456789:ABCdef...
Use different bots for different content categories:
// Function Node - Determine category
const category = $json.title.includes('crypto') ? 'crypto' : 'tech';
return {
botToken: category === 'crypto' ? $env.BOT_TOKEN_CRYPTO : $env.BOT_TOKEN_TECH,
chatId: category === 'crypto' ? '@crypto_news' : '@tech_news',
message: $json.title
};
// Telegram Multi Node
Authentication Method: Environment Variable
Environment Token: {{$json.botToken}}
Resource: Message
Operation: Send
Chat ID: {{$json.chatId}}
Text: {{$json.message}}
Route different alert levels to different bots:
// Function Node - Alert routing
const alertBots = {
'critical': $env.BOT_TOKEN_ALERTS,
'warning': $env.BOT_TOKEN_WARNINGS,
'info': $env.BOT_TOKEN_INFO
};
return {
botToken: alertBots[$json.severity],
chatId: $json.severity === 'critical' ? '@critical_alerts' : '@general_alerts'
};
Different bots for different customers:
// Function Node - Customer routing
const customerBots = {
'customer_a': $env.BOT_TOKEN_CUSTOMER_A,
'customer_b': $env.BOT_TOKEN_CUSTOMER_B,
'customer_c': $env.BOT_TOKEN_CUSTOMER_C
};
return {
botToken: customerBots[$json.customer_id],
chatId: $json.notification_chat
};
- Send: Send text messages with formatting
- Edit: Edit existing messages
- Delete: Delete messages
- Send: Send photos with captions
- Send: Send documents with captions
- Get: Get chat information
- Get Administrators: Get list of chat administrators
All operations support these additional options:
- Parse Mode: HTML, Markdown, or MarkdownV2
- Caption: For photos and documents
- Disable Web Page Preview: Hide link previews
- Disable Notification: Send silently
- Reply to Message ID: Reply to specific message
The node supports multiple chat ID formats:
-
Numeric ID:
123456789
(private chat) -
Negative ID:
-123456789
(group) -
Username:
@channel_name
(public channel/group)
Create a .env
file or set environment variables:
# Multiple bot tokens for different purposes
BOT_TOKEN_NEWS=1234567890:ABCDEF...
BOT_TOKEN_ALERTS=9876543210:GHIJKL...
BOT_TOKEN_CRYPTO=5555555555:MNOPQR...
BOT_TOKEN_MINING=7777777777:STUVWX...
BOT_TOKEN_PERSONAL=3333333333:YZABCD...
The node includes comprehensive security features:
- Token Validation: Ensures proper Telegram bot token format
- Chat ID Validation: Validates numeric IDs and usernames
- Input Sanitization: Prevents XSS and API issues
- Error Handling: Network errors, timeouts, API errors
- Rate Limiting: Built-in Telegram API rate limit support
Approach | Security | Convenience | Flexibility | Recommendation |
---|---|---|---|---|
HTTP Request | 🔒🔒 | ⭐⭐ | ⭐⭐⭐⭐⭐ | For complex cases |
Standard Telegram | 🔒🔒🔒🔒 | ⭐⭐⭐⭐⭐ | ⭐ | For single bot |
Telegram Multi | 🔒🔒🔒🔒 | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | Best choice |
The node provides detailed error messages for common issues:
- Invalid bot token format
- Invalid chat ID format
- Network connectivity issues
- Telegram API errors
- Message length limits
- Rate limiting
Enable "Continue on Fail" in node settings to handle errors gracefully.
Migrating is simple:
- Replace Telegram node with Telegram Multi
- Set Authentication Method to "Encrypted Credentials"
- Select your existing Telegram credentials
- All other settings remain the same
// Function Node - Advanced routing logic
const time = new Date().getHours();
const isWeekend = [0, 6].includes(new Date().getDay());
const priority = $json.priority;
let selectedBot;
if (priority === 'urgent') {
selectedBot = $env.BOT_TOKEN_URGENT;
} else if (isWeekend || time < 8 || time > 18) {
selectedBot = $env.BOT_TOKEN_AFTER_HOURS;
} else {
selectedBot = $env.BOT_TOKEN_BUSINESS;
}
return { botToken: selectedBot };
// Function Node - Message formatting
const status = $json.status;
const emoji = status === 'success' ? '✅' : status === 'error' ? '❌' : '⚠️';
const parseMode = $json.includeHtml ? 'HTML' : 'Markdown';
return {
text: `${emoji} <b>Status:</b> ${status}\n<i>Details:</i> ${$json.details}`,
parse_mode: parseMode
};
"Invalid bot token format"
- Ensure token follows format:
123456789:ABCdef...
- Check for extra spaces or characters
"Chat not found"
- Verify chat ID format (@username or -123456789)
- Ensure bot has access to the chat
"Environment variable not found"
- Check variable spelling:
{{$env.BOT_TOKEN_NAME}}
- Verify environment variable is set
"Request timeout"
- Check network connectivity
- Try reducing message size
- Use Environment Variables for production deployments
- Enable Error Handling with "Continue on Fail"
- Validate Chat IDs before sending messages
- Monitor Rate Limits for high-volume workflows
- Test Thoroughly in development environment first
MIT License - see LICENSE file for details.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
- Issues: GitHub Issues
- Documentation: n8n Community Forum
- Telegram API: Official Documentation
- Initial release
- Multiple authentication methods
- All basic Telegram operations
- Comprehensive error handling
- Full documentation and examples
Made with ❤️ for the n8n community