Skip to content

Telegram ​

13 operations. Paths are relative to https://api.frege.io.

Get the environment's Telegram bot ​

GET/v1/projects/{id}/telegram-bot

The bot attached to this environment, if any: its Telegram username and id, the agent that answers, and the last delivery error. Never the token. Organization admin or project manager only.

Authentication: bearer token.

Parameters

NameInTypeDescription
id (required)pathstringProject ID

Responses

StatusDescriptionBody
200OKdata
403Forbiddenerror envelope

Attach a Telegram bot to the environment ​

PUT/v1/projects/{id}/telegram-bot

Paste a BotFather token and name the agent that answers. Frege checks the token with Telegram, stores it encrypted, and registers a webhook so Telegram delivers straight here. A bot already attached is replaced. Anyone who messages the bot is sent to this environment's own sign-in as a Telegram Mini App; once signed in, each message runs one turn of the agent as that customer. An environment with no customer sign-in but with public documentation open gets a docs-only bot instead: people sign in with Google as the MCP URL lets docs readers do, and the agent answers from the public documents alone, with no API tools. Organization admin or project manager only: a bot spends real customers' credentials and real model minutes.

Authentication: bearer token.

Parameters

NameInTypeDescription
id (required)pathstringProject ID

Request body (application/json)

Schema: api.setTelegramBotRequest.

FieldTypeDescription
agentstring
tokenstring

Responses

StatusDescriptionBody
200OKdata
400Bad Requesterror envelope
403Forbiddenerror envelope
409Conflicterror envelope
422Unprocessable Entityerror envelope
502Bad Gatewayerror envelope

Set the Telegram bot's menu ​

PATCH/v1/projects/{id}/telegram-bot

Replaces the bot's menu: inline buttons in one message the customer opens with /menu (also listed under the menu button by the message box) and gets after /start and sign-in. A button is {label: {"en": ..., "ru": ..., "uz": ...}, and one of children, tool or prompt}. With children it opens a submenu in the same message. With tool (a read of this environment's API, with optional args) the bot calls it as the customer, without the agent, and shows the answer through reply ({"ru": "Balance: {{data.balance}}"}, fields by dot path), list ({items: path to the array, item: line per element, title?, page_size?}) or, with neither, as field: value lines. Otherwise a press runs its prompt as the customer's message (its label when there is no prompt), so the agent knows what to do from the prompt itself. The customer sees the label for their Telegram language, else the environment's default, else English, else any. Up to 3 levels, 24 buttons a level (8 a screen, paged), 100 in all; labels up to 64 characters, prompts up to 500. An empty list removes the menu. Organization admin or project manager only.

Authentication: bearer token.

Parameters

NameInTypeDescription
id (required)pathstringProject ID

Request body (application/json)

Schema: api.setTelegramMenuRequest.

FieldTypeDescription
menudata.TelegramMenuButton[]

Responses

StatusDescriptionBody
200OKdata
403Forbiddenerror envelope
404Not Founderror envelope
422Unprocessable Entityerror envelope

Detach the environment's Telegram bot ​

DELETE/v1/projects/{id}/telegram-bot

Unregisters the webhook and forgets the token. Customers who signed in through the bot keep their credentials; only the bot goes. Organization admin or project manager only.

Authentication: bearer token.

Parameters

NameInTypeDescription
id (required)pathstringProject ID

Responses

StatusDescriptionBody
204No Content
403Forbiddenerror envelope
404Not Founderror envelope

Read how the Telegram bot talks to customers ​

GET/v1/projects/{id}/telegram-bot/behavior

The environment's bot behavior: the start prompt, the language of the bot's own words and menu, and whether the agent's steps are shown. Any project member with access to the environment may read it; can_edit says whether the caller may change it. 404 when the environment has no bot.

Authentication: bearer token.

Parameters

NameInTypeDescription
id (required)pathstringProject ID

Responses

StatusDescriptionBody
200OKdata
404Not Founderror envelope

Set how the Telegram bot talks to customers ​

PUT/v1/projects/{id}/telegram-bot/behavior

Replaces the bot's behavior. start_prompt (up to 500 characters) is run as one agent turn when a customer signs in through the Mini App or sends /start signed in, in place of the welcome message: the customer sees only the agent's answer, with the menu under it, and the prompt is kept in the conversation as a sign-in note rather than as something the customer wrote. It runs at most once a minute per chat. default_language is the language of every message the bot itself writes and of its menu; use_telegram_language speaks each customer's Telegram language instead. show_agent_steps shows the agent's steps above its answer; off, the customer sees the answer alone. progress_animation (one of the names listed for the field, such as ring, dots-ring, comet-spinner, bouncing-dots or text-shimmer; empty for none) shows a short line for each stage of a turn, animated, while the agent works, and takes it away when the answer comes; with show_agent_steps on, it animates the running step of the list instead. daily_customer_cap (0 to 1000; left out, it stays as it was) is how many alerts each customer gets a day (UTC) — a hook's notification or a proactive run's reply; one over it is not sent and fails with the reason capped. 0 is no cap. Organization admin or project manager only.

Authentication: bearer token.

Parameters

NameInTypeDescription
id (required)pathstringProject ID

Request body (application/json)

Schema: api.setTelegramBehaviorRequest.

FieldTypeDescription
daily_customer_capinteger
default_languagestringOne of: en, ru, uz.
progress_animationstringOne of: ``, text-shimmer, typewriter, ring, spokes, classic, dots-ring, swirling, arc, concentric-ring, clock-ring, quarter-ring, dash-ring, comet-spinner, pulse, ripple, pulse-dot, dots, bobbing-dots, bouncing-dots, typing, pulsating-dots, triple-dot-spinner, text-blink.
show_agent_stepsboolean
start_promptstring
use_telegram_languageboolean

Responses

StatusDescriptionBody
200OKdata
400Bad Requesterror envelope
403Forbiddenerror envelope
404Not Founderror envelope

Switch calls on or off for the Telegram bot ​

PUT/v1/projects/{id}/telegram-bot/calls

With calls on, the bot lists /call: it answers with a button that opens a call with the bot's agent inside Telegram, as a Mini App, and the agent can send the same button when someone asks to call — the same live call as the widget's call button, through the same voice worker. Only signed-in customers can call. A call needs this environment's Voice settings to be usable; call_blocked in the response says what is missing. Off by default: a call spends real vendor and LiveKit minutes. Organization admin or project manager only.

Authentication: bearer token.

Parameters

NameInTypeDescription
id (required)pathstringProject ID

Request body (application/json)

Schema: api.setTelegramCallsRequest.

FieldTypeDescription
enabledboolean

Responses

StatusDescriptionBody
200OKdata
403Forbiddenerror envelope
404Not Founderror envelope

List the Telegram bot's pictures ​

GET/v1/projects/{id}/telegram-bot/media

Every picture the bot keeps, by key, without its bytes (GET .../media/{key}/content has them). Any project member with access to the environment may read it. 404 when the environment has no bot.

Authentication: bearer token.

Parameters

NameInTypeDescription
id (required)pathstringProject ID

Responses

StatusDescriptionBody
200OKdata
404Not Founderror envelope

Add a picture to the Telegram bot ​

POST/v1/projects/{id}/telegram-bot/media

Uploads a picture the bot can send: with a step before sign-in (its media field), or when its agent shows it by key with display_images. multipart/form-data with file (JPEG or PNG, up to 5 MB; its sides adding up to at most 10000 pixels, neither more than 20 times the other), key (lowercase letters, digits and _, starting with a letter, up to 48 characters, one per picture), and optionally caption, a JSON object {"en"|"ru"|"uz": text up to 1024 characters} the customer reads under it, and note (up to 300 characters), which tells the agent when to show it. Up to 30 pictures a bot. Organization admin or project manager only.

Authentication: bearer token.

Parameters

NameInTypeDescription
id (required)pathstringProject ID

Request body (application/x-www-form-urlencoded)

Type: file or string or string or string.

Request body (multipart/form-data)

Type: object.

Responses

StatusDescriptionBody
201Createddata
403Forbiddenerror envelope
404Not Founderror envelope
413Request Entity Too Largeerror envelope
422Unprocessable Entityerror envelope

Change a Telegram bot picture's caption and note ​

PATCH/v1/projects/{id}/telegram-bot/media/{key}

Replaces the caption ({"en"|"ru"|"uz": text up to 1024 characters}) and the note for the agent (up to 300 characters). The picture itself stays; to change it, remove it and add another. Organization admin or project manager only.

Authentication: bearer token.

Parameters

NameInTypeDescription
id (required)pathstringProject ID
key (required)pathstringThe picture's key

Request body (application/json)

Schema: api.describeTelegramMediaRequest.

FieldTypeDescription
captionobject (map)
notestring

Responses

StatusDescriptionBody
200OKdata
403Forbiddenerror envelope
404Not Founderror envelope
422Unprocessable Entityerror envelope

Remove a picture from the Telegram bot ​

DELETE/v1/projects/{id}/telegram-bot/media/{key}

Forgets the picture. Refused with 422 while a step before sign-in sends it; the agent's instructions are not checked, and a key the agent shows that is gone is skipped. Organization admin or project manager only.

Authentication: bearer token.

Parameters

NameInTypeDescription
id (required)pathstringProject ID
key (required)pathstringThe picture's key

Responses

StatusDescriptionBody
204No Content
403Forbiddenerror envelope
404Not Founderror envelope
422Unprocessable Entityerror envelope

A Telegram bot picture's bytes ​

GET/v1/projects/{id}/telegram-bot/media/{key}/content

The picture itself, as uploaded, for the dashboard to show. Any project member with access to the environment may read it.

Authentication: bearer token.

Parameters

NameInTypeDescription
id (required)pathstringProject ID
key (required)pathstringThe picture's key

Responses

StatusDescriptionBody
200OK
404Not Found

Set what the Telegram bot asks before sign-in ​

PUT/v1/projects/{id}/telegram-bot/pre-signin

Replaces the steps a customer who has not signed in goes through before the sign-in button. Each step is {key, text: {"en"|"ru"|"uz": ...}, buttons: [{label: {...}, emoji?, value}]}: the bot sends the text with a button for each, and a press keeps the button's value under the key in the customer's chat and sends the next step. After the last step comes final: {text?, button?}, the message with the button that opens the sign-in Mini App, the bot's own words where left out. The key "language" takes the values en, ru, uz and switches every message the bot writes to that customer, its menu and its Mini App pages to that language, over default_language and use_telegram_language. /start before sign-in starts the steps over; a signed-in customer never sees them. The answers open the Mini App as answer.<key>=<value> parameters and are told to the agent in every turn of the chat, and the run records them. Up to 10 steps and 24 buttons a step; keys are lowercase letters, digits and _, up to 32 characters, one per step; values up to 64 characters, one per button; texts up to 1000 characters, labels up to 64, emoji up to 16. No steps offers sign-in straight away. Organization admin or project manager only.

Authentication: bearer token.

Parameters

NameInTypeDescription
id (required)pathstringProject ID

Request body (application/json)

Schema: data.TelegramPreSignin.

FieldTypeDescription
finaldata.TelegramPreSigninFinal
stepsdata.TelegramPreSigninStep[]

Responses

StatusDescriptionBody
200OKdata
403Forbiddenerror envelope
404Not Founderror envelope
422Unprocessable Entityerror envelope