AI agent and training

AckReply AI actions: let the AI look up orders and make changes through your API

Set up AI actions: connect your API, choose inputs, pick the fields the AI may see, test, sign logged-in visitors with an identity token, and read the logs.

16 min read
On this page
  1. What is an AI action?
  2. How do I create an AI action?
  3. How do I connect AckReply to my API (connections)?
  4. How do I set up the request?
  5. What are inputs, and where do their values come from?
  6. How do I test an action?
  7. How do I choose which response fields the AI sees?
  8. How do I tell the AI when to use an action?
  9. What is the identity token, and how do I make it?
  10. Why do write actions need a logged-in visitor?
  11. What must my API check (ownership)?
  12. What does the visitor see before a write action runs?
  13. What does the Security tab check?
  14. Where can I see what an action did (logs)?
  15. Limits for AI actions
  16. Common problems with AI actions
  17. Related articles

An AI action lets the AckReply AI call your own API during a chat. With a read action it can look things up, for example “where is my order NW-10391?”. With a write action it can change something, for example cancel an order. You set it up in AI Agent > Actions (https://app.ackreply.com/ai-agent/actions). For each action you choose the API it calls, the inputs it needs, the response fields the AI may see, and when the AI should use it.

AI actions are in early access and off by default. If AI Agent > Actions says “Actions are off for this workspace”, email support@ackreply.com to turn them on. You can build and test actions while they are off, but you can’t set them live. Only Owners and Admins can see the Actions page. Agents see the action lines in the inbox.

What is an AI action?

An action is one API call that the AI can choose to make. It has:

  • A request: method, URL, query params, headers and an optional JSON body, for example GET https://api.yourshop.com/v1/orders/{{order_id}}.
  • Inputs: the values the request needs, such as an order number. Each input has a source (see below).
  • Response fields: the parts of your API’s answer the AI may read. Nothing else reaches the AI.
  • Instructions: when the AI should use the action, in your own words.
  • An effect: Read (only looks things up) or Write (changes data). The effect is set from the method (GET is Read; POST, PUT, PATCH and DELETE are Write), and you can change it if your API uses POST for a lookup.

When a visitor asks something your action answers, the AI fills in the inputs, AckReply sends the request from its server, and the AI answers using the fields you picked. While a read action runs, the visitor sees your status text, such as “Checking your order…”. Write actions always show a confirm card first (see The confirm card).

A workspace can have up to 50 actions and 20 connections.

How do I create an AI action?

  1. Go to AI Agent > Actions and click New action.
  2. Choose Your API (call an existing API with a method, URL, headers and body). Custom endpoint (AckReply format) is only for endpoints built for the older AckReply format, where we POST a signed JSON envelope to an endpoint you built.
  3. Give it a name, such as “Check order status”. The name is shown to your team and in logs.
  4. Click Create draft. The editor opens with four tabs: API, Data, AI behaviour and Security.
  5. Fill in each tab, click Save, then Set live when the Security tab has no issues to fix.

A new action is a draft: the AI never sees it until you click Set live. You can Pause a live action at any time. Saving a live action keeps it live, and your changes apply from the next chat.

How do I connect AckReply to my API (connections)?

A connection is a saved login for your API. Keys are stored encrypted and can’t be viewed again after you save them, only replaced. Create one under AI Agent > Actions > Connections > New connection:

FieldWhat to enter
NameAny name, such as “Shop API”.
TypeBearer token (sends Authorization: Bearer <token>), API key in a header (you pick the header name, such as X-Api-Key), or Username and password (Basic).
HostThe API’s host name only, such as api.yourshop.com, without https:// or a path. A port is optional (api.yourshop.com:8443).
Token / API key / PasswordPaste it once.

The key is only ever sent to that one host, over https. An action that uses the connection must call exactly that host, and AckReply checks this again on every call. If you change a connection’s host or header name, you must enter the key again, so a saved key is never sent somewhere new.

On the action’s API tab, pick the connection under Connection. Choose No connection (public API) if your API needs no key.

Never put a key in the URL, a query param or a header on the action. AckReply refuses headers that look like credentials (and an Authorization header) and asks you to save them as a connection.

How do I set up the request?

On the API tab:

  • Method and URL. The URL must use https. Put inputs in the path with double braces, for example https://api.yourshop.com/v1/orders/{{order_id}}, or use Insert input. Inputs can go in the path, not in the host. Values in the path are encoded, so a visitor can’t add extra path parts.
  • Query params, Headers and Body (for POST, PUT, PATCH and DELETE). The body is JSON. Put inputs in quotes, like "{{qty}}": a number or yes/no input is sent as a number or true/false.
  • Timeout: 1 to 15 seconds (default 8). Visitors wait while the action runs.

The Request preview shows the exact URL with your test values, and the auth header masked.

AckReply does not follow redirects, and it only reads JSON responses up to 256 KB.

What are inputs, and where do their values come from?

Inputs are the values an action needs. Each input has a name (lowercase letters, numbers and _, such as order_id), a type (Text, Whole number, Decimal, Yes/No or One of a list), and a Source. There are three sources:

SourceWhere the value comes fromUse it for
AI asks the visitorThe AI takes it from the chat, or asks the visitor for it.Order numbers, tracking numbers, a reason for cancelling.
From the logged-in visitorYour signed identity token (user_id). The AI cannot see or change it.The customer’s own id, so a visitor can only reach their own records.
Fixed valueThe same value on every call.Settings like include=items or channel=ackreply.

For inputs the AI fills in, write a clear Description. The AI reads it to know what to ask for, for example “The order number, starts with NW- followed by 5 digits. It is on the invoice email.” You can add a Format check (a pattern such as ^NW-\d{5}$). A value that does not match is refused before anything is sent.

When an input uses From the logged-in visitor, the action is only offered to logged-in visitors, and its Audience is locked to Logged-in visitors. Today the only value available from the logged-in visitor is user_id.

Never ask the AI for a customer id. A visitor can type anyone’s id into the chat. On a write action, AckReply blocks an input named like a customer id (customer_id, user_id, account_id, member_id) with the source AI asks the visitor.

The AI never handles passwords, tokens or keys. Inputs with names like password or api_key are refused: put credentials in a connection.

How do I test an action?

On the Data tab, under Test response:

  • Test live sends a real request with the test values you enter.
  • Paste sample lets you paste a JSON response if your API is not ready yet. You still need a live test before setting the action live.

If an input uses the logged-in visitor, enter a customer id under Test as this logged-in customer. The test sends that id as if the customer were logged in, so use a test account.

A live test of a write action asks first (“This sends a real POST to …”), because your system may really change data. Every test request carries the header X-AckReply-Test: 1, so your API can tell tests apart.

If the test fails, you get a plain reason, for example:

  • “Your API answered 401. Check the connection’s key.”
  • “Timed out after 8 s.”
  • “The response is not JSON (text/html). Actions read JSON only.”
  • “The response is over 256 KB.”
  • “Your API redirected to another address. Redirects are not followed.”

How do I choose which response fields the AI sees?

After a test, Fields the AI can see lists every field in the response with its type and an example value. Tick the fields the AI may read. Everything you don’t tick is removed before the AI sees the response, so pick only what it needs to answer, such as data.status and data.items[].name.

  • Fields with secret-like names (password, token, card, cvv, secret, api_key, pin, otp) are greyed out and can never be picked. They are “Never sent to the AI”.
  • Fields that look like personal data (phone, email, address, NIK, NPWP, birth date) get a Personal data tag. You can pick them, but the AI may repeat them in the chat.
  • Lists (items[]) send up to 50 items.
  • What the AI receives shows the exact data the AI gets, up to 16 KB.

You must pick at least one field before you can set an action live.

How do I tell the AI when to use an action?

On the AI behaviour tab:

  • Instructions: when the AI should run the action, for example “Use when the visitor asks where their order is or what its status is. Ask for the order number if they have not given it.” Clear instructions matter: the AI decides from this text.
  • Status text: shown in the chat while the action runs, such as “Checking your order…”.
  • Run in the background (read actions only): no status line in the chat, but the AI still uses the result.
  • Ask the visitor to confirm: shows the confirm card before the action runs. It is on by default for write actions.
  • Confirm card text: the question on the card, such as Cancel order {order_id}?. Inputs in single braces are filled in.
  • Audience: Everyone (any visitor, logged in or not) or Logged-in visitors (visitors your site identified with a signed token).

If your shop gives order details only to the person who placed the order, use Logged-in visitors and an input From the logged-in visitor.

What is the identity token, and how do I make it?

The identity token tells AckReply, in a way a visitor can’t fake, which of your customers is chatting. It is a short string your server makes on each page load, signed with your workspace’s identity secret, that expires after at most 24 hours. If a token leaks, it stops working within a day.

It builds on identity verification:

WhatWhat it doesNeeded for
user_hash (HMAC of user_id, never expires)Verifies who the visitor is.Read actions for Logged-in visitors.
identity_token (signed, expires within 24 hours)Verifies who the visitor is, with an expiry.Every write action, as well as user_hash.

Set it up in Settings > Widget > Members’ names > Verify members > Set up verification. Step 1 creates the identity secret. Keep the secret on your server: never send it to the browser.

The token is base64url(JSON) + "." + base64url(HMAC-SHA256(secret, base64url(JSON))), without = padding. The JSON is {"user_id": "...", "exp": <unix seconds>}. user_id is the same string you pass to the widget, and exp is at most 24 hours ahead.

Node.js

// Server side only. Make a new token on each page load.
import { createHmac } from "node:crypto";

function ackreplyIdentityToken(userId, secret, ttlSeconds = 3600) {
  // ttlSeconds: at most 86400 (24 hours)
  const json = JSON.stringify({
    user_id: String(userId), // the same user_id the page sends
    exp: Math.floor(Date.now() / 1000) + ttlSeconds,
  });
  const payload = Buffer.from(json).toString("base64url");
  const sig = createHmac("sha256", secret).update(payload).digest("base64url");
  return `${payload}.${sig}`;
}

const identityToken = ackreplyIdentityToken(member.id, process.env.ACKREPLY_IDENTITY_SECRET);

PHP

<?php
// Server side only. Make a new token on each page load.
function ackreply_identity_token(string $userId, string $secret, int $ttlSeconds = 3600): string {
    // $ttlSeconds: at most 86400 (24 hours)
    $b64 = fn (string $s): string => rtrim(strtr(base64_encode($s), '+/', '-_'), '=');
    $payload = $b64(json_encode(['user_id' => $userId, 'exp' => time() + $ttlSeconds]));
    $sig = $b64(hash_hmac('sha256', $payload, $secret, true));
    return $payload . '.' . $sig;
}

$identityToken = ackreply_identity_token((string) $member->id, getenv('ACKREPLY_IDENTITY_SECRET'));

Python

# Server side only. Make a new token on each page load.
import base64, hashlib, hmac, json, os, time

def ackreply_identity_token(user_id: str, secret: str, ttl_seconds: int = 3600) -> str:
    # ttl_seconds: at most 86400 (24 hours)
    b64 = lambda b: base64.urlsafe_b64encode(b).rstrip(b"=").decode()
    body = json.dumps({"user_id": str(user_id), "exp": int(time.time()) + ttl_seconds},
                      separators=(",", ":"))
    payload = b64(body.encode())
    sig = b64(hmac.new(secret.encode(), payload.encode(), hashlib.sha256).digest())
    return f"{payload}.{sig}"

identity_token = ackreply_identity_token(member.id, os.environ["ACKREPLY_IDENTITY_SECRET"])

Then pass the token to the widget on pages where the customer is logged in, next to user_hash. Keep this script above the AckReply script tag:

<script>
  window.AckReplySettings = {
    user: { user_id: "MEMBER_ID", name: "MEMBER_NAME" },
    user_hash: "HASH_FROM_SERVER",
    identity_token: "TOKEN_FROM_SERVER"
  };
</script>
<script src="https://app.ackreply.com/widget/loader.js" data-workspace-id="YOUR_WORKSPACE_ID" async></script>

In a single-page app, pass it as the third argument after login, and call AckReply.logout() when the customer logs out:

AckReply.identify({ user_id: "MEMBER_ID", name: "MEMBER_NAME" }, "HASH_FROM_SERVER", "TOKEN_FROM_SERVER");

If the token is wrong, AckReply rejects it: “invalid_identity_token_signature”, “identity_token_expired”, or “identity_token_lifetime_too_long” (more than 24 hours). When a token expires during a chat, a waiting confirm card asks the visitor to log in again.

Why do write actions need a logged-in visitor?

Anyone can open your chat and type anything. If a write action were open to everyone, a stranger could ask the AI to cancel someone else’s order, and the AI can be talked into things. So AckReply runs write actions only for a visitor who is logged in with a valid identity token:

  • A write action set to Everyone can’t be set live. The Security tab shows “Write action open to everyone” and asks you to choose Logged-in visitors.
  • The AI is not offered a write action at all in a chat without a verified visitor and an unexpired token. AckReply checks this again when the visitor taps the confirm button.
  • Write actions are never retried automatically. Each write request carries an Idempotency-Key header, so your API can ignore a duplicate.

Read actions can be open to Everyone, which suits public lookups like stock levels or shipping rates. Anything that shows one customer’s data should be set to Logged-in visitors.

What must my API check (ownership)?

AckReply sends the logged-in customer’s id, signed so a visitor can’t fake it. But only your API knows who owns an order. Your API must check that the record belongs to this customer, and refuse anything else.

For example, with the URL https://api.yourshop.com/v1/orders/{{order_id}}?customer={{customer_id}}, where order_id comes from the AI and customer_id comes from the logged-in visitor:

  • Look the order up for that customer only: WHERE number = :order_id AND customer_id = :customer_id.
  • If customer 8812 asks for someone else’s order, answer 404, the same as for an order that doesn’t exist. Then nobody can learn whether another customer’s order exists.
  • Do the same check on every write: cancel, change address, and so on.

Without this check, a logged-in visitor could still type someone else’s order number and see or change it. The Security tab shows this reminder on every action for logged-in visitors.

What does the visitor see before a write action runs?

When the AI wants to run an action with Ask the visitor to confirm on, the visitor sees a card in the chat instead of the action running straight away:

  • Your Confirm card text, such as “Cancel order NW-10391?”, and the inputs you marked Show on confirm card.
  • Two buttons: one named after your action, such as Cancel order (or Confirm when the action’s name is longer than 20 characters), and Not now. The first button uses your widget colour.
  • “Nothing changes until you confirm.” and a small timer: the card waits 5 minutes.

Nothing is sent to your API until the visitor taps the action button. After that the card shows “Working on it…”, then Done, or “That didn’t work. Our team can help.” If the visitor taps Not now or lets the card time out, it says nothing was changed. Only the visitor can confirm. Your team never sees a confirm button.

You can turn Ask the visitor to confirm off for a write action, but AckReply warns you first: the AI would run it as soon as it decides to, and a visitor can talk the AI into running it. Only do this if your API checks everything itself and the change is easy to undo. Your team sees a “ran without confirm” tag on those calls.

What does the Security tab check?

AckReply checks each action’s setup every time you save. The Security tab lists:

  • Blockers, which stop the action going live. Examples: a URL that isn’t https, a key in the URL, a write action open to everyone, a write action that asks the AI for a customer id, no response fields picked, or an input from the logged-in visitor when identity verification is not set up.
  • Warnings, which you can accept one by one with I understand when you click Set live. Examples: confirm turned off on a write action, a read action that asks the AI for a customer id, personal data fields shown to everyone, or no successful live test yet.
  • Notes, such as the ownership reminder above.

When nothing needs fixing, it says “Safety check: All clear”.

Where can I see what an action did (logs)?

  • In the inbox, each call shows as a line in the conversation, visible to your team only, for example AI ran "Check order status" · Succeeded · 412 ms · View log. Expand it to see the inputs and the fields the AI saw.
  • In the action’s logs, open View logs from the action’s menu on the Actions list. Logs lists every call with its time, result (Succeeded, Failed, Waiting for visitor, Declined, Expired or Outcome unknown), HTTP status, time taken and chat. Filter by date, status or chat id. Click a call to see the source chat (Open chat), the visitor, the inputs and where each came from, the request (keys shown as [connection secret]), your API’s response, and what the AI received. Health shows success rate and speed.
  • On the Actions list, each action shows its success rate and call count for the last 7 days, typical time, health and safety status.

Call details (request, response and what the AI received) are kept for 14 days. After that, the call stays in the list with its status, code and time.

“Outcome unknown” means a write request reached your API but no answer came back in time. AckReply doesn’t retry it, and the AI tells the visitor your team will check. Look the call up in your own system.

Limits for AI actions

LimitValue
Actions per workspace50
Connections per workspace20
Timeout per call1 to 15 seconds (default 8)
Response size AckReply reads256 KB, JSON only
Data the AI receives16 KB, lists up to 50 items
Confirm cardanswer within 5 minutes
Identity token lifetimeat most 24 hours
Calls per conversation20 per hour, of which 3 writes
Writes per visitor5 per hour
Calls per API host120 per minute
Dashboard tests30 per 10 minutes
Call details in logs14 days

Common problems with AI actions

  • The AI never uses the action. Check it is Live, not a draft or paused. Make the Instructions say plainly when to use it. Actions for Logged-in visitors are only offered when the visitor is verified, and write actions also need a valid identity_token.
  • The AI answers from earlier in the chat instead of calling again. Add to the instructions: “Always run this action again for the latest status. Don’t answer from earlier messages.”
  • Test says 401 or 403. The connection’s key is wrong or has expired. Click Replace key on the connection.
  • “The host must be …” The URL’s host must match the connection’s host exactly.
  • A logged-in customer sees “Please log in again to continue”. Their identity token expired. Make a new token on each page load.
  • A customer sees someone else’s data. Your API is not checking ownership. See What must my API check.

Was this article helpful?