I recently had a conversation with a customer where we were thinking about on how to distribute important information from a workflow to the recipient. The most obvious idea was to send an e-mail. But you know how it is… you get hundreds of mails every day and if there is a very important one you will often miss it.
We had the idea to use another medium to send out notifications and as today you have your mobile phone always close to you, the idea came up to use one of the popular messengers out there. Here Telegram offers a wide range of options with their free API https://core.telegram.org/api and capability to create Bots https://core.telegram.org/bots.
Let’s use a Bot to share some important messages out of Alteryx. I created an Alteryx macro to interact with this API. You can find the macro attached in this post or on the Public Gallery.
You can send a single message directly from the Tool configuration, or you connect an incoming data stream to use a whole batch of entries. You as well can get the last interactions with the Bot in a single chat by selecting “Get Bot Updates”.
Now you have seen that you will interact with a Bot. Wait, a what? A Bot? Do I need a Server and stuff like this to get this up and running?
Luckily the answer is NO.
A Bot is a third-party application that runs inside Telegram, so they are doing all the stuff for you. And the best is, they do it for free. You simply tell the Bot what it should do, like sending a Message to you or a group. So you will have a conversation with a non-human character.
To create a Bot you will speak to … another Bot in Telegram 🙂 It’s the BotFather.
Search for “BotFather” and start a chat with him.
Message him “/newbot” and he will guide you through the process. At first you choose a Name. This is the name which will appear in your contact list. Mine is called “Alteryx Workflow”. Then you define a username. This is a unique identificatory and ends with “bot”.
After this is done you receive your API Token to authenticate against the service. The Token looks like this: 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
The last thing you need to know is the Chat ID the Bot should interact with. As the Bot is a little shy you need to start the conversation, otherwise it will not speak to you. Search for your Bot and write something to it, like “Hello 😊”. You can add the Bot to Group Chats as well, so you don’t need to send single messages to every person.
Now as you started the conversation you can get the Chat ID by selecting “Get Bot Updates”. Here you can see all interactions which happened with your Bot since the last request.
You can call this one through a website as well: https://api.telegram.org/bot<<YOUR_API_TOKEN_HERE>>/getUpdates. Now you have an API Token and a Chat ID.
You can use the macro to send a single message:
To send messages based on your Input, you can active the incoming connection option. To select specific entries:
When not setting a specific column, the configuration from the main settings will be used. Now you are ready to go to send automated messages by Alteryx to Telegram.
Messages can be formatted, as well. The different formatting options and how to add them to your text is described here: https://core.telegram.org/bots/api#formatting-options
Even add emojis! Check out this page: https://emojipedia.org/ Here you can simply copy and paste the emoji to send it in your Telegram message.
Banner image by csgboyer