Omniscope Custom Blocks › Outputs/Telegram

Send to Telegram

Sends the input records as a message to a Telegram chat, group or channel through your bot, as text, a table or JSON.

Outputs › Messenger Python

Open the demo in Omniscope Download demo.ioz Sample data: low-stock.csv Sample data: placeholder.csv Source on GitHub

Omniscope custom block · Outputs

This morning's reorder list on the warehouse leads' phones, as a table that lines up, sent by the workflow that worked it out.

Python · requests, pandas · requests installed on first run if missing

The problem it solves

The stock workflow knows each morning which products have fallen below their reorder level. The people who reorder are on the warehouse floor, with phones, not at a dashboard. A message in their Telegram group, with the list, gets acted on.

This block sends the records to a Telegram chat through your bot, split into several messages if the list is longer than Telegram allows.

How it works

What goes in

Low stock

Product Warehouse In stock Reorder level Last delivery
Terracotta pot 30cm Leeds 14 40 2025-03-03
Compost 50L Leeds 22 60 2025-02-24
Hose reel Bristol 3 10 2025-02-17
Netting 4m Bristol 0 15
Fleece & frost cover Reading 4 12 2025-02-20

8 rows in the sample file.

The options

Option Demo setting What it does
Bot token (an example token) The token from @BotFather.
Chat ID -1001234567890 (an example) The group, chat or @channel to send to.
Format Table Text (one line per record), Table or JSON.

What comes out

The message (as Telegram shows it, first lines)

Product                | Warehouse | In stock | Reorder level | Last delivery
-----------------------+-----------+----------+---------------+--------------
Terracotta pot 30cm    | Leeds     | 14       | 40            | 2025-03-03
Compost 50L            | Leeds     | 22       | 60            | 2025-02-24
Hose reel              | Bristol   | 3        | 10            | 2025-02-17
Netting 4m             | Bristol   | 0        | 15            |

Sent

Part Parts Records Characters Message ID Chat
1 1 8 744 4101 -1001234567890

One message holding all 8 records. (The message ID is invented: it comes from Telegram.)

Where it pays off

Warehousing: Reorder lists

The lines below their reorder level, sent to the warehouse group each morning.

Field service: Today's jobs

Each engineer's jobs for the day, filtered per engineer and sent to their chat.

Finance: Payment exceptions

Payments that failed a check overnight, as JSON for a follow-up bot or as a table for people.

Monitoring: Threshold alerts

Sensors or sites outside their limits in the latest data; no records, no message.

Use cases describe typical scenarios and are illustrative; the sample data is invented.

Why do this in Omniscope

How it fits into an Omniscope workflow

Database (stock) → Join (reorder levels) → filter (in stock below reorder level) → Sort → Send to Telegram

Try it

  1. Open the demo project (demo.iox on the demo server, or import demo.ioz from this folder). It holds the sample low-stock list, the block with example settings (it needs your own bot to send), and a File block with placeholder.csv: what the block outputs when it sends the sample as a table.
  2. The question: was the list sent, and in how many messages?
  3. Look at the placeholder record: one message, eight records.
  4. To send for real: create a bot with @BotFather, add it to a group, paste the token and the group's chat ID, and run the block.

Running in Omniscope

Omniscope workflow
Omniscope workflow

The demo project's workflow: the sample data, the block, and a Validate data check on its output.

Language and libraries

Python. It uses requests (Apache License 2.0) and pandas (BSD 3-Clause).

pandas is part of Omniscope's Python environment. requests is listed in the block's dependencies, so Omniscope installs it with pip on first run if it is missing.

Tested

The block is covered by automated tests that run its script against a stand-in for Omniscope's Python API and a stand-in for Telegram's Bot API that answers as Telegram does, refusals included (no live calls): the sample in each format, with the text checked line by line; a table that lines up and escapes &; JSON with numbers and dates; 400 records split into several messages in each format, with every record sent once; an unknown chat and a wrong token; a network error, with the token kept out of the message; empty input; missing settings; a channel name and mixed field types; and 20,000 records.

Reference

Options

NameTypeWhat it does
Bot tokenPasswordThe token @BotFather gave when the bot was created, such as 7000000001:AA...
Chat IDTextWhere to send: a number (a group's starts with -), or @channelname for a public channel. The bot must be in the group or an administrator of the channel.
FormatChoiceHow the records are written in the message.

Outputs

OutputWhat it holds
SentOne record per message sent: Part, Parts, Records (in that message), Characters, Message ID, Chat.