Telegram Notifications
This guide will help you configure automatic notifications from the TakeProfit platform to Telegram using your own bot and Webhook. This allows you to receive timely alerts directly in the messenger, enhancing your workflow efficiency.
Creating a Telegram Bot
Begin by creating your own Telegram bot, which will send you messages.
Obtaining the API Token
- Open Telegram and search for @BotFather.
- Create a new bot:
- Send the command
/newbot
. - Follow the instructions to set your bot’s name and username.
- Send the command
- Receive the API token:
- After creation, BotFather will send you an API token. Example:
123456789:ABCDefGhIJKlmNoPQRsTUVwxyZ
. - Save this token securely; you’ll need it for further setup.
- After creation, BotFather will send you an API token. Example:
Obtaining the Chat ID
To send messages, you need the chat identifier (chat_id
) where the bot will send notifications.
For Personal Messages
- Start a conversation with your bot:
- Open a chat with your bot and send
/start
.
- Open a chat with your bot and send
- Get your
User ID
:- Search for @userinfobot.
- Send any message to it.
- It will reply with your
User ID
and other information.
For Group Chats
- Create or use an existing group.
- Add your bot to the group.
- Obtain the group’s
Chat ID
:- Add @userinfobot to the same group.
- Send a message in the group.
- @userinfobot will provide the group’s
Chat ID
.
Important: Ensure your bot has the necessary permissions in the group to send messages.
Configuring Webhook in TakeProfit
Setting up a Webhook allows the TakeProfit platform to send notifications to your bot.
Preparing the Webhook URL
Create the URL for the Telegram API:
- Replace
<YOUR_BOT_TOKEN>
with the token from step 1.
Example:
Setting Up Webhook in the Platform
- Log in to your TakeProfit account.
- Create a new alert or edit an existing one.
- Set up alert conditions:
- Specify parameters like ticker, exchange, trigger condition, etc.
- Add the Webhook:
- In the notifications section, select Webhook URL.
- Paste the Webhook URL you prepared.
- Configure the Payload:
- In the Message field, enter JSON with
chat_id
andtext
parameters.
- In the Message field, enter JSON with
Example Payload:
- Replace
YOUR_CHAT_ID
with yourUser ID
or groupChat ID
. - Replace
YOUR_MESSAGE
with your notification text or use TakeProfit variables.
Forming a Message Using Variables
Using TakeProfit Variables
TakeProfit allows the use of variables for dynamic message content.
Common variables:
{{ticker}}
— The instrument’s ticker.{{exchange}}
— Exchange name.{{condition_type}}
— Type of trigger condition.{{condition_source_1}}
— Condition source (e.g., price).
Example in the Message field:
When the alert triggers, the variables will be replaced with real-time values.
Configuration Examples
Example 1: Simple Text Message
Details:
- Bot Token:
123456789:ABCDefGhIJKlmNoPQRsTUVwxyZ
- Chat ID:
987654321
- Message:
BTC price exceeded $50,000
Webhook URL:
Payload in the Message field:
Example 2: Sending JSON Data
Objective: Send structured JSON with alert data.
Payload:
Important: Escape quotes inside text
with a backslash (\
).
Example of the final message:
Testing the Configuration
- Create a test alert with the settings you’ve configured.
- Check for the message in your Telegram app.
- If the message doesn’t arrive, double-check your settings and JSON formatting.
- Verify the data, ensuring variables are correctly replaced.
Troubleshooting
- Messages are not delivered:
- Ensure the
chat_id
and bot token are correct. - Confirm the bot isn’t blocked and has access to the chat or group.
- Ensure the
- Formatting errors:
- Use a JSON validator to check the Payload’s correctness.
- Make sure all special characters are properly escaped.
- Variables are not replaced:
- Verify the variables are spelled correctly.
- Ensure the variables are supported by TakeProfit.
Helpful Tips
-
Using Telegram Formatting:
-
Add
"parse_mode": "Markdown"
or"parse_mode": "HTML"
to the Payload for text formatting. -
Example:
-
-
Sending Messages to Multiple Chats:
- Create multiple alerts with different
chat_id
s. - Alternatively, implement distribution within the bot (requires additional programming).
- Create multiple alerts with different
-
Security:
- Never share your bot’s token with anyone.
- Ensure the Webhook URL doesn’t contain sensitive information.
Conclusion
You have now set up integration between TakeProfit and Telegram using your own bot. This enables you to receive instant notifications about important events and respond promptly to market changes.
If you encounter questions or difficulties, refer to the official Telegram Bot API documentation or contact TakeProfit support.
Useful Links:
Note: Always verify the APIs and functions you use are up to date, as they may change over time.
Was this page helpful?