Integration with PBX systems occurs through SIP connections, which are jointly configured both on the PBX side and on the SIP.TG side.

To create a SIP connection on the SIP.TG side:

  1. Launch the @siptg_bot and go to the /gateway section.
  2. Select the Telegram session you want to connect to the PBX, or create a new one using the “Connect” button (for more details, see Step-by-step session connection).
  3. Click one of the buttons to create a new SIP connection, corresponding to the connection type: ”🆕 PBX→SIP․TG”, ”🆕 SIP․TG→PBX” or ”🆕 IP⇿IP”.

Configuring SIP Connection to PBX

Most settings are displayed directly on the buttons as current values. To change these settings, simply click the corresponding button and enter a new value when prompted by the bot.

However, some buttons work differently:

  • Worker: when clicked, a list of available Worker servers appears. Select the desired server from the list to see its detailed description and assign it.
  • Checkmark buttons, such as “DTMF in”, “DTMF out”, “Redial”, “Lines”, “Message processing”, “Callback” and “Share subscription”, work as toggles. One click activates or deactivates the option.
  • Connection protocol (UDP/TCP/TLS): each click switches to the next available protocol.
  • Show account and Reset password: display connection parameters to SIP.TG that need to be specified on the PBX side.

Below are specific settings for each type of SIP connection.

PBX → SIP.TG

In this mode, your PBX registers on SIP.TG as a SIP client. You receive a SIP login and password from the bot and specify them in your PBX.

This is the simplest connection method and is suitable for most systems (Asterisk, 3CX, FreePBX, etc.).

Screenshot with PBX→SIP.TG connection settings

SIP.TG → PBX

Here, the SIP.TG Worker server registers on your PBX. In the bot, you set the parameters of your PBX: login, password, and address.

Don’t forget to add SIP.TG IP addresses to the whitelist on your PBX. Current list: files.sip.tg/fw.txt.

Screenshot with SIP.TG→PBX connection settings

IP ⇿ IP

Both sides know each other’s IP address. Used in cases where registration is impossible or unnecessary (for example, static routing).

Suitable for advanced users. Requires route configuration on the PBX side.

Screenshot with IP⇿IP connection settings

Types of caller identifiers

Each Telegram user can have up to three types of identifiers:

  • Phone number, on which the account is registered. It is always present, but by default is hidden by privacy settings for other users. With significant limitations, it’s possible to establish contact with a user by phone number.
  • Username — this is a unique alphabetic username. By default, it doesn’t exist, many users set it up, but strictly speaking, it may be absent. Conversely, a user may have several collectible Usernames. You can establish contact with a user by Username, and the restrictions are much milder than for Phone number, but cloud PBXs often do not provide for the use of non-numeric caller identifiers.
  • User ID — internal numeric identifier. Always present, never changes, but it’s impossible to establish contact with a user only by User ID — it can be used only after contact has been established by one of the other methods.
Identifier typeFormatContact possibilityMandatoryChangeablePBX support
Phone numbernumericlimitedyesyesyes
Usernamealphabeticyesnoyeslimited
User IDnumericnoyesnoyes

The table shows that each identifier has serious limitations that prevent it from being used in all scenarios. SIP.TG supports all types of identifiers and their combinations, and also allows you to set the priority of their use according to your needs.

Telegram → PBX

For each SIP connection, you can set rules for forming the Caller ID, which will be transmitted in the From field in the INVITE message for Telegram → PBX calls.

Caller ID formation rules consist of several lines, with one rule per line. Each rule is a template string, in which {phone}, {username}, and {userid} are allowed as template parameters. When forming the final Caller ID, the first rule is used, all template parameters of which contain values about the calling Telegram user.

In addition to Caller ID, the From field can also contain the caller’s name (Caller Name), the formation of which can also be controlled using similar rules, but in addition to the parameters listed above, there are two more:

  • {name} — display name in UTF-8 (may cause problems on the PBX side due to emojis);
  • {name_ascii} — display name converted to ASCII (safe option).

PBX → Telegram

When receiving an INVITE request from the PBX side, the called identifier will be interpreted in full accordance with the same Caller ID parameter described above. However, the algorithm for determining the identifier type and cutting off prefixes and extraneous characters in it does not look so obvious.

CRM Integration

CRM integration is usually implemented not directly with SIP.TG, but through a PBX to which SIP.TG connects as a standard SIP trunk. The CRM itself “sees” calls and contacts thanks to the capabilities of the PBX. Separate modules or plugins specifically for SIP.TG in CRM, as a rule, do not need to be installed.

Most often, the interaction is arranged as follows:

  1. A Telegram call comes to the SIP.TG Gateway (Telegram account).
  2. The SIP.TG Gateway converts the call to SIP and passes it to the PBX (via SIP trunk).
  3. The PBX, having the necessary module or plugin for CRM integration, recognizes the incoming call, displays the client card, logs the call, or performs other actions.
  4. At the end of the conversation, data about the call (for example, duration, result) is also saved in the CRM.

When additional configuration is needed

1

Extended SIP header fields

If your CRM forms or expects some specific headers (for example, X-CRM-ID), such situations are resolved by means of your PBX (AGI scripts in Asterisk, custom settings in 3CX, etc.). On the SIP.TG side, there is no way to directly influence arbitrary SIP headers.

2

Need a forwarded CallerID

In some cases, the CRM needs to see the original caller number in full (for example, to “link” to a specific client). If the call is from Telegram, then the number can be anything (or absent altogether), and here it depends on the logic of your PBX how to substitute CallerID. Sometimes an additional database of correspondence “Telegram ID → client phone” is added.

3

Enabling call recording in CRM

Call recording can be enabled both in the PBX itself and in the “Call recording” mode on the SIP.TG side (in the Softphone). If you want to store recordings specifically in the CRM, check if your PBX can transfer recording files there. From the point of view of SIP.TG, this is a “transparent” transmission of sound via SIP, and there are no additional settings for recording.

Additional tips

  • Unified approach: all settings related to CRM are usually performed in your PBX interface. You perceive SIP.TG as a regular telecom operator (SIP trunk).
  • Typical PBXs (Asterisk, 3CX, FreeSWITCH, Yate, Oktell, Panasonic, etc.) have plugins or REST interfaces for CRM integration. Study the PBX documentation: most likely, there is a ready-made example.
  • Call reception and routing scenarios (IVR, operator queue, automatic forwarding) — all these are common PBX functions. The SIP.TG Gateway does not limit or complicate such scenarios: they work the same way as with other SIP trunks.

Don’t overcomplicate. To “befriend” CRM with Telegram calls, it’s enough to connect the SIP.TG Gateway to your PBX and use the standard CRM integration tools that are available in the PBX.

If you encounter problems or errors, use the Troubleshooting section.