WordPress Telegram Bot - Use Case - How to Create a Bot on Telegram That Sends Automatic SMS or Email Alerts
Use Case – How to create a bot on Telegram that sends automatic SMS or email alerts.
Note: This guide requires:
- WordPress Telegram Bot – This document uses version 1.0.3
Video Use-Case
Introduction
WordPress Telegram Bot is a WordPress plugin that allows you to send automatic messages, emails and SMS based on Telegram conversations and much more. You can use the WordPress Telegram Bot plugin to automate business workflows involving the messenger app.
Main functionalities:
- Email Repeater – Send messages sent on a Telegram group to one or many emails. Mark words as “stop words” to prevent them from triggering the bot.
- Personal Messages – Mention a user after certain words or expressions are sent to the group together with a message to this user.
- Group Messages – Emit message to all users based on certain conditions in a specific group.
- SMS Repeater – Send a copy of Telegram group conversations to a mobile device.
- SMS Alerts – Send notifications to multiple phone devices whenever certain keywords are used.
- WordPress Repeater – Store all messages from a specific group or several groups in WordPress and output the content using a shortcode.
Use Case Front-End
1. Email Repeater:
![Example of the rule - WordPress Telegram Plugin](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a3f903eb3af44cc1209d96/file-qKMopyslYL.png)
Messages on Telegram:
![Example of the rule - WordPress Telegram Plugin](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a3fd371df47a61c5ad2a33/file-gJ5lpoWO2M.png)
Sent emails:
![Example of the sent email - Telegram Plugin for WordPress](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a3fd86eb3af44cc1209dc2/file-nAq1Fi7vhf.png)
2. SMS Alerts:
![Example of the rule - Telegram Group Bot Manager](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a407a127c86942e8069320/file-wh7kAGoabN.png)
Message on Telegram:
![Result in action - Telegram Bot Plugin for WordPress](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a40880dca0fd46b9356807/file-PgBBjKCSFX.png)
Sent SMS:
![Example of the sent SMS - WordPress Telegram Plugin](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a40c8f1df47a61c5ad2aad/file-uwRb6KnPYS.png)
Use Case Assumptions
In this example we will consider how to create a bot on Telegram and how to teach it to send automatic SMS or email alerts.
Learn more about other types of rules:
Requirements
- The WordPress Telegram Bot plugin will only work on sites with installed SLL certificates (HTTPS).
- You cannot use the same access token (bot API) on different sites.
- The bot may not perform properly with supergroups.
It follows:
- Installing the plugin
- Creating a Telegram account
- Creating a bot and connecting it to plugin
- Creating a group and adding the bot as admin
- SMS: connecting plugin to Amazon SNS Service
- Creating rules
- Creating, duplicating and deleting a rule
- Viewing the log - checking performed rules
- End Result
Installing the Plugin
The process is the same for all CM plugins and add-ons.
![CreativeMinds Customer Account Dashboard - Downloads tab](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/5ea2abc604286364bc98ef13/file-FEHseeA7Qu.png)
- Download the plugin from your customer dashboard.
- Log in to WordPress and navigate to the WordPress Admin → Plugins settings.
- Click on Add New.
- Activate it and add the license.
Learn more: Getting Started - Plugin Overview
Creating a Telegram Account
To start working with the plugin, first thing you need to do is to create a Telegram account. The phone number is required. To create an account you can use web browser or application that is supported for different types of devices. You can learn more about it in official documentation.
When the account is created, you need to create a bot.
Creating a Bot and Connecting It to Plugin
Telegram Resources
Official Telegram documentation: How To Create a Bot | @BotFather Commands
This feature depends on Telegram, so steps and interface may change at any time.
If you feel this article is deprecated, please get in touch with us.
In order to create a Telegram Bot, follow these steps:
1) Contact the user @BotFather on Telegram and start a chat.
Either follow the link @BotFather or look for its username.
![Using BotFather for creating a bot - Telegram Plugin for WordPress](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a2a60713fd125a39b4452d/file-dRBNSyJHqZ.png)
2) Write /newbot to @BotFather and choose a friendly bot name. Friendly names can contain spaces. Example: Creative Minds Bot.
![Specifying a friendly bot name - Telegram Group Bot Manager](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a2a61aeb3af44cc120965c/file-5kr3nJhgfW.png)
3) Specify the bot username. This name can't contain spaces and must end with "bot". Example: CmindsBot.
![Specifying a bot username - Telegram Bot Plugin for WordPress](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a2a62613fd125a39b4452f/file-GRVqZgPh9P.png)
Your bot has been created! You will now receive the access token.
You can find it on the @BotFather message logs. Alternatively, message /token @xxx to it, with xxx being the bot name. For example: /token @CmindsBot.
![Copying the API key - WordPress Telegram Plugin](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a2a637dca0fd46b9356020/file-Kdf3q3abmf.png)
4) Copy this token and navigate to the plugin: Admin Dashboard → CM Telegram Bot → Settings → API Settings tab.
![Navigation to the plugin settings - Telegram WordPress Widget](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a295a81df47a61c5ad21f1/file-Fv6TaYLaky.png)
There in the section Telegram API Settings you need to fill the following fields:
![Connecting the created bot with the plugin - Telegram Plugin for WordPress](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a2977d1df47a61c5ad21f7/file-d331LHVcBC.png)
- Bot API Key - Paste here copied token.
Bot Username - Here you need to write bot username without @. In our example it's CmindsBot.
Remember: the username is the one without spaces and ends with bot:
Bot username example - Default sender name - If the bot can't detect the sender's name then he will use this one.
And then click the Save button.
![Saving the changes - Telegram Bot Plugin for WordPress](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a29e65eb3af44cc1209604/file-LGLDw3zwCl.png)
TIP: Edit the Bot
Using the @BotFather you can edit your bot: name, description, about info, profile photo and list of commands. Just follow the instructions by @BotFather.
![BotFather settings - WordPress Telegram Plugin](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a2a692dca0fd46b9356026/file-TFz7RyHxC5.png)
Creating a Group and Adding the Bot as Admin
Note: the following steps are shown in a desktop application, as there's no possibility to set a bot as admin on the web version of Telegram.
The WordPress Telegram Bot plugin requires the bot to be part of one or multiple groups to fetch messages and interact with users.
It can only perform actions if it has admin permissions. So, next step - you need to create a new group (if you haven't done it yet) and add your bot as administrator.
Open the Telegram's menu and click New group.
![Creating new group - Telegram WordPress Widget](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a2a7af27c86942e8068b40/file-mz7KdCmGAy.png)
In the pop-up window you need to write a name for your group and click Next.
![Giving a name to the group - Telegram Plugin for WordPress](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a2a7daeb3af44cc120966c/file-BVtNNhIt4f.png)
On the next step invite new members to the group. Now you need to find your bot, choose it and click Create.
![Creating the group - Telegram Group Bot Manager](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a2a800eb3af44cc120966d/file-LQTE0fs0yW.png)
And the final step: setting the bot as administrator. Navigate to the group settings, click Manage Group → Administrators → Add Administrator. Then choose the bot and click Save and Close.
![Setting up a bot as an admin - Telegram Bot Plugin for WordPress](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a2aa14dca0fd46b9356049/file-lAWv6Uiko1.gif)
SMS: Connecting Plugin to Amazon SNS Service
You need to create an Amazon SNS API and connect it to the plugin via the plugin's settings. It's needed for plugin to be able to send SMS messages.
You can set up Amazon SNS API by following the link and learn more about it in official documentation. You can also check our guide about it: General Support - Enabling SMS Messages (Amazon SNS API)
When you get SNS API Key and Secret, navigate to Admin Dashboard → CM Telegram Bot → Settings → API Settings tab.
![Navigation to the plugin settings - Telegram WordPress Widget](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a295a81df47a61c5ad21f1/file-Fv6TaYLaky.png)
Then fill corresponding fields and click Save:
![Adding Amazon SNS API keys - Telegram Plugin for WordPress](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a40f1813fd125a39b44da6/file-YxfYufdey0.png)
Creating Rules
Now it's time to teach our bot to respond on some definite words or phrases. Rules are the main features of the WordPress Telegram Bot plugin and you can create multiple of them.
Examples:
- Send all messages from a group to an email address of choice, except it they have the word "hey" or "hi"
- If someone writes "help" in a group, send an SMS with contact information to a chosen number
In this use case we will consider sending SMS or Email alerts by the bot on Telegram with the message containing the words or phrases from the rule.
Email Repeater
So, let's start with Email Repeater. This rule sends an email for every group message. To configure it navigate to Admin Dashboard → CM Telegram Bot → Settings → Email Repeater tab.
![Creating an Email Repeater rule - Telegram Group Bot Manager](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a3e4711df47a61c5ad2965/file-YsJ6Lyz3Mp.png)
There you can find the following fields and options:
Telegram group ID - Here you need to write ID of your Telegram group. This field can contain multiple IDs for different groups. Must follow the format "-xxxxxxxx" (the character "-" followed by nine numerals). Note: leaving this field empty will apply the rule to ALL groups, where the bot is set as administrator.
To get ID navigate to Telegram and type /getGroupId in your group.
Note: Telegram bot commands are case-sensitive! As such, /getGroupId will work and /getgroupid will not work.
In respond you will get group ID:
Getting a Group ID - Send to email address - Write here an email address where the message should be sent. Supports only one email per rule.
- Email Sender name - Write here a name that will be displayed as Sender in the sent email.
- Status - Set the rule as active or paused.
- Email title template - Write here a subject of the email. This option supports placeholders.
- Repeater name - The contact name shown as the message sender.
- Stop word/s - The rule will only run if it DOES NOT include ANY of these words.
Email message template - Write here text of the email. This option supports placeholders.
Supported Placeholders:
- {Text} - Telegram message content
- {sender} - Sender username / nickname
- {GroupID} - Telegram group id
- {img} - Image that was included in the Telegram message
- {date} - Telegram message date
Let's fill this form for our example in the following way: Sender name is "CmindsBot". Stop word "goodbye" and phrase "good night". We add sender name to the email title, and to the email message we add sender name, date of the sent message, ID of Telegram group where the message was sent, text of the message and image (if it was sent).
![Example of the created rule - WordPress Telegram Plugin](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a3f903eb3af44cc1209d96/file-qKMopyslYL.png)
And click the Save button.
![Saving the changes - Telegram WordPress Widget](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a29e65eb3af44cc1209604/file-LGLDw3zwCl.png)
Result on the front-end:
Sent messages: first message without image, the second one contains an image, and the last one contains stop-word:
![Front-end result - Telegram Plugin for WordPress](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a3fd371df47a61c5ad2a33/file-gJ5lpoWO2M.png)
In result there were sent only emails with two first messages:
![Example of the sent email - Telegram Group Bot Manager](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a3fd86eb3af44cc1209dc2/file-nAq1Fi7vhf.png)
SMS Alerts
The rule SMS Alerts sends an SMS to one or more mobile phone numbers when a message with specific words are sent in any group the bot is in. To configure it navigate to Admin Dashboard → CM Telegram Bot → Settings → SMS Alerts tab.
![Creating an SMS Alert rule - Telegram Bot Plugin for WordPress](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a4054027c86942e8069311/file-r5z45uc5dn.png)
There you can find the following fields and options:
- Send to phone number/s - List all phone numbers that will receive the message. Include country code, but without the "+" symbol.
- Good example: 17775552368
- Bad example: +17775552368
- Detect phrase/s - The rule will only run if the message DOES include AT LEAST ONE of these words.
- SMS message content - Message to be sent.
- Sender name - Can only contain 11 characters or less. If it has more, the message will not be sent (due a restriction by Amazon). The sender name will appear in the SMS text message send to the phone number.
- Status - Set rule as active or paused.
- Must not include - The rule will only run if the message DOES NOT include ANY of these words.
- Must include - The rule will only run if the message DOES include one of these words.
- Snooze for - Set a number in hours. After the rule is activated, it will "snooze" for X hours before being ready to activate again. Useful to avoid spamming.
- Execute every - Execute the rule after every X times the trigger is activated. For example, if detection is set to 3 the rule will be set on the following 1,4,7.
- Reset Count - Click this button to reset the count to 0.
Let's fill this form for our example in the following way: SMS message must be sent to the phone number when the word "alert" is detected. The message from Telegram group must include the word "urgent" and not include the word "false".
![Example of the created rule - WordPress Telegram Plugin](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a407a127c86942e8069320/file-wh7kAGoabN.png)
And then click the Save button:
![Saving the changes - Telegram WordPress Widget](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a29e65eb3af44cc1209604/file-LGLDw3zwCl.png)
Result on the front-end:
![Front-end result - Telegram Plugin for WordPress](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a40c7a27c86942e806933d/file-RmxbaSsky7.png)
Sent SMS:
![Example of the sent SMS - Telegram Group Bot Manager](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a40c8f1df47a61c5ad2aad/file-uwRb6KnPYS.png)
Creating, Duplicating and Deleting a Rule
Every tab comes with an empty rule.
![Creating, duplicating and deleting a rule - Telegram Bot Plugin for WordPress](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a2c91a1df47a61c5ad23ee/file-bQmiIqTDeN.png)
- Add rule - Create more rules at any time by clicking this button.
- Duplicate rule - You can duplicate rules and edit the copies.
- Delete rule - Delete the rule. Note: be careful, as there is no confirmation for this action.
All changes (including deletion) are only performed after you click the Save button.
Viewing the Log - Checking Performed Rules
You can check all performed actions in the log. It helps you monitor the bot responses and operation and, in case of errors, lets you understand what is the rule that did not work as expected.
Capturing Group ID
The log is also useful for detecting the group ID. Once adding the Bot to a group as an admin, it will start sending the content of that group to the plugin. In such case you can find out what is the group number without using the command line within the group stream.
To see the log navigate to Admin Dashboard → CM Telegram Bot → Log.
![Navigation to the plugin log - WordPress Telegram Plugin](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a2c5d427c86942e8068c80/file-SyWxyrnVRQ.png)
The log shows the information about each action:
- Group ID - This column can be useful to retrieve this number (you can also order this column by ID).
- User Name - You can order this column by user names.
- Message - All group messages are logged, even if they don't trigger any rule.
- Actions - Identifies the rules and, and if it was processed successfully or failed by some reason.
- Status - Status of the message.
- Date - Date when the message was sent.
![Example of the log - Telegram WordPress Widget](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a40cebdca0fd46b9356827/file-hDUHPZrgCZ.png)
You can clear the log at any moment by clicking the button Clear log.
![Clearing the log - Telegram Plugin for WordPress](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a2d5c527c86942e8068d1e/file-Dihq8oCYEk.png)
End Result
As you can see, using the WordPress Telegram Bot plugin you can create the rules, and the bot will respond reacting only on definite word or phrases, that optionally must include or not include some definite keywords. You can create any number of different rules that will respond to different words of phrases.
Use Case Front-End
1. Email Repeater:
![Created Email Repeater rule - Telegram Bot Plugin for WordPress](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a3f903eb3af44cc1209d96/file-qKMopyslYL.png)
Messages on Telegram:
![Messages on Telegram - WordPress Telegram Plugin](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a3fd371df47a61c5ad2a33/file-gJ5lpoWO2M.png)
Sent emails:
![Sent emails - Telegram WordPress Widget](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a3fd86eb3af44cc1209dc2/file-nAq1Fi7vhf.png)
2. SMS Alerts:
![Created SMS Alert rule - Telegram Plugin for WordPress](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a407a127c86942e8069320/file-wh7kAGoabN.png)
Message on Telegram:
![Message on Telegram - Telegram Group Bot Manager](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a40880dca0fd46b9356807/file-PgBBjKCSFX.png)
Sent SMS:
![Sent SMS - Telegram Bot Plugin for WordPress](http://d33v4339jhl8k0.cloudfront.net/docs/assets/558f9e89e4b01a224b42f278/images/60a40c8f1df47a61c5ad2aad/file-uwRb6KnPYS.png)
![]() |
More information about the WordPress Telegram Bot plugin Other WordPress products can be found at CreativeMinds WordPress Store |
![]() |
Let us know how we can Improve this Product Documentation Page To open a Support Ticket visit our support center |