Telegram
Endpoint URL
This API Function Sends Custom Alert Messages to Telegram Users
Local Host : POST http://127.0.0.1:5000/api/v1/telegram/notify
Ngrok Domain : POST https://<your-ngrok-domain>.ngrok-free.app/api/v1/telegram/notify
Custom Domain: POST https://<your-custom-domain>/api/v1/telegram/notifyPrerequisites
Telegram Bot Must Be Running
Start the bot from OpenAlgo Telegram settings
Bot must be active to send alerts
User Must Be Linked
User must have linked their account using
/linkcommand in TelegramUsername in API request must match your OpenAlgo login username (the username you use to login to OpenAlgo app)
This is NOT your Telegram username
Valid API Key
API key must be active and valid
Get API key from OpenAlgo settings
Sample API Request (Basic Notification)
Note: username should be your OpenAlgo login username (e.g., "john_trader"), not your Telegram username (e.g., @johntrader).
Sample API Response (Success)
Sample API Request (With Priority)
Sample API Request (Multi-line Alert)
Parameter Description
apikey
App API key
Mandatory
-
username
OpenAlgo login username (the username used to login to OpenAlgo app, NOT Telegram username)
Mandatory
-
message
Alert message to send
Mandatory
-
priority
Message priority (1-10, higher = more urgent)
Optional
5
Response Parameters
status
API response status (success/error)
string
message
Response message
string
Use Cases
1. Price Alert Notifications
2. Strategy Signal Alerts
3. Risk Management Alerts
4. Market Update Notifications
5. Trade Execution Confirmation
6. Technical Indicator Alerts
Priority Levels
1-3
Low Priority
General updates, market news
4-6
Normal Priority
Trade signals, daily summaries
7-8
High Priority
Price alerts, position updates
9-10
Urgent
Stop loss hits, risk alerts
Note: Priority affects message delivery order but all messages are delivered.
Error Responses
Invalid API Key
User Not Found
Common Cause: Using Telegram username instead of OpenAlgo login username. Use the username you login to OpenAlgo with, not your @telegram_handle.
Missing Parameters
Bot Not Running
Common Error Messages
Invalid or missing API key
API key is incorrect or expired
Check API key in settings
User not found or not linked to Telegram
User hasn't linked account OR using wrong username
Use OpenAlgo login username (not Telegram username). Link account via /link command
Username and message are required
Missing required fields
Provide username and message
Failed to send notification
Bot is not running
Start bot from Telegram settings
Message Formatting
Supported Markdown
Bold:
*text*or**text**Italic:
_text_or__text__Code:
`text`Pre-formatted:
```text```Links:
[text](url)
Emojis
Use standard Unicode emojis in messages:
📈 📉 Charts
💰 💵 Money
✅ ❌ Status
🚨 ⚠️ Alerts
📊 📉 Analytics
🎯 🔔 Notifications
Line Breaks
Use \n for line breaks in JSON strings.
Rate Limiting
Limit: 30 requests per minute per user
Scope: Per API endpoint
Response: 429 status code if limit exceeded
Best Practices
Use Correct Username: Always use your OpenAlgo login username (the one you use to login to OpenAlgo app), NOT your Telegram username (@handle)
Keep Messages Concise: Short, actionable messages work best
Use Emojis Wisely: Emojis improve readability but don't overuse
Set Appropriate Priority: Reserve high priority (9-10) for urgent alerts only
Format for Readability: Use line breaks and sections for multi-line messages
Test First: Send test messages before automating
Handle Errors: Implement error handling for failed notifications
Username Match: Ensure username matches exactly (case-sensitive)
Bot Status: Check bot is running before bulk notifications
Integration Examples
Python Example
JavaScript Example
cURL Example
Workflow Integration
With Trading Strategies
With Price Monitoring
With Risk Management
Features
Custom Messages: Send any text-based alert
Priority System: Control message importance (1-10)
Rich Formatting: Support for emojis, markdown, line breaks
User-Specific: Target specific users by username
High Reliability: Messages queued if delivery fails
Rate Limited: Prevents spam and abuse
Secure: API key authentication required
Troubleshooting
Alert Not Received
Check Bot Status: Ensure bot is running in OpenAlgo settings
Verify Username: Confirm username matches linked account (case-sensitive)
Check Linking: User must have linked account via
/linkcommandReview Logs: Check OpenAlgo logs for error messages
Test Connection: Use
/statuscommand in Telegram bot
Delivery Delays
Rate Limiting: Check if rate limit exceeded (30/min)
Bot Load: High message volume may cause slight delays
Network Issues: Check internet connectivity
Telegram API: Telegram may have temporary issues
Formatting Issues
Escape Characters: Use proper JSON escaping for special characters
Line Breaks: Use
\nnot actual line breaks in JSONMarkdown: Check markdown syntax is correct
Message Length: Keep messages under 4096 characters (Telegram limit)
Security Considerations
API Key Protection: Never expose API keys in client-side code
Username Privacy: Usernames are case-sensitive and private
Message Content: Don't send sensitive data in plain text
Rate Limiting: Prevents abuse and spam
Authentication: Every request must include valid API key
Limitations
Maximum message length: 4096 characters (Telegram limit)
Rate limit: 30 messages per minute per user
Bot must be running to send messages
User must be linked to receive messages
Messages are queued but not guaranteed during bot downtime
Support
For issues or questions:
Check bot status in OpenAlgo Telegram settings
Verify user is linked via
/statuscommand in TelegramReview API response for specific error messages
Check OpenAlgo logs for detailed error information
Last updated
Was this helpful?