Telegram Bot needs no introduction today and with the growing usage of chat bot in RPA industry it is obvious choice to integrate your workflow with telegram bot.
In this tutorial, we are going to write a small UiPath process which interacts with Telegram Bot chat: send to user a screenshot with Captcha image (from website https://captcha.com/demos/features/captcha-demo.aspx), wait for message with recognized Captcha text or command to change Captcha or command to speak Captcha out.
You can download the project .xaml from GitHub – You’ll just need to add your Telegram Bot token and ChatId (Id of chat of bot with you) https://github.com/mflow42/rpabotsworldbot to to get this example working.
Action plan for this article-
Add UiPath.Web.Activities package in Manage Packages
Create Telegram Bot
Create initial UiPath process.
Get target ChatId to connect bot with you.
Finalize UiPath with Telegram process.
Add UiPath.Web.Activities package in Manage Packages
To work with “HTTP request” and “Deserialize JSON” activity you need to first add UiPath Web Activities Pack as dependencies in your project.
You can enable and install it from the Manage Packages window as shown below.
Select UiPath Web Activities Pack and click on install to add a required dependency. As soon as they are added you will be able to see web activities from the activities panel as below.
Create new Telegram Bot
Open telegram app: mobile, desktop, or web (https://web.telegram.org/). Register if you did not do it before. Then follow instructions:
Search “botfather”
Open proper chat
Create new bot by typing “/newbot”
Give bot name and username
Copy bot token – you’ll need it later.
Open chat with new bot and Ssend any test message – to get ChatId in future steps.
Create initial UiPath process.
We will use only the following types of Telegram methods:
getUpdates – to get messages and callbacks from user.
Assign string Token to remembered before telegram bot token.
Assign string UpdateId to “0”.
Assign string Offset to ((CInt(UpdateId)+1).ToString. It needs to get not all but only last update from chat. By default, it is incremented value of UpdateId by 1.
Add HTTP request activity and fill in it:
Assign EndPoint to “https://api.telegram.org/bot”+Token+”/getUpdates”
AddParameters:
String offset = Offset
String limit = “1”
Our Intial Workflow will look like this
Then add Deserialize JSON activity to deserialize response from the server.
Then add assign to UpdateId = If(ResultJObj(“result”) IsNot Nothing AndAlso ResultJObj(“result”)(0)(“update_id”) IsNot Nothing, ResultJObj(“result”)(0)(“update_id”).ToString, UpdateId)
Then add assign ChatId and make Breakpoint at this activity to get ChatId from the response in Local Panel via Debug mode.
Finalize UiPath with Telegram process.
Now we know all the necessary items: Token and ChatId. So we can moveon to the most interesting part of this guide.
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Cookie settingsACCEPT
Privacy & Cookies Policy
Privacy Overview
This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
Subscribe to receive exclusive content and notifications
What is Functions of this project
What is the Function of telegram Bot here