Skip to content

Telegram and voice ​

Two more channels for an agent. Both use the environment's customer sign-in, and both are mostly set up once; this page is what a developer needs to wire them. The routes are in the reference under Telegram and Voice.

A Telegram bot ​

Anyone who messages the bot signs in to your service inside Telegram, and every message after that runs a turn of the agent as them.

You need an agent, the customer sign-in, and a verified custom domain for the project (see Your own domain): the bot sends people to your sign-in page, which has to be on your own domain.

  1. In Telegram, send /newbot to @BotFather and keep the token it answers with.
  2. Attach the bot to the environment, naming the agent that answers:
bash
curl -X PUT "https://api.frege.io/v1/projects/$PROJECT/telegram-bot" \
  -H "Authorization: Bearer $TOKEN" -H "X-Frege-Stage: live" \
  -H "Content-Type: application/json" \
  -d '{"token": "<BotFather token>", "agent": "<agent id>"}'

Frege checks the token with Telegram, stores it encrypted and registers the bot's webhook itself. A bot already attached is replaced. DELETE /v1/projects/{id}/telegram-bot detaches it; customers keep their accounts.

RouteWhat it sets
PUT .../telegram-bot/behaviorHow the bot talks: start prompt, language, the steps it shows, and daily_customer_cap, the most alerts one customer gets a day (UTC; 0 is no limit).
PATCH .../telegram-botThe /menu buttons.
PUT .../telegram-bot/pre-signinQuestions and pictures shown before sign-in.
POST .../telegram-bot/mediaPictures the agent can send, each with a key and a note.
PUT .../telegram-bot/callsVoice calls in a Telegram mini app, on or off.
PUT .../photo-retentionHow many days what Frege read from photos is kept (1 to 3650).

Customers use /start, /signin, /signout, /menu, /call (when calls are on), /stop (stops every alert from your hooks) and /alerts (lets them through again).

Hooks can message customers in the bot; see Hooks.

Voice ​

Customers talk to an agent by voice in the widget, in Telegram, from the dashboard, or from an ordinary phone. Frege keeps the text of each call, not the sound.

Speech models ​

Calls are refused until the environment has a model that listens and a model that speaks: PUT /v1/projects/{id}/voice/settings. GET /v1/models/speech lists Frege's own; PUT .../voice/vendors/{provider} connects an account of your own with a speech vendor.

Phone numbers ​

Each environment has its own numbers, and each number has a route: which agent answers, how the caller is identified, and what happens outside business hours (PUT .../voice/numbers/{numberID}/route). Calls come in only: agents do not call out yet.

A number comes from a virtual line (for test calls from the dashboard, POST .../voice/numbers/{numberID}/test-call), from your own SIP trunk, or from Frege's carrier once it is connected.

To bring your own carrier, create a trunk (POST /v1/projects/{id}/voice/trunks), add the number on it, and ask your carrier to send inbound calls to Frege:

SettingValue
Addresssip.frege.io
Port and transport5060, UDP or TCP
RegistrationNone: the carrier sends calls to Frege
AuthenticationThe trunk's username and password, or the carrier's IP addresses (public, no network wider than /16)
Audio codecG.711 (A-law or μ-law)
Dialled numberIn international form

A trunk's password is shown once. Caller ID can be faked, so by default Frege texts a code to the caller's number and asks them to say it before the agent acts for that customer; a route can trust caller ID for numbers you control end to end.