By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
RPABOTS.WORLD
  • Topics
    • UiPath
    • blue prism
    • Open Source RPA
    • power automate
    • automation anywhere
  • Resources
    • RPA News
    • UiPath Free Course
    • Software
    • Jobs
    • Publications
  • Contact-us
    • Write For Us
    • Editorial Team
Notification
  • My Interests
  • My Saves
  • My Feed
  • History
Personalize
RPABOTS.WORLDRPABOTS.WORLD
Aa
Search
  • Topics
    • UiPath
    • blue prism
    • Open Source RPA
    • power automate
    • automation anywhere
  • Resources
    • RPA News
    • UiPath Free Course
    • Software
    • Jobs
    • Publications
  • Contact-us
    • Write For Us
    • Editorial Team

Top Stories

Explore the latest updated news!
Robot Framework Python: Working with Databases

Robot Framework Python: Working with Databases

Continuous Integration and Deployment with Robot Framework

Continuous Integration and Deployment with Robot Framework Python

Top 5 Tips for Writing Clean and Maintainable Robot Framework Python Code

Top 5 Tips for Writing Clean and Maintainable Robot Framework Python Code

Stay Connected

Find us on socials
248.1k Followers Like
61.1k Followers Follow
165k Subscribers Subscribe
Made by ThemeRuby using the Foxiz theme. Powered by WordPress
RPABOTS.WORLD > Blog > RPA > Telegram Bot Integration With UiPath (Remote Captcha solving)
RPA

Telegram Bot Integration With UiPath (Remote Captcha solving)

Nikolay But
Last updated: 2020/12/23 at 9:07 AM
By Nikolay But 3 comments
Share
6 Min Read
SHARE

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.

Contents
Add UiPath.Web.Activities package in Manage PackagesCreate new Telegram BotCreate initial UiPath process.Finalize UiPath with Telegram process.Making keyboard layout for telegram botSend a screenshot with Captcha.Listen to answer from the userReact on actionsReact on message

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- 

  1. Add UiPath.Web.Activities package in Manage Packages
  2. Create Telegram Bot
  3. Create initial UiPath process.
  4. Get target ChatId to connect bot with you.
  5. 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.

Telegram Bot Integration With UiPath

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.

UiPath.Web.Activities package in Manage Packages

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:

  1. Search “botfather”
  2. Open proper chat
  3. Create new bot by typing “/newbot”
  4. Give bot name and username
  5. Copy bot token – you’ll need it later.
  6. Open chat with new bot and Ssend any test message – to get ChatId in future steps.
Create new Telegram Bot

Create initial UiPath process.

We will use only the following types of Telegram methods:

  1. getUpdates – to get messages and callbacks from user.
  2. sendPhoto – to send screenshot.
  3. sendMessage – to send message user.

Read More at Telegram Documentation – https://core.telegram.org/bots/api#authorizing-your-bot 

First of all, you need to add the “Use Application\Browser” activity and assign it to the website https://captcha.com/demos/features/captcha-demo.aspx.

Create initial UiPath process.

Then add Flowchart and:

  1. Assign string Token to remembered before telegram bot token.
  2. Assign string UpdateId to “0”.
  3. 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.
  4. Add HTTP request activity and fill in it:

Assign EndPoint to “https://api.telegram.org/bot”+Token+”/getUpdates”

  • Add Parameters:
  • String offset = Offset
  • String limit = “1”
UiPath process for Web activity
Telegram Bot Integration With UiPath (Remote Captcha solving) 1

Our  Intial Workflow will look like this

Deserialize JSON activity to deserialize

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.

Telegram Bot Integration With UiPath (Remote Captcha solving) 2
Then assign valid ChatId. My example below:

Finalize UiPath with Telegram process.

Now we know all the necessary items: Token and ChatId. So we can move on to the most interesting part of this guide.

Making keyboard layout for telegram bot

More at https://core.telegram.org/bots/api#inlinekeyboardmarkup 

I chose this type of markup and it has following JSON form – there are two buttons “change” and “speak” which contains appropriate “callback_data”.

Assign KeyboardMarkup = “{“”inline_keyboard””: [[{“”text””: “”change””,””callback_data””: “”change””},{“”text””: “”speak””,””callback_data””: “”speak””}]]}”

Telegram Bot Integration With UiPath (Remote Captcha solving) 3

Send a screenshot with Captcha.

Add “Take screenshot” activity, set it to Captcha image and save image file path to variable CaptchaImagePath:

Telegram Bot Integration With UiPath (Remote Captcha solving) 4
Telegram Bot Integration With UiPath (Remote Captcha solving) 5

Then send it to telegram chat via HTTP Request activity:

Telegram Bot Integration With UiPath (Remote Captcha solving) 6
Telegram Bot Integration With UiPath (Remote Captcha solving) 7
Telegram Bot Integration With UiPath (Remote Captcha solving) 8

In the chat it will look like- 

 

Telegram Bot Integration With UiPath (Remote Captcha solving) 9

Listen to answer from the user

  • Add another HTTP Request Get Updates activity.
  • Add another Deserialize JSON activity.
  • Add Flow Decisions activity to check whether the answer is callback or message: get action if it is a callback and Captcha text if it is a message.
Telegram Bot Integration With UiPath (Remote Captcha solving) 10

The answer is Callback?

ResultJObj(“result”).Count > 0 AndAlso ResultJObj(“result”)(0)(“callback_query”) IsNot Nothing

If it is a callback then save Action:

ResultJObj(“result”)(0)(“callback_query”)(“data”).ToString

The answer is a Message?

ResultJObj(“result”).Count > 0 AndAlso

ResultJObj(“result”)(0)(“message”) IsNot Nothing

If it is a message then save AnswerText:

ResultJObj(“result”)(0)(“message”)(“text”).ToString

 

 

 

React on actions

We have 2 actions: change and speak. So every action is a click to appropriate button:

Telegram Bot Integration With UiPath (Remote Captcha solving) 11
Telegram Bot Integration With UiPath (Remote Captcha solving) 12
Telegram Bot Integration With UiPath (Remote Captcha solving) 13

Then we need to send a message to the user to give feedback:

Telegram Bot Integration With UiPath (Remote Captcha solving) 14
Telegram Bot Integration With UiPath (Remote Captcha solving) 15
Telegram Bot Integration With UiPath (Remote Captcha solving) 16

Then update UpdateId and loop to “Take Screenshot ‘Captcha’”. Workflow will look like this:

Telegram Bot Integration With UiPath (Remote Captcha solving) 17

React on message

Then we need to process getting and typing into Captcha text. If answer is message with Captcha text then we need to save AnswerText from ResultJObj:

 

ResultJObj(“result”)(0)(“message”)(“text”).ToString

 

Then add “Type Into” activity to type this answer to Captcha validation input:

Telegram Bot Integration With UiPath (Remote Captcha solving) 18

Then add “Click” activity to button “Validate”:

Telegram Bot Integration With UiPath (Remote Captcha solving) 19

Then we need to get the result text of validation:

Telegram Bot Integration With UiPath (Remote Captcha solving) 20

Then direct to “HTTP Request sendMessage” activity. If answer is not a message then we need to direct flow to “HTTP Request getUpdates” activity.

Workflow will look like this:

Telegram Bot Integration With UiPath (Remote Captcha solving) 21

Please feel free to reach me in case you are still facing any issues with your Telegram integration with UiPath.

Happy Automation!

TAGGED: Bot, Chat Bot, Telegram, Telegram Bot, uipath, UiPath Examples, UiPath Guide, UiPath Tutorial

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.

By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Twitter LinkedIn Reddit Telegram Email Copy Link Print
What do you think?
Love0
Sad0
Happy0
Sleepy0
Angry0
Dead0
Wink0
Previous Article Working with UiPath Queues | Step by Step Guide UiPath Queues | Working Example Step by Step Guide
Next Article create your first automation in OpenBots Studio OpenBots Working Example | Solve RPA Challenge Open Source RPA Tool
3 Comments 3 Comments
  • Manoj N says:
    11/04/2022 at 8:56 am

    What is Functions of this project

    Reply
  • Manoj N says:
    11/04/2022 at 8:57 am

    What is the Function of telegram Bot here

    Reply
  • Ivttan says:
    03/28/2023 at 10:46 pm

    ¿como encapsulo esto en un paquete para utilizarlo en mis proyectos?

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Want to learn more? 🚀

Robot Framework Python: Working with Databases
Robot Framework Python: Working with Databases
RPA
Ensuring
Ensuring RPA Security: Best Practices and Guidelines
RPA
Robotics Process Automation in Finance and Accounting
RPA Upscaling All Dynamics of the Healthcare Industry in 2023
RPA
Low-Code/No-Code Development Platforms: The Future of Software Development? 23
Low-Code/No-Code Development Platforms: The Future of Software Development?
RPA

💙 Subscribe to me on YouTube :)

👉 Stay Connected

Instagram Follow
Youtube Subscribe
Telegram Follow

Related Stories

Uncover the stories that related to the post!
Robot Framework Python: Working with Databases
RPA

Robot Framework Python: Working with Databases

Ensuring
RPA

Ensuring RPA Security: Best Practices and Guidelines

Robotics Process Automation in Finance and Accounting
RPA

RPA Upscaling All Dynamics of the Healthcare Industry in 2023

Low-Code/No-Code Development Platforms: The Future of Software Development? 25
RPA

Low-Code/No-Code Development Platforms: The Future of Software Development?

UiPath Integration Service –Platform Update 21.10 | Working ServiceNow Example

Microsoft Power Automate Pricing – Is Power Automate Worth It?

Robotics Process Automation in Finance and Accounting
RPAuipath tutorial

Working with UiPath Test Automation

Robotics Process Automation in Finance and Accounting
RPA

Robotics Process Automation in Finance and Accounting

Show More
RPABOTS.WORLDRPABOTS.WORLD
Follow US
Disclosure: Posts on this site may contain affiliate links, meaning that if you click on one of the links and purchase an item, we may receive a commission (at no additional cost to you). All opinions are our own and we do not accept payments for positive reviews. All product names, logos, and brands are the property of their respective owners in the United States and/or other countries. All company, product and service names used on this website are for identification purposes only. Use of these names, logos, and brands does not imply endorsement.
Copyright © 2019 - 2023, RPABOTS.WORLD., unless otherwise noted. All rights reserved.
Join Us!

Subscribe to our newsletter and never miss our latest news, podcasts etc.

Zero spam, Unsubscribe at any time. Copyright © 2019 - 2023, RPABOTS.WORLD., unless otherwise noted. All rights reserved.
Welcome Back!

Sign in to your account

Lost your password?