- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 05-03-2022 01:01 AM
Create a telegram bot which would provide 3 options to users: -
1 Create a Incident
2 Search for ticket
3 Search Knowledge Base
and using ServiceNow REST Service it will send output back to Telegram Chat Bot
1 Create a Telegram Bot -
To create a telegram bot, follow the steps mentioned here.
An access token would be generated once we create a telegram bot. This access token is used while making API calls to telegram from ServiceNow
2 Create a Scripted REST API
Once u have the bot setup, we will create a webhook for this bot on ServiceNow to receive user messages but before that we need to create a Scripted REST Service.
- Create a table to record telegram conversation to provide context for the next message.
E.g., If the user selects the 1st option, then ask for incident details.
- Script Include to send messages. (XML Attached)
- We created a scripted REST service.
Add a new resource with POST method and define a URL for the same
- Take a note of the URL of the resource. This URL we will use in the next step.
- We have used a Telegram - Send Message. This is an outbound REST message, details are available in the next step
- We are calling our script include to send messages in this resource.
- Set the URL in Telegram Webhook Setup.
Send a GET request with the URL that is created in the above step.
https://api.telegram.org/bot<bot_token>/setWebhook?url=<instance>/api/543178/telegram_bot/createIncident
This would set the webhook URL on telegram which will send the user’s message to ServiceNow.
- Create an outbound message
We will create a REST Message to send the details back to the user.
Send Message - we have used this in script include of step 2.
We can get the Script by clicking on ‘Preview Script Usage’ found below the Related Links
Working of Bot
- Create a Incident
- Search for ticket
- Search Knowledge Base
Resources
- https://core.telegram.org/api
- https://community.servicenow.com/community?id=community_blog&sys_id=886d2a29dbd0dbc01dcaf3231f9619b0
Special thanks to Telegram Bot and ServiceNow Article by Rad in helping me develop this use case.
Hope this will help in understanding Telegram Bot API and ServiceNow REST integration.
- 3,068 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
How to get a chat id from telegram? How do you execute the process?