- Why do we need to integrate MyChat and Telegram?
- How does it work?
- The Telegram bot creation
- External IP address + HTTPS in MyChat
- Enabling integration with MyChat
- Enabling web-hook script in MyChat
- Subscribing Telegram user to bot messages
- How to send a message from MyChat to Telegram
- How to send a message from Telegram to MyChat
- What do I do if it didn’t work out?
1. Why do we need to integrate MyChat and Telegram?
Here are some examples:
- To make an automatic notification for absent office workers.
- For sending messages to your customers or suppliers on specific events.
- Notifythe administrator about company database server access problems.
Besides, there are many options, and each company will find their own usage.
2. How does it work?
You must create a Telegram bot by yourself. After this, you have to enable integration with Telegram in the "Tools" -> "Integration" -> "Telegram Bot" section in the MyChat Admin Control Panel. All necessary users will subscribe to this bot directly from the Telegram messenger.
On MyChat Server you can use scripts to send messages to any person, who is subscribed to you personal Telegram bot.
3. The Telegram bot creation
Let's make a few simple steps:
To begin with, you have to send a message to @BotFather from the Telegram application and he will guide you. Create a unique name for your bot: only you and your users will know it:
The official Telegram bot creation instruction is here.
4. External IP address + HTTPS in MyChat
Two conditions must be followed for the correct integration between MyChat and Telegram.
Your MyChat WEB server must be available from the Internet. You need an external «white» IP address to do this. What is that and how do I set up this?
Type your server domain name in the Administration Control Panel "Settings" -> "Network settings" -> "IP address or hostname for external clients" (do not enter the external IP address because SSL certificate works with domain only):
b) Your WEB server must use HTTPS. You have to use special verified certificates for it. You can’t use self-signed non-trusted certificates. You can enable HTTPS encryption in the MyChat Server Administration Control Panel "Settings" -> "WEB services":
5. Enabling integration with MyChat
After you’ve created your Telegram bot, you need to enable integration with Telegram in the MyChatServerAdministration Control Panel ("Tools"-> "Integration" -> "Telegram").
Just copy a bot token (text line like a"bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11",[email protected] replies to you), and paste it into the "Authorization key (token)" field:
Click on the "Connect the bot" button. If everything is okay, MyChat Server will register web-hook in the Telegram automatically:
If there is any problem, you should read and analyze error log (it appears immediately after the connection attempt):
Error log helps you to find a problem type and clarify on which integration step you made a mistake.
To check your bot, follow the link: https://api.telegram.org/bot(paste your bot token here, without brackets)/getWebhookInfo, if there is no "last_error_message’, then it’s most likely mean, that everything is okay and the Telegram bot can send messages to you.
6. Enabling web-hook script in MyChat
Everything is simple here: you need to enable the script for incoming messages from the Telegram bot.
Enter the event "Tools" -> "Scripts" -> "Event scripts" -> "OnRequestByREST" and enable "Telegram" script checkbox:
7. Subscribing Telegram user to bot messages
Open the Telegram on your smartphone and type in the search bar your bot name. Then, open the dialog with the bot and press the "Start" button, or simply send the text "/start" to it and it will register you in the MyChat Server:
As soon as Telegram user subscribes to messages from the bot, he will appearin the list:
You have to enable and connect it with the real MyChat user, like this:
8. How to send a message from MyChat to Telegram
Here is the real example. A MyChat user sends a private message to another user, who is offline now.
We need to duplicate this message to the specific user in the Telegram. How to do it?
Use the event OnPrivateMessage and paste the following script:
If the message recipient is located in the list of users in the integration section, MyChat will send him a copy of the private message tothe smartphone.
9. How to send a message from Telegram to MyChat
To reply a person in Telegram you need to make a long tap on the received message and choose "Reply"(messages come from the bot, not from the specified person).
You obtain a bilateral connection:
Replying from Telegram to MyChat:
10. What do I do if it didn’t work out?
Visit the MyChat official support forum and ask your questions. Our team is always ready to help you.
|< <<<=====||=====>>> >|