telybot A little less ordinary.
A lot more intelligent.
Nepal Sign in Talk to us Start free
Telybot docsGuides

Actions: answers from your own system

With actions, Telybot answers from your own system during a chat — where an order is, when it will be delivered, whether a booking is confirmed.

The customer asks, the bot collects what it needs, calls your API, and answers from what comes back, in the customer's language. It works everywhere your bot does: the website widget, your bot link and QR code, and the Android, iOS, React Native, Flutter and Ionic apps. Nothing is installed or updated: Telybot makes the call itself, so your API credentials never reach a browser or a phone.

Before you start: anyone can chat with your bot

Your bot is a public chat. If an order number alone is enough to see an order, anyone can type numbers until one works.

Ask for two details only the real customer knows — the order number and the email or phone on the order — and make your API return the order only when both match. Answer "not found" otherwise.

The bot helps in three ways, but none of them replaces that check: it sends only values the customer actually typed, it limits how many lookups one chat or one address can make, and you can choose which fields of the response it is allowed to see.

Set up an action

Owners and admins can set up actions.

  1. Open Actions → New action.
  2. Fill in the fields described below, and save.
  3. Under Actions → All actions, press Test beside the action, type sample values and press Run test: you see the request that was sent and exactly what the bot would be given.
  4. Then try it for real on the Test screen: "Where is my order 48213? My email is asha@example.com".

The fields:

  • Name — for you, such as "Order status".
  • When should the bot use it? — one sentence, as you would tell a new colleague: "The customer asks where their order is or when it will arrive."
  • Your API address — GET or POST, and an https:// address. Write {{order_id}} where a value goes.
  • What the bot asks the customer for — up to six values. Each has a label in your words ("Order number"), the name your API uses (order_id) and a type: any text, a number, an email address or a phone number.
  • Authentication — the connection to the system this address belongs to, which carries its key. Choose one you saved, or + Add a connection… to add it in a side panel without leaving the action. When only one of your connections is for the address you typed, it is chosen for you. How connections work is below.
  • Extra headers — only what this one action needs beyond its connection, such as a tenant id. Stored encrypted and never shown again. A header the connection already sends cannot be added here.
  • Only share these fields with the bot — optional. List the parts of the response the bot may use, such as status, eta, items[].name. Everything else is dropped before the AI sees it.

Connect your systems

Each system your bot talks to is connected once, as a connection, and every action and webhook for that system uses it. Connect as many as you run, up to 20: an order system with an API key, a booking tool with a token, a CRM through its own OAuth app. Each one signs in in its own way, and each credential goes only to its own system.

  1. Under Authentication in an action or a webhook, choose + Add a connection…, or open Workspace → Connections, then Your systems, and press Add a connection.
  2. Under Start from, choose the service, or My own system. Shopify, WooCommerce, Razorpay, HubSpot, Pipedrive, Zendesk, Airtable, Notion and Calendly are filled in for you: how the service signs in, where the key goes and a test address. Paste the key from your account with that service, and add your own address where it asks for one.
  3. For My own system, choose How it authenticates and fill in what your system's API documentation gives you.
  4. Press Save and check. Telybot asks your system whether it accepts the credential before anything is saved; a refused one is never stored.

The ways a system can sign in:

How it authenticatesWhat Telybot sends
API keyThe key in a header you name (X-Api-Key unless you say otherwise), or as a query parameter in the address
Bearer tokenAuthorization: Bearer and the token
User name and passwordBasic authentication
OAuth 2.0 clientA short-lived token from your token URL, renewed before it runs out
Token requestYour own login call, with the token read out of its answer and renewed
Sign-in (OAuth 2.0)A token from your own OAuth app, after someone on your team signs in once

Headers on every request. Some systems want more than the key on every call: an API version, an account or tenant id, or a key and a secret in two headers. Add them to the connection under Headers on every request and every action and webhook that uses it sends them. Values are stored encrypted and never shown again; leave one empty when you edit the connection and it keeps its value.

One connection per host. A connection is pinned to its system's Host, such as api.example.com, and its credential is sent there and nowhere else. *.example.com covers its subdomains. An action can use a connection only for an address on that host, and Workspace → Connections shows which actions and webhooks use each one. Two accounts of the same service, such as two shops, are two connections, each with its own key.

A system you sign in to

Some systems give you no fixed key: you register an app with them, and a person signs in to allow access. Choose Sign-in (OAuth 2.0) as the way it authenticates, and fill in what your system's documentation gives you: the authorization URL, the token URL, the client ID and secret, and the scope. Telybot asks the token URL whether it accepts the client ID and secret before anything is saved.

Once it is saved, Telybot shows the connection's own redirect URI. Register it in your system's app settings, then press Sign in. You sign in at your system and allow access, and you come back to the page you started from with the connection working. From then on Telybot keeps the access token renewed before it runs out, using the refresh token your system gave it, and keeps a refresh token your system replaces. If your system stops accepting the sign-in, the connection says Sign in again and the owners are emailed.

The sign-in belongs to the person who made it. If they leave your team, it goes with them, and someone else signs in again. Telybot sends PKCE with every sign-in; switch it off only if your system's documentation says it does not support it.

What your API receives

With GET, values you placed in the address are filled in and the rest are added to the query string:

GET https://api.yourshop.com/orders/48213?email=asha%40example.com

With POST, the values are the JSON body:

POST https://api.yourshop.com/lookup
Content-Type: application/json

{"order_id":"48213","email":"asha@example.com"}

Every request also carries your own headers and these:

HeaderWhat it is
webhook-idA unique id for this request
webhook-timestampWhen it was sent, in seconds
webhook-signatureThe signature — see below
X-TelyBot-BotYour bot's key (tb_live_…)
X-TelyBot-ActionThe action's key, such as order_status
X-TelyBot-ConversationThe chat it came from

What to send back

Reply within 8 seconds with JSON, or a short line of plain text.

  • 200 with the data — the bot answers from it. Keep it small and use clear field names: {"status":"shipped","eta":"2 October"} works better than internal codes.
  • 404 (or 410) when nothing matches — the bot tells the customer and asks them to check what they typed.
  • Anything else, or no reply in time — the bot apologises, offers your contact details, and the chat is flagged for you. The reason is shown under Actions → All actions.

Redirects are not followed, a response over 256 KB is not read, and a web page is never taken as an answer. If you listed fields under Only share these fields with the bot, reply with JSON: plain text then counts as a failed lookup, because there is nothing to pick the fields from.

Check the signature

Requests are signed the Standard Webhooks way, so you can use an existing library for your language: give it the secret as shown, whsec_ included. Your signing secret is on Your bot → Actions → Security, under Telybot’s signature.

By hand: join the webhook-id header, the webhook-timestamp header and the body exactly as it arrived, with a full stop between each. Sign that with HMAC-SHA256, using the part of the secret after whsec_, base64-decoded, as the key. The request is genuine when the result, base64-encoded, matches one of the signatures in webhook-signature (each starts v1,) and the timestamp is within five minutes of your clock.

const crypto = require('crypto');

// True when your bot signed this request in the last five minutes.
function isFromTelyBot(headers, rawBody, secret) {
  const id = headers['webhook-id'];
  const timestamp = Number(headers['webhook-timestamp']);
  const now = Math.floor(Date.now() / 1000);
  if (!id || !(Math.abs(now - timestamp) <= 300)) return false;
  const key = Buffer.from(secret.replace(/^whsec_/, ''), 'base64');
  const expected = crypto.createHmac('sha256', key)
    .update(`${id}.${headers['webhook-timestamp']}.`).update(rawBody).digest();
  return String(headers['webhook-signature'] || '').split(' ').some((part) => {
    const given = Buffer.from(part.replace(/^v1,/, ''), 'base64');
    return part.startsWith('v1,') && given.length === expected.length
      && crypto.timingSafeEqual(given, expected);
  });
}
import base64
import hashlib
import hmac
import time


def is_from_telybot(headers, raw_body: bytes, secret: str) -> bool:
    """True when your bot signed this request in the last five minutes."""
    msg_id = headers.get("webhook-id", "")
    timestamp = headers.get("webhook-timestamp", "")
    try:
        if not msg_id or abs(time.time() - int(timestamp)) > 300:
            return False
    except ValueError:
        return False
    key = base64.b64decode(secret.removeprefix("whsec_"))
    signed = f"{msg_id}.{timestamp}.".encode() + raw_body
    expected = base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest())
    return any(
        part.startswith("v1,") and hmac.compare_digest(part[3:].encode(), expected)
        for part in headers.get("webhook-signature", "").split()
    )
<?php
/** True when your bot signed this request in the last five minutes. */
function is_from_telybot(string $id, string $timestamp, string $signatures, string $rawBody, string $secret): bool
{
    if ($id === '' || !preg_match('/^\d{1,12}$/', $timestamp) || abs(time() - (int) $timestamp) > 300) {
        return false;
    }
    $key = base64_decode(preg_replace('/^whsec_/', '', $secret));
    $expected = base64_encode(hash_hmac('sha256', "$id.$timestamp.$rawBody", $key, true));
    foreach (explode(' ', $signatures) as $part) {
        if (str_starts_with($part, 'v1,') && hash_equals($expected, substr($part, 3))) {
            return true;
        }
    }
    return false;
}
import (
	"crypto/hmac"
	"crypto/sha256"
	"encoding/base64"
	"net/http"
	"strconv"
	"strings"
	"time"
)

// isFromTelyBot reports whether your bot signed this request in the last five minutes.
func isFromTelyBot(h http.Header, body []byte, secret string) bool {
	id, timestamp := h.Get("webhook-id"), h.Get("webhook-timestamp")
	sent, err := strconv.ParseInt(timestamp, 10, 64)
	now := time.Now().Unix()
	if id == "" || err != nil || sent < now-300 || sent > now+300 {
		return false
	}
	key, err := base64.StdEncoding.DecodeString(strings.TrimPrefix(secret, "whsec_"))
	if err != nil {
		return false
	}
	mac := hmac.New(sha256.New, key)
	mac.Write([]byte(id + "." + timestamp + "."))
	mac.Write(body)
	expected := mac.Sum(nil)
	for _, part := range strings.Fields(h.Get("webhook-signature")) {
		given, err := base64.StdEncoding.DecodeString(strings.TrimPrefix(part, "v1,"))
		if strings.HasPrefix(part, "v1,") && err == nil && hmac.Equal(given, expected) {
			return true
		}
	}
	return false
}
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.time.Instant;
import java.util.Base64;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

/** True when your bot signed this request in the last five minutes. */
static boolean isFromTelyBot(String id, String timestamp, String signatures, byte[] body, String secret)
        throws Exception {
    long now = Instant.now().getEpochSecond();
    long sent;
    try {
        sent = Long.parseLong(timestamp);
    } catch (NumberFormatException notANumber) {
        return false;
    }
    if (id == null || signatures == null || sent < now - 300 || sent > now + 300) return false;
    Mac mac = Mac.getInstance("HmacSHA256");
    mac.init(new SecretKeySpec(Base64.getDecoder().decode(secret.replaceFirst("^whsec_", "")), "HmacSHA256"));
    mac.update((id + "." + timestamp + ".").getBytes(StandardCharsets.UTF_8));
    byte[] expected = mac.doFinal(body);
    for (String part : signatures.split(" ")) {
        try {
            if (part.startsWith("v1,") && MessageDigest.isEqual(Base64.getDecoder().decode(part.substring(3)), expected)) {
                return true;
            }
        } catch (IllegalArgumentException notBase64) {
            // not a signature of ours
        }
    }
    return false;
}
using System.Security.Cryptography;
using System.Text;

// True when your bot signed this request in the last five minutes.
static bool IsFromTelyBot(IHeaderDictionary headers, byte[] body, string secret)
{
    string id = headers["webhook-id"].ToString(), timestamp = headers["webhook-timestamp"].ToString();
    long now = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
    if (id.Length == 0 || !long.TryParse(timestamp, out var sent) || sent < now - 300 || sent > now + 300) return false;
    var key = Convert.FromBase64String(secret.StartsWith("whsec_") ? secret[6..] : secret);
    var signed = Encoding.UTF8.GetBytes($"{id}.{timestamp}.").Concat(body).ToArray();
    var expected = HMACSHA256.HashData(key, signed);
    foreach (var part in headers["webhook-signature"].ToString().Split(' '))
    {
        var given = new byte[32];
        if (part.StartsWith("v1,") && Convert.TryFromBase64String(part[3..], given, out var length)
            && length == given.Length && CryptographicOperations.FixedTimeEquals(given, expected))
        {
            return true;
        }
    }
    return false;
}
require 'openssl'

# True when your bot signed this request in the last five minutes.
def from_telybot?(id, timestamp, signatures, raw_body, secret)
  return false if id.to_s.empty? || !timestamp.to_s.match?(/\A\d+\z/) || (Time.now.to_i - timestamp.to_i).abs > 300

  key = secret.delete_prefix('whsec_').unpack1('m')
  expected = [OpenSSL::HMAC.digest('SHA256', key, "#{id}.#{timestamp}.".b + raw_body.b)].pack('m0')
  signatures.to_s.split(' ').any? { |part| part.start_with?('v1,') && OpenSSL.secure_compare(part[3..], expected) }
end

Check the body before you parse it: JSON that has been read and written out again is spaced differently, and no longer matches. For a GET request the body is empty, so the signed text ends with a full stop. Use POST if you want the values themselves covered by the signature. The address and the other headers, X-TelyBot-User among them, are not part of what is signed.

A complete server, with an action and a webhook, is in Server examples for each of these languages.

How does the bot use an action?

  • It asks for anything that is missing, one short question at a time, and remembers what the customer said earlier in the chat.
  • It never guesses a value. If the customer did not type it, the bot asks.
  • One lookup per message. Your saved answers still come first, so a question you have answered by hand never calls your API.
  • Answers from a lookup are never reused for another customer.
  • A lookup counts as one answer, like any other reply the AI writes.

In Chats, an answer that came from a lookup says so underneath: which action ran and how it ended. The values the customer typed stay in the transcript and nowhere else.

Verified visitors

When a customer is signed in to your own website, your server can vouch for them, and the bot then knows who it is talking to: an action can look up their order without asking for a number, and the chat shows Verified with their id in your system.

  1. Open Your bot → Actions → Security and, under Verified visitors, press Show the secret and copy it. It starts with tbid_.
  2. On your server, when a signed-in customer opens a page with the chat, sign a token with it: a JWT, algorithm HS256, signed with the secret exactly as shown. Put the customer's id in your system in sub, as text (up to 128 characters), and the time it stops being valid in exp (an hour is plenty, thirty days at most). email, name and phone (with the country code, such as +91 98765 43210) are optional. A phone here tells the bot this is the same customer who writes to you on WhatsApp from that number.
  3. Hand it to the chat. Either set it before the chat script loads, with window.TelyBotSettings = { userToken: token } (and {} on pages where nobody is signed in), or call TelyBot.identify(token) once the chat has loaded. When the customer signs out, call TelyBot.identify('').
  4. In the action's address, write {{user_id}}, {{user_email}} or {{user_name}} where the value goes. The bot never asks for those. When a message arrives without a token that verifies, or the token lacks the value the action uses, the bot asks the customer to sign in instead. Every call for a verified customer also carries X-TelyBot-User with their id, percent-encoded.
  5. {{customer_phone}} and {{customer_email}} are the customer's own phone and email, on any channel, whenever something proves them: on WhatsApp, the number they write from; on your website, the phone and email in the token. Use them to look up a WhatsApp customer's order by their number. When there is no proof, the bot asks the customer to sign in instead.

Any JWT library works; here is the token in each language:

// npm install jsonwebtoken
const jwt = require('jsonwebtoken');

const telybotToken = jwt.sign(
  { sub: String(user.id), email: user.email, name: user.name },
  process.env.TELYBOT_IDENTITY_SECRET, // tbid_…, exactly as shown on Actions → Security
  { algorithm: 'HS256', expiresIn: '1h' },
);
// In the page, before the chat script (EJS):
// <script>window.TelyBotSettings = { userToken: "<%= telybotToken %>" };</script>
# pip install pyjwt
import os
from datetime import datetime, timedelta, timezone

import jwt

telybot_token = jwt.encode(
    {"sub": str(user.id), "email": user.email, "name": user.name,
     "exp": datetime.now(timezone.utc) + timedelta(hours=1)},
    os.environ["TELYBOT_IDENTITY_SECRET"],  # tbid_…, exactly as shown on Actions → Security
    algorithm="HS256",
)
# In the page, before the chat script (Jinja):
# <script>window.TelyBotSettings = { userToken: "{{ telybot_token }}" };</script>
<?php
// composer require firebase/php-jwt
use Firebase\JWT\JWT;

$telybotToken = JWT::encode(
    ['sub' => (string) $user->id, 'email' => $user->email, 'name' => $user->name, 'exp' => time() + 3600],
    getenv('TELYBOT_IDENTITY_SECRET'), // tbid_…, exactly as shown on Actions → Security
    'HS256',
);
?>
<script>window.TelyBotSettings = { userToken: "<?= htmlspecialchars($telybotToken) ?>" };</script>
// go get github.com/golang-jwt/jwt/v5
telybotToken, err := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
	"sub":   fmt.Sprint(user.ID),
	"email": user.Email,
	"name":  user.Name,
	"exp":   time.Now().Add(time.Hour).Unix(),
}).SignedString([]byte(os.Getenv("TELYBOT_IDENTITY_SECRET"))) // tbid_…, exactly as shown on Actions → Security
// In the page, before the chat script (html/template adds the quotes):
// <script>window.TelyBotSettings = { userToken: {{.TelyBotToken}} };</script>
// com.auth0:java-jwt
String telybotToken = JWT.create()
        .withSubject(String.valueOf(user.getId()))
        .withClaim("email", user.getEmail())
        .withClaim("name", user.getName())
        .withExpiresAt(Instant.now().plus(1, ChronoUnit.HOURS))
        .sign(Algorithm.HMAC256(System.getenv("TELYBOT_IDENTITY_SECRET"))); // tbid_…, exactly as shown on Actions → Security
// In the page, before the chat script (Thymeleaf):
// <script th:inline="javascript">window.TelyBotSettings = { userToken: [[${telybotToken}]] };</script>
// dotnet add package Microsoft.IdentityModel.JsonWebTokens
using System.Text;
using Microsoft.IdentityModel.JsonWebTokens;
using Microsoft.IdentityModel.Tokens;

var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(
    Environment.GetEnvironmentVariable("TELYBOT_IDENTITY_SECRET")!)); // tbid_…, exactly as shown on Actions → Security
string telybotToken = new JsonWebTokenHandler().CreateToken(new SecurityTokenDescriptor
{
    Claims = new Dictionary<string, object>
    {
        ["sub"] = user.Id.ToString(),
        ["email"] = user.Email,
        ["name"] = user.Name,
    },
    Expires = DateTime.UtcNow.AddHours(1),
    SigningCredentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha256),
});
// In the page, before the chat script (Razor):
// <script>window.TelyBotSettings = { userToken: "@telybotToken" };</script>
# gem install jwt
require 'jwt'

telybot_token = JWT.encode(
  { sub: user.id.to_s, email: user.email, name: user.name, exp: Time.now.to_i + 3600 },
  ENV.fetch('TELYBOT_IDENTITY_SECRET'), # tbid_…, exactly as shown on Actions → Security
  'HS256'
)
# In the page, before the chat script (ERB):
# <script>window.TelyBotSettings = { userToken: "<%= telybot_token %>" };</script>

Each message is checked on its own. A signed-in customer's chat goes on only while the page says who is signed in: a message that comes without a token starts a new chat, so the next person at the screen never continues the last one's. When a customer signs out, or a different one signs in, the chat, the orders the device was holding for them and their cart are cleared from it. A token that does not verify is ignored for that message, and the browser console says why once.

Make a new one on Security rotates the secret, and tokens signed with the old one keep working for 24 hours, so you can update your servers without signing anyone out. Replace it now is for a secret that may have leaked: the old one stops at once.

Webhooks

An action is your bot asking your system. A webhook is the other direction: when something happens in the chat, Telybot posts it to an address of yours — your CRM, your order system, a sheet — so your systems hear about it the moment it happens. Set them up under Your bot → Actions → Webhooks.

Each webhook has a name, an https:// address, the events it wants, and an on/off switch. If your receiver wants its own authentication, choose the connection for that same host under Authentication, or add one there, and its credential is sent with every delivery.

EventWhen it is sent
lead.createdA chat became a lead by finishing your welcome flow or asking to talk to a person. A lead your team marks by hand is not sent, and a booked meeting sends meeting.booked.
contact.requestedA visitor asked to be contacted, with their details.
order.created, order.updatedAn order was placed; its status changed: accepted, rejected, preparing, ready, out for delivery, completed or cancelled.
booking.created, booking.updatedA booking was requested; it was confirmed, declined, completed, marked missed or cancelled.
meeting.booked, meeting.updated, meeting.cancelledA meeting was booked or requested; it was confirmed, moved, completed or marked missed; it was cancelled by either side, or your team declined the request.
application.receivedSomeone applied for a job in the chat. The resume itself is never sent.

Every delivery is one POST with a JSON body:

{
  "id": "4f0c…",
  "type": "order.created",
  "created_at": "2026-10-25T10:14:03.511Z",
  "attempt": 1,
  "bot": "tb_live_…",
  "data": { "order_id": "…", "number": 1042, "status": "placed", "customer_name": "Asha", "total_minor": 149900 }
}

data is the record as your dashboard shows it — ids, status, the customer's details, the amounts, the times — never a resume, a file or a note your team wrote for itself. An update also says what the status was before. The body is signed the same way as an action's request (webhook-id, webhook-timestamp, webhook-signature, the secret from Your bot → Actions → Security), so the same check works. X-TelyBot-Event carries the event name, X-TelyBot-Webhook the webhook's id and X-TelyBot-Bot your bot's key. Answer with any 2xx within 10 seconds, and do slow work after answering.

If your receiver does not answer, or answers 5xx, 408, 425 or 429, Telybot tries again: after a minute, five, thirty, two hours, six and twelve — seven attempts over about a day, with the same id every time, so a receiver can drop a duplicate. Any other answer, a redirect or another 4xx, is taken as your receiver saying no: it is not retried, and the delivery fails straight away. A delivery that is retried fails only when its last attempt has failed. After fifty failed deliveries in a row the webhook is paused and the owners are emailed; Send a test event checks the receiver, Resume starts it again. The last hundred deliveries, with what the receiver answered, are listed under Deliveries for thirty days.

Send to Google Sheets

If you would rather see leads, orders, meetings and applications in a spreadsheet, press Connect Google Sheets under Your bot → Actions → Webhooks and sign in with Google. You come back to Webhooks with Send to Google Sheets open: pick the events and the time zone. Telybot makes a spreadsheet in your Google Drive with a tab for each kind of record, a header row in your dashboard's language, and a row for every event as it happens.

The spreadsheet is yours: rename it, move it, share it with your team. Telybot can open only the spreadsheets it makes for you, never your other files. A renamed tab keeps getting its rows, and a deleted one is put back with the next row. The spreadsheet lives in the Google Drive of the account that connected Google Sheets, and only that account can write to it, so connect one your business owns rather than a person's own. Everything a visitor typed is written as text, so nothing they type can run as a formula. A sheet is retried and paused the same way as any webhook, and counts as one of the bot's five. If Webhooks has no Connect Google Sheets button, add your own Google app on the Google Calendar card on Workspace → Connections, with the Google Sheets API switched on in it, and the button appears.

Limits

5 webhooks per bot (a Google Sheets spreadsheet counts as one), 7 attempts per delivery over about a day, 10 seconds per delivery.
8 actions per bot, 6 values and 8 headers per action, 8 seconds per call. One chat can run 6 lookups in ten minutes and one internet address 20 an hour; your API receives at most 120 calls a minute from your bot.

Actions read information. Do not point one at an address that changes something — cancelling an order or issuing a refund needs a confirmation step the bot does not have yet.

Next: Your menu or services →