
What You Can Forward
With this forwarder, you can:- Forward Jotihunt Telegram messages to Discord channels
- Forward messages to WhatsApp (using unofficial WhatsApp Web API)
- Preserve message formatting (bold, links, etc.)
- Handle different types of updates (hints, assignments, news)
Prerequisites
Before you begin, ensure you have:- Node.js installed (version 18.x or higher)
- A Telegram account and API credentials
- Discord bot token and channel ID (optional, for Discord forwarding)
- WhatsApp group name (optional, for WhatsApp forwarding)
Setting Up Your Telegram Forwarder
1
Create a new Node.js project
First, create a new directory and initialize your project:Install the required dependencies:
2
Set up environment variables
Create a
.env
file in your project root. Here’s how to get each required value:Telegram API Credentials:- Visit my.telegram.org/apps
- Log in with your phone number
- Create a new application if you don’t have one
- Copy the
api_id
andapi_hash
values
- Go to the Discord Developer Portal
- Click “New Application” and name it
- Go to the “Bot” section and create a bot
- Copy the bot token
- Enable “Message Content Intent” under Privileged Gateway Intents
- To get the channel ID, enable Developer Mode in Discord (Settings > App Settings > Advanced)
- Right-click the target channel and click “Copy ID”
- Note the exact name of your WhatsApp group (case sensitive)
- You must be a member of the group you want to forward messages to
- Make sure to keep your WhatsApp connected on your phone while using the forwarder
.env
file:.env
Never commit your
.env
file to version control. Make sure to add .env
to your .gitignore
.3
Create the forwarder code
Create a new file called The code includes:
index.js
in your project root and add the following code:index.js
- Telegram message listener
- Discord message forwarding
- WhatsApp Web integration
- Message formatting conversion
- Graceful shutdown handling
Running the Forwarder
To run your forwarder:- Make sure your environment variables are set in
.env
- Run the application:
- On first run:
- If
TELEGRAM_STRING_SESSION
is empty, you’ll get a session string to add to.env
- For WhatsApp, scan the QR code that appears in the terminal
- If
- The forwarder will now forward messages from the specified Telegram chat to Discord and WhatsApp
The WhatsApp Web API is unofficial and may break with WhatsApp updates. For production use, consider using the official WhatsApp Business API instead.
Handling Different Message Types
The Jotihunt bot sends different types of messages. Here’s how to handle them:Advanced Configuration
Here are some additional configuration options you might want to add:Message Filtering
Add filters to only forward specific types of messages
Multiple Channels
Forward different message types to different channels
Error Handling
Add robust error handling and automatic reconnection
Message Queue
Implement a message queue for reliable delivery
Best Practices
- Error Handling: Implement proper error handling for all API calls
- Rate Limiting: Respect platform-specific rate limits
- Logging: Add comprehensive logging for debugging
- Message Queue: Consider using a message queue for reliability
- Monitoring: Set up monitoring for the forwarder service
- Testing: Test with different message types and formats
Running as a Service
To run your forwarder continuously, you can use a process manager like PM2:Security Considerations
When implementing the forwarder, keep these security considerations in mind:- API Credentials: Keep all API tokens secure
- Message Validation: Validate messages before forwarding
- Access Control: Limit which messages get forwarded
- Logging: Don’t log sensitive information
- Updates: Keep dependencies updated
Troubleshooting
Common issues and solutions:Connection Issues
Connection Issues
If the forwarder disconnects frequently:
- Check your internet connection
- Implement automatic reconnection
- Add connection status logging
Message Format Problems
Message Format Problems
If messages aren’t formatting correctly:
- Check the message parsing logic
- Log raw messages for debugging
- Test with different message types
WhatsApp Authentication
WhatsApp Authentication
If WhatsApp Web authentication fails:
- Clear your WhatsApp Web sessions
- Regenerate the QR code
- Check for WhatsApp Web API updates
Conclusion
By implementing this Telegram forwarder, you can ensure your team stays updated on Jotihunt events through their preferred communication channels. Remember to monitor the forwarder’s performance and handle errors appropriately.Credits and Inspiration
This tutorial is inspired by the jotihunt-telegram-forwarder project by ScoutingScherpenzeel, which provides a Python implementation of similar functionality. This Node.js version offers an alternative approach while maintaining the same core functionality.Need Help?
If you have questions about the Jotihunt API or need assistance, contact the Jotihunt organization.