A Telegram bot that forwards messages to Slack and manages support tickets via Zendesk.
- Team Workflow: Forward messages from any Telegram chat to Slack, with reaction-based acknowledgment alerts
- Support Workflow: Users can create and interact with Zendesk support tickets directly in Telegram
The application runs two separate Node.js processes:
- Bot Process: Handles Telegram interactions and message forwarding
- Webhook Process: Handles the web server for test endpoints and manual acknowledgments
- Reaction-Based Acknowledgment: Uses polling to detect reactions on Slack messages for acknowledgments
State is shared between processes through file-based persistence.
- Node.js v16+
- npm/yarn
- Telegram Bot Token
- Slack workspace with API access
- Zendesk account
-
Message @BotFather on Telegram
-
Send
/newbot -
Follow prompts to create a bot
-
Save the API token
-
Set commands (optional):
/setcommands→ select your bot → paste:start - Start using the support bot help - Get help with using the bot menu - Show the main menu ticket - Create a new support ticket status - Check ticket status
- Go to Slack API Dashboard
- Click "Create New App" → "From scratch"
- Name your app and select your workspace
- Under "OAuth & Permissions" → "Scopes" → add Bot Token Scopes:
chat:write- Send messageschannels:read- View channel infochat:write.public- Send to public channelsgroups:read- View private channelsim:read- View direct messagesmpim:read- View group DMsreactions:read- View emoji reactionsusers:read- View user info
- Install the app to your workspace
- Copy the "Bot User OAuth Token" (starts with
xoxb-) - Under "Basic Information" → copy the "Signing Secret"
- Under "Socket Mode" → ensure it's OFF (we're using HTTP endpoints)
- Invite the bot to your designated channel with
/invite @YourBotName
- Go to Admin Center → Apps and Integrations → APIs → Zendesk API
- Create an API token
- Note your admin email and token
-
Clone the repository:
git clone https://github.com/yourusername/teledesk.git cd teledesk -
Install dependencies:
yarn install
-
Create
.envfile using the example:cp .env.example .env
-
Edit the
.envfile with your credentials:# Telegram Configuration TELEGRAM_BOT_TOKEN=your_telegram_token # Slack Configuration SLACK_CHANNEL_ID=your_slack_channel_id SLACK_API_TOKEN=xoxb-your_slack_api_token SLACK_SIGNING_SECRET=your_slack_signing_secret SLACK_WEBHOOK_SERVER=http://your-domain:3030/slack/interactions # Zendesk Configuration ZENDESK_API_URL=https://yourdomain.zendesk.com/api/v2 ZENDESK_EMAIL=your_admin_email@example.com ZENDESK_API_TOKEN=your_zendesk_token # Application Configuration DEPLOY_ENV=development # Options: development, production PORT=3030 LOG_LEVEL=INFO # Options: ERROR, WARN, INFO, DEBUG, TRACE
-
Configure team members in
config.js:- Add Telegram user IDs to the
TEAM_MEMBERSset
- Add Telegram user IDs to the
-
Create the data directory for state persistence:
mkdir -p data chmod 755 data
Start both the bot and webhook server:
# Start both processes concurrently
yarn dev# Start in production mode with PM2
yarn prod
# Or using the startup script (recommended)
./startup.shPM2 configuration is provided in ecosystem.config.cjs:
# Install PM2 globally if needed
yarn global add pm2
# Start with PM2
pm2 start ecosystem.config.cjs
# Set to auto-start on reboot
pm2 startup
sudo env PATH=$PATH:/usr/bin pm2 startup systemd -u $USER --hp $HOME
pm2 save
# Monitor logs
pm2 logs# Validate configuration
yarn validate
# Test Slack integration
yarn test:slack
# Test webhook server
yarn test:webhook
# Test reactions acknowledgment system
yarn test:reactions
# Diagnose Slack issues
yarn diag:slack
# Diagnose webhook issues
yarn diag:webhookThe reaction-based acknowledgment system can be tested using the provided script:
yarn test:reactionsThis interactive tool lets you:
- Create test messages in Slack with pendingAcks entries
- Add reactions to existing messages
- Check reactions on existing messages
- List all pending acknowledgments
The webhook server provides several useful endpoints:
-
Health Check: Check server status
http://your-host:3030/health
-
Debug Pending Acks: View pending acknowledgments
http://your-host:3030/debug-acks
-
Manual Acknowledgment: Send a test acknowledgment
POST http://your-host:3030/test-acknowledge Body: { "chatId": "123456789", "userName": "Test User" }
# View latest logs
yarn logs
# Or directly from logs directory
tail -f logs/$(date +%Y-%m-%d).logIf you get 409: Conflict: terminated by other getUpdates request:
# Clear webhooks
yarn clear-webhook
# Or directly run
node clear-webhook.jsIf the server won't start due to port conflicts:
# Check what's using port 3030
lsof -i :3030
# Kill the process
kill -15 <PID>If processes won't stop:
# Force stop PM2 processes
pm2 delete telegram-bot slack-webhook
# Find and kill any stray processes
pgrep -f "node.*bot.js"
pgrep -f "node.*slackWebhook.js"
kill -9 <PID>bot.js- Main Telegram bot entry pointmodules/logger.js- Logging utilitiesmessageHandlers.js- Telegram message handlingmenus.js- Telegram menu interfacesslackIntegration.js- Slack messaging utilitiesslackPolling.js- Reaction-based acknowledgment systemslackWebhook.js- Webhook serverstate.js- Shared state managementzendeskIntegration.js- Zendesk ticket handling
config.js- Configuration and team member listecosystem.config.cjs- PM2 configurationdata/- State persistence directorylogs/- Application logstests/- Diagnostic tools
- Forward a message from any chat to the bot
- Provide context about the source if needed
- Message appears in Slack with instructions to add a reaction for acknowledgment
- When a team member adds a reaction (like 👍 or ✅), the Telegram user receives confirmation
- Users message the bot directly
- First message creates a Zendesk ticket
- Follow-up messages add comments to the ticket
- New tickets generate Slack notifications with Zendesk link
MIT