Contact card — template vars
For Admins

Contact card — template vars

The contact card on a ticket can show data from your API. Contact data is filled into the requests to it.

It's set up in “Settings → Operator tools → Contact Card” (owner and admins). Data sources hold the requests to your API: URL, HTTP method, headers and body (JSON, form, raw text or none). Card blocks decide what the operator sees: Data display, List, Action button or a VPN card. Each source is requested once when the card opens, with a 10-second timeout.

Channels of sources and buttons

A source's Channels decide in tickets from which of the project's channels it's needed. The default is All channels, which is also how sources set up earlier work. With channels chosen, tickets from the other channels don't request the source at all: the blocks that read it aren't on their card, its lists' buttons can't be pressed, and the assistant doesn't see its data. A source that looks the customer up in your Telegram bot can stay with the Telegram channel, so that on BILLmanager tickets it doesn't repeat what the BILLmanager block already shows.

  • A ticket's channel is the one the customer last wrote from. If the customer moved from the website chat to Telegram, the ticket's card shows Telegram's sources.
  • An Action button makes its own request, with no source, and has Channels of its own, meaning the same. By default it's there in tickets from any channel. With channels chosen, tickets from the others don't have it on their card, and it can't be pressed there. A button's channels aren't taken from a source or from the request's address.
  • A deleted channel drops out of the list by itself. A source or a button left without a single channel isn't shown anywhere, and the settings warn about it.

Contact variables

They are filled into the URL, headers and body of source and action-button requests:

VariableValue
{contact_id}The contact's ID in SupportHub (UUID)
{internal_id}the widget visitor's session, like vs_…: a random key of their browser, not a user ID
{user_id}same as {internal_id}
{verified_user_id}the user ID your site signed into the widget visitor's token
{external_id}the contact's external ID, e.g. from your CRM (set through the contacts API)
{telegram_id}Telegram ID: from Telegram, and for a widget visitor only the one your site signed
{vk_id}VK ID
{whatsapp_id}WhatsApp ID (like 15551234567@s.whatsapp.net)
{phone}the number from the WhatsApp ID, without @s.whatsapp.net
{email}the contact's email, except one a widget visitor typed in
{name}the contact's name, as the operator sees it on the card
{username}the contact's username (in Telegram, for example), without the @
  • Action buttons also get {input.<id>} — the values of input fields the operator fills in — and item actions in a list get {item.<field>}, the fields of the chosen item.
  • A customer is looked up only by what has been verified. An email or Telegram ID a widget visitor typed in themselves (the pre-chat form, an unsigned identify()) never fills a variable: typing someone else's, they'd get that person's subscription and balance in the assistant's answer, and the operator that person's card. The operator sees such values on the card marked “given by the visitor”. If a visitor came in from the BILLmanager cabinet, BILLmanager has bound that same account to their contact and has itself given the contact's address (with the account's ticket), the email has no mark and the {email} variable gets it. While BILLmanager hasn't given an address, the email stays marked “given by the visitor”. Look up a visitor signed in on your site by {verified_user_id}, the ID from the signed visitor token, or put telegram_user_id into the token: {telegram_id} is filled then too.

Syntax

SyntaxWhat it does
{field}the field's value, or an empty string if it has none
{a|b|c}the first non-empty value of those listed
{?field}…{/?}the block stays only if the field isn't empty
{?!field}…{/?}the block stays only if the field is empty
{?a|b}…{/?}the block stays if at least one of the fields isn't empty

Conditional blocks can be nested. With a JSON body, the body must still be valid JSON after substitution, or the request isn't made.

Values filled into a JSON body are escaped, so quotes and line breaks in a customer's name or an operator's comment don't break it. Just put the variable in quotes: "NAME": "{name}". Escaping leaves numbers and plain text as they are, so an unquoted {telegram_id} works as before.

Example 1 — conditional JSON with multiple identifiers

The request sends whichever identifier the contact has. The conditional blocks make sure only one field ends up in the JSON.

{
  "method": "user.get",
  "params": {
    {?external_id}"user_id": "{external_id}"{/?}{?!external_id}{?telegram_id}"telegram_id": {telegram_id}{/?}{?!telegram_id}{?vk_id}"vk_id": {vk_id}{/?}{?!vk_id}{?email}"email": "{email}"{/?}{/?}{/?}{/?}
  }
}
Check order: external_id → telegram_id → vk_id → email. Once the first non-empty value is found, the other blocks are skipped.

Example 2 — the first non-empty identifier

The {a|b|c} form fills in the first non-empty value. Handy when the API accepts any identifier in a single field.

{
  "query": "{telegram_id|vk_id|email}",
  "source": "supporthub"
}
If none of the fields is filled in, an empty string goes in and the request is still made. Answer such a request with an error (a 404, for example) and set up Error handling on the source by HTTP code or a JSON field — the operator then sees a clear message instead of an empty card.

Example 3 — every known identifier in its own field

The comma sits inside the conditional block, so an empty field never reaches the body and the JSON stays valid for any combination. This is how the Ready-made VPN client card template sends it: the service tries the fields in its own order instead of guessing what it was given. A single shared field, as in example 2, only fits a service that tells the values apart for sure: a numeric user ID and a Telegram ID look the same.

{
  "include": ["card"]{?external_id|verified_user_id},
  "user_id": "{external_id|verified_user_id}"{/?}{?telegram_id},
  "telegram_id": {telegram_id}{/?}{?email},
  "email": "{email}"{/?}
}

user_id here is the user's ID in the service: from the project's API (external_id), and for a widget visitor signed in on the site, the ID the site signed into their token (verified_user_id).

Link buttons

A link button's URL template takes values from your API's response: {field.path} is the dotted path to a field from the root of the response, the same as for the block's fields. The :b64 modifier encodes the value as URL-safe base64 without padding — for a Telegram deep link, for example. If any value is missing from the response, the button isn't shown.

A List has its own row links — a button on each item. Their template takes the item's own fields: in a list of servers, {admin_url} opens that server's page. An item without the value gets no button.

Only links starting with https://, http://, tg://, mailto: or tel: are shown. An address without a scheme, or with any other scheme, gets no button — even when the whole address comes from the API response.

Action buttons

An Action button and a List's item actions send a request to your system. They work from a ticket: every press is recorded in the ticket's history and in the project's audit log — who pressed which button, for which list item, and what your system answered. Input field values aren't recorded: such a field may hold a password or a key.

  • With Admins and owner only on, an operator sees the button with a lock and can't press it. The server checks this too: it won't run the request for an operator.
  • An item action takes the item from the source's fresh response, not from what was on the screen: the values filled into the request through {item.<field>} are checked against the response at the moment of the press. If the item is no longer there — say, the server was deleted while the card was open — no request is made and the operator is asked to refresh the card.

Streamer mode

There's no knowing in advance which fields of your card are personal data, so every data block (Data display, List, VPN card) has a Streamer mode section. It decides what gets blurred for an operator who turned on streamer mode:

  • Hide the whole block blurs every value of the block, whatever it holds. Field labels stay readable.
  • Each field gets Auto, Hide or Show. Auto hides a field whose key or name looks like personal data: email, phone, Telegram, VK, WhatsApp, IDs, balance, IP, address, card, wallet, token, password, passport, tax and insurance numbers, name, date of birth, links. What Auto picks shows right in the list: “Auto: hidden” or “Auto: visible”.
  • The choice is tied to the field's path (user.email), not its label: renaming the label keeps it, and changing the path takes the choice along. In a list the path is inside an item, so name in the configs list is a config's name, not a person's.
  • A block with no field list shows the whole API response: its keys follow the Auto rules, and a key you want to decide for yourself is added by hand.
  • The VPN card lists its own fields: name, Telegram, ID, email, balance, payment and withdrawal amounts, withdrawal details, subscriptions, statistics and more. A subscription in the card is titled by its config name (the name field), which is how the service's admin panel finds it. The label the customer gave it themselves (custom_name) sits beside it in quotes.
In streamer mode, link buttons don't show their URL on hover — it often carries the client's ID (…?start=get_u_{user.id}). A click opens the link as usual.
Was this page helpful?