Graphrt

Telegram Bot

Read updates by long polling, send messages, photos and documents, edit and delete messages, answer button presses, manage the webhook

Beta v0.1.0 Node.js 16 actions ToS risk low
Use in Graphrt Desktop

About

A Graphrt plugin for the official Telegram Bot API. It reads a bot's updates by long polling, sends and edits messages, sends photos and documents, answers inline-keyboard button presses and manages the webhook. Every operation is a workflow node, all except the webhook operations are also agent tools.

What it can do

  • Updates: get_updates with a cursor (next_cursor = last update_id + 1), long polling up to 25 s
  • Sending: text (MarkdownV2/HTML/Markdown, replies, silent, keyboards, forum topics), photos and documents by URL or file_id, chat actions ("typing…")
  • Messages: edit text, delete, forward, answer callback queries
  • Info: the bot itself, a chat, a chat's member count
  • Webhook (node only): set, delete, get info
  • api_request: any other Bot API method, by method name only. Agents (tool calls) may only use get* methods, anything that sends, pays or deletes must be a dedicated operation or a workflow node. getUpdates, the webhook methods, logOut and close are refused
  • The bot token never appears in errors or responses (it is redacted everywhere, including api_request)

Actions

Each action is a step you can add to a workflow. Agents can also use most of them as tools.

  • Get Telegram updates telegram-bot.get_updates
  • Send Telegram message telegram-bot.send_message
  • Send Telegram photo telegram-bot.send_photo
  • Send Telegram document telegram-bot.send_document
  • Send Telegram chat action telegram-bot.send_chat_action
  • Edit Telegram message text telegram-bot.edit_message_text
  • Delete Telegram message telegram-bot.delete_message
  • Forward Telegram message telegram-bot.forward_message
  • Answer Telegram button press telegram-bot.answer_callback_query
  • Get Telegram bot info telegram-bot.get_me
Show all 16 actions
  • Get Telegram chat telegram-bot.get_chat
  • Count Telegram chat members telegram-bot.get_chat_member_count
  • Set Telegram webhook telegram-bot.set_webhook
  • Delete Telegram webhook telegram-bot.delete_webhook
  • Get Telegram webhook info telegram-bot.get_webhook_info
  • Telegram Bot API request telegram-bot.api_request

Settings

Graphrt starts plugins with a clean environment. Only these values reach the plugin, and secrets stay out of logs.

  • TELEGRAM_BOT_TOKEN Required
    Bot token "<bot id>:<secret>" from @BotFather
  • TELEGRAM_WEBHOOK_SECRET Optional
    Sent by set_webhook as secret_token: Telegram puts it in the X-Telegram-Bot-Api-Secret-Token header of every webhook call (1-256 of A-Z a-z 0-9 _ -)

How to use it

In Graphrt Desktop

  1. Open Plugins and search for Telegram Bot.
  2. Click Install and approve it.
  3. Follow the setup steps on the plugin's page, then paste the settings it needs.
  4. Describe a job that needs it, and the builder adds the steps.
Plugins in Graphrt Desktop

With the CLI

terminal
$ graphrt plugin install telegram-bot
workflow.yaml
- id: updates
  type: telegram-bot.get_updates
  cursor: "{{#state.value#}}"      # e.g. from state-store; empty on the first run
  long_poll_seconds: 20
  allowed_updates: '["message","callback_query"]'
- id: reply
  type: telegram-bot.send_message
  chat_id: "{{#start.chat_id#}}"
  text: "Pesanan *{{#start.order_id#}}* sudah dikirim"
  parse_mode: MarkdownV2
  reply_markup: '{"inline_keyboard":[[{"text":"Lacak","callback_data":"track"}]]}'
Plugins in the docs