Integration of MyChat enterprise messenger and Telegram

  1. Why do we need to integrate MyChat and Telegram?
  2. How does it work?
  3. The Telegram bot creation
  4. External IP address + HTTPS in MyChat
  5. Enabling integration with MyChat
  6. Enabling web-hook script in MyChat
  7. Subscribing Telegram user to bot messages
  8. How to send a message from MyChat to Telegram
  9. How to send a message from Telegram to MyChat
  10. 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.
  • Notify the administrator about company database server access problems.

Besides, there are many options, and each company will find its 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 your personal Telegram bot.


3. The Telegram bot creation


Let's make a few simple steps:

Telegram's botfather

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):

Network settings on MyChat Server

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":

Configuring WEB services in MyChat


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",which@BotFather replies to you), and paste it into the "Authorization key (token)" field:

Copying the token for Telegram bot in MyChat

Click on the "Connect the bot" button. If everything is okay, MyChat Server will register web hook in Telegram automatically:

Connecting Telegram bot for MyChat

If there is any problem, you should read and analyze the error log (it appears immediately after the connection attempt):

Error when connecting Telegram bot

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 the "Telegram" script checkbox:

Enabling Telegram script


7. Subscribing Telegram user to bot messages


Open 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 a Telegram user subscribes to messages from the bot, he will appear in the list:

List of Telegram's bots on MyChat Server

You have to enable and connect it with the real MyChat user, like this:

Coneccting MyChat user to Telegram's bot


8. How to send a message from MyChat to Telegram


Here is a 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 Telegram. How to do it?

Use the event OnPrivateMessage and paste the following script:

Using the script to send messages from MyChat to Telegram

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 to the smartphone.

Download the script


9. How to send a message from Telegram to MyChat


To reply to 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:

Reply in Telegram

Replying from Telegram to MyChat:

Message 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.



Служба поддержки