Skip to content
engage-ai

Guides

How replies work

The eight steps from an inbound message to a sent, held or escalated reply, and the rules that decide which.

engage-ai answers only from your own data, and it knows when it does not know. This page follows one customer message from the moment it arrives to the moment a reply leaves, or a person is asked to step in.

The pipeline

  customer sends a message
          │
          ▼
  ① RECEIVE      verify the provider's signature, store the raw event, return 200 in <50 ms
          │      a redelivery of the same event does nothing
          ▼
  ② IDENTIFY     resolve the sender to a contact (created on first contact),
          │      find or open their conversation, normalise the message
          ▼
  ③ SHOULD WE?   automation off? conversation closed? a person already replied?
          │      → stop here, with the reason recorded
          ▼
  ④ RETRIEVE     hybrid search over this organization's catalogue and knowledge:
          │      embeddings for meaning, trigrams for SKUs and order numbers
          ▼
  ⑤ DRAFT        the model gets the persona, the guardrails, the retrieved facts
          │      and the recent conversation, and returns a reply, a confidence
          │      score, an intent and citations
          ▼
  ⑥ CHECK        guardrails in code: banned phrases, price quotes, commitments,
          │      disclaimers, length. A confident answer citing nothing is blocked.
          ▼
  ⑦ DECIDE       ┌── the model asked for a person?  → escalate
                 ├── a complaint or a refund?       → escalate
                 ├── below the confidence bar?      → escalate
                 ├── channel in review mode?        → hold as a draft
                 └── otherwise                      → send
          │
          ▼
  ⑧ DELIVER      respect the platform's rate limit and reply window, send,
                 and record every attempt with its latency and result

Steps ② to ⑧ run on durable queues. Platforms disable webhooks that answer slowly (Meta allows around 20 seconds), so the HTTP endpoint only verifies, stores and acknowledges. Everything expensive happens afterwards, where it can be retried and rate limited.

Retrieval

The AI only knows what retrieval hands it. Retrieval combines two searches:

  • Semantic search with embeddings, which matches meaning. "Can I send these back?" finds the returns policy.
  • Lexical search with trigrams, which matches spelling. BOOT-TRL-9 or an order number pasted verbatim finds the exact record.

Results that both searches find rank highest. Products and knowledge documents are searched together as one collection.

To see exactly what retrieval returns for a question, call POST /knowledge/preview. It is the best tool for answering "why did it say that?" and "why didn't it know that?".

The draft

The model returns structured fields, not free text:

FieldMeaning
replyThe text it would send.
confidenceA score from 0 to 1.
intentWhat the customer wants: PRODUCT_INQUIRY, PRICING, AVAILABILITY, ORDER_STATUS, SHIPPING, RETURNS_REFUND, COMPLAINT, TECHNICAL_SUPPORT, GREETING, SMALL_TALK, SPAM or OTHER.
needs a personThe model's own request to hand over.
citationsThe knowledge chunks the reply is based on.

Because confidence and the hand-over flag are fields, the rules below can act on them reliably.

Guardrails

Prompt instructions shape what the model does, but they do not guarantee it. After the model replies, these checks run in code:

  • Banned topics and phrases. Anything the business never wants said.
  • Price quotes. If the agent profile does not allow quoting prices, a reply that contains one is blocked.
  • Commitments. Promises such as delivery dates or refunds are blocked unless allowed.
  • Required disclaimers. Added or enforced where the business requires them.
  • Length. Kept within the platform's limit, such as 4,096 characters on WhatsApp.
  • Grounding. A confident reply that cites nothing is treated as a hallucination and blocked.

A blocked reply is never sent. The conversation goes to a person instead.

The decision

Four rules decide what happens to a draft. They are checked in this order, and the first one that applies wins:

  1. The model asked for a person → escalate. This always wins.
  2. The intent is COMPLAINT or RETURNS_REFUND → escalate, however confident the model is. A confidently wrong refund promise costs more than a short wait.
  3. Confidence is below the organization's threshold → escalate.
  4. The channel is in review mode → hold the draft for a person to approve.

Otherwise the reply is sent.

Escalate sets the conversation to AWAITING_HUMAN, so it appears in the agent worklist. Depending on the agent profile, the customer may also get a short holding message, such as "let me get a colleague to confirm that for you".

Hold stores the reply as a message with status DRAFT and leaves the conversation's status unchanged. Nothing is sent until a person approves it. Both cases are handled in the inbox.

Reply modes

Each channel connection has an autoReplyMode:

ModeWhat happens
OFFNo AI replies on this channel.
SUGGESTThe AI drafts every reply and a person approves it. New connections start here.
AUTO_WITH_THRESHOLDReplies above the confidence threshold are sent; the rest go to a person.
AUTOReplies are sent unless one of the escalation rules applies.

Starting in SUGGEST lets a business review every draft and loosen control once it trusts the replies. The mode is returned on GET /channels/connections. It cannot yet be changed through the public API.

A person is never talked over

As soon as a person replies in a conversation, automation stops for that conversation. The check runs again just before a reply is generated, because a queued job may wait behind others, and in that time a person may have taken over.

Every decision is recorded

There is no path where a customer message is dropped without a stored reason. For every message the system records whether it replied, why or why not, which knowledge chunks the reply was based on, and each delivery attempt. When a person edits a draft before approving it, the edit is stored next to the original.

A worked example

Customer, 11:40pm on WhatsApp: "do the trailhead boots come in a UK 11?"

  1. The signature checks out against the connection's secret. The raw event is stored and Meta gets 200 in 40 ms.
  2. +44 7700 900123 resolves to Jamie Chen, who last wrote three weeks ago. Their conversation reopens.
  3. Automation is on for this channel and no person is handling the thread.
  4. Retrieval returns the Trailhead Mid GTX product: matched on the name by spelling and on "boots / sizes" by meaning.
  5. The model reads "Sizes: UK 4-13", replies "Yes, the Trailhead Mid GTX goes up to a UK 13, so an 11 is in the range.", scores itself 0.91 and cites the product.
  6. Guardrails pass: no price, no commitment, under the length limit, and a real citation.
  7. 0.91 clears the 0.75 threshold, the intent is AVAILABILITY, and the channel is on auto. Send.
  8. Delivered. Jamie has an answer before midnight.

Change one thing. The customer asks "can I get a refund on boots I've already worn?". Step ⑦ escalates no matter how confident the model is. A person sees it first thing in the morning, with the whole thread already there.