> Markdown rendition of https://typeglish.dev/blog/build-callback-agent ("Building a callback-booking agent, prompt-first - Tidelines"). Canonical page: https://typeglish.dev/blog/build-callback-agent · All pages: https://typeglish.dev/llms.txt

[← Tidelines](https://typeglish.dev/blog)/ Guides Nov 9, 2026

# Building a callback-booking agent, prompt-first

A callback looks like the easy way out of a long queue. The brief for it asks the agent to judge a wait it cannot see, keep to hours it cannot check, and enforce a limit that the first missed call breaks.

by **TypeGlish team** 8 min read #guides

The queue knows the wait. The prompt does not.

**TL;DR** Give a callback agent tools for the open windows, the booking, the cancellation and a priority transfer, keep the wait, the hours and the one-per-customer limit inside them, and write the six rules that stay as one checkable line each.

Larkfield Fibre is a broadband provider with a phone team that runs a callback queue. On a bad evening the chat fills with customers who want a person, and the contact-centre lead wants the assistant, Juno, to book them a callback instead of leaving them in a queue. The brief arrived as seven lines, which is the callback page of the team wiki. Here it is as a prompt, then as a spec.

## §1 The brief, checked as written

brief.tg - the seven lines as sent ✓ 0 error

```typeglish
# Role
You are Juno, the chat assistant for Larkfield Fibre, a broadband provider.

# Callbacks
- Offer a callback if the wait is long.
- Callbacks run 8am to 8pm, Monday to Saturday.
- Get the customer's phone number and read it back.
- Tell the customer when we'll call.
- Only one callback per customer.
- Customers with a personal alarm on their line shouldn't wait for a callback, put them straight through.
- Customers can cancel or move their callback any time.
```

tg check and score (excerpt) - brief.tg ✓ C (71/100)

```
$ typeglish check brief.tg
✓ 1 file — 0 error, 0 warning, 9 info

$ typeglish score brief.tg
brief.tg — C (71/100)  proven errors: none  tiers: base+z3
  rules   0 of 7 rule-shaped lines read
    L5   ✗ invisible     Offer a callback if the wait is long.
    L6   ✗ invisible     Callbacks run 8am to 8pm, Monday to Saturday.
    L7   ✗ invisible     Get the customer's phone number and read it back.
    L8   ✗ invisible     Tell the customer when we'll call.
    L9   ✗ invisible     Only one callback per customer.
    L10  ✗ invisible     Customers with a personal alarm on their line shouldn't wait for a callback, put them straight t
    L11  ✗ invisible     Customers can cancel or move their callback any time.
```

Zero of seven lines read as rules. Line 5 stops being read at *if*, line 8 at *when*, and the rest have no modal and no verb the checker knows at the head.

No errors and a C, which sounds fine until you see the rules line: the checker read nothing it could hold Juno to. That is normal for a wiki page. It was written for phone agents who can see the queue board, the clock and the customer’s account. Juno can see the chat. The work is sorting each line into a rule Juno can follow, or a job for the system that already knows the answer.

## §2 One callback, and then a second

Line 9 is the first to grow an exception. Give it a modal and it reads well: never book a second callback. Then the phone team misses a call, because the customer was on the train when it rang, and the team lead asks for the obvious patch:

once.tg - the limit, and the patch for a missed call ✗ logic/contradiction

```typeglish
# Role
You are Juno, the chat assistant for Larkfield Fibre, a broadband provider.

# Callbacks
- NEVER book a second callback for the customer.
- WHEN the customer missed their callback THEN MUST book a second callback for the customer.
```

tg check - once.tg ✗ 2 error

```
$ typeglish check once.tg
once.tg:5:1  error  logic/contradiction  Conflicts with line 6. Logical conflict — "book a second callback for the customer" is both required and forbidden. Keep one, or scope the two rules so they cannot both apply (IF <condition> THEN ...).
         ↳ line 6: - WHEN the customer missed their callback THEN MUST book a second callback for the customer.
once.tg:6:1  error  logic/contradiction  Conflicts with line 5. Logical conflict — "book a second callback for the customer" is both required and forbidden. Keep one, or scope the two rules so they cannot both apply (IF <condition> THEN ...).
         ↳ line 5: - NEVER book a second callback for the customer.

✗ 1 file — 2 error, 0 warning, 0 info
```

An unconditional ban covers the customer who missed their call, so the two lines cannot both hold. `typeglish build once.tg` refuses and writes nothing.

The checker offers two exits, and scoping the ban is the tempting one. But the conflict is telling you something about the policy, not the grammar. The team never meant *one callback, ever*. It meant *one open callback at a time*, so a customer cannot sit in the queue three times. A missed call is closed, so booking another is not a second open one.

Juno cannot see which callbacks are open. The callback system can. So the limit leaves the prompt and goes into the `book_callback` tool: if the customer already has an open callback, it moves that one instead of adding another. The prompt has no ban to contradict, the missed call needs no patch, and line 11’s *move their callback* comes free with the same tool.

## §3 Long for whom?

Line 5 asks Juno to offer a callback if the wait is long, and line 6 gives the hours. Neither is something Juno can know. It has no view of the queue and no clock it can trust, and the brief leaves out the case the phone team handles every few weeks: during an area outage, callbacks are paused, because every customer in the postcode wants one and the answer for all of them is the outage page. Write both as rules and you get this:

wait.tg - the wait threshold, and the outage pause ✓ 0 error

```typeglish
# Role
You are Juno, the chat assistant for Larkfield Fibre, a broadband provider.

# Callbacks
- WHEN the estimated wait is more than 10 minutes THEN MUST offer a callback.
- WHEN the customer's area has a known outage THEN NEVER offer a callback.
```

tg check and score - wait.tg ✓ B (87/100)

```
$ typeglish check wait.tg
✓ 1 file — 0 error, 0 warning, 0 info

$ typeglish score wait.tg
wait.tg — B (87/100)  proven errors: none  tiers: base+z3
  planes  runtime 99 (what the model reads) · hygiene 50 (source only)
  facets  enforceability 100 x.21 · hardness 100 x.12 · directness 90 x.08 · consistency 100 x.17 · structure 100 x.12 (hygiene) · annotation 0 x.12 (hygiene) · style 100 x.08 · security 100 x.08
  lever   annotation 0/100 (up to +12 overall) — 3 statements without a @@ note (L2 L5 L6) — put a "@@ why" line directly above each
  rules   2 of 2 rule-shaped lines read
```

Both rules read, both are hard, and they check clean: each sits behind its own condition, and nothing in the prompt says the two conditions can be true together. In an outage they almost always are, because an outage is what makes the wait long.

And look at what the prompt now holds: a number that belongs to the queue system, an outage rule that only works if Juno has heard about the outage, and two triggers that fire on the same message at the worst possible time. The checker compares what the prompt says. It cannot know that your queue and your network fail together.

So the policy moves into one tool. `find_callback_slots` asks the queue system for open windows on the customer’s account. The system applies the hours, the wait threshold and any outage pause, and returns either a list of 30-minute windows or an empty list. Juno’s rule is one line: when the customer asks to speak to a person, call it. If the list is empty, there is nothing to offer, and no rule has to say so. A proactive outage message is its own job, built in [Building a proactive outage agent, prompt-first](https://typeglish.dev/blog/build-outage-agent).

## §4 The number, the time, and the alarm

The last four lines each need one rule, and one of them needs a test more than it needs a rule:

- **The phone number.** Line 7 joins two actions with *and*, and *get* is not a verb the checker reads. Juno asks for a number anyway when it books, so only the read-back needs a rule: when the customer gives a phone number, repeat their phone number to the customer. One wrong digit and the call goes to a stranger. [How to write read-back rules for a voice agent](https://typeglish.dev/blog/voice-agent-read-back) covers the spoken version, where it matters even more.

- **When we’ll call.** Line 8 is in the first person, and *we* is the phone team, not Juno. The honest answer is a window, since a callback team works a queue. One rule: describe every callback time as a window. A test fails any reply that says *at 2pm*.

- **The personal alarm.** Line 10 is the line that matters most. A customer whose line carries a personal alarm, the kind an older relative presses after a fall, may have no other way to call for help while the line is down. They do not wait for a callback. A `transfer_priority` tool puts them through now, and the rule is to call it whenever the customer says there is an alarm on their line.

- **Cancel.** Line 11 is two actions, and `book_callback` already moves. A `cancel_callback` tool frees the window for somebody else.

The alarm customer is also the case §3 warned about. *Can you call me back tonight?* asks for a person and mentions an alarm in the same message, so two rules fire at once, and the checker will not tell you which one wins. A test will.

## §5 The spec, checked and tested

juno.tg - four tools, six rules, five cases ✓ A (99/100)

```typeglish
$TOOL find_callback_slots
  - description:: Look up the open callback windows for the customer's account. Returns a list of 30-minute windows, or an empty list when callbacks are paused, for example during an outage in the customer's area.
  - input::
    - account_id:: string: the customer's account number.

$TOOL book_callback
  - description:: Book a callback in one of the windows from find_callback_slots. If the customer already has an open callback, it moves that one instead of adding a second.
  - input::
    - account_id:: string: the customer's account number.
    - window_start:: string: the start of the chosen window, as returned by find_callback_slots.
    - phone_number:: string: the number to call, as confirmed by the customer.

$TOOL cancel_callback
  - description:: Cancel the customer's open callback.
  - input::
    - account_id:: string: the customer's account number.

$TOOL transfer_priority
  - description:: Put the customer through to the priority team now, without a callback.
  - input::
    - account_id:: string: the customer's account number.

# Role
@@ role: one sentence names the speaker, so every later "you" is Juno
You are Juno, the chat assistant for Larkfield Fibre, a broadband provider.

# Callbacks
@@ slots: the queue system knows the wait, the hours and any outage pause; the chat knows none of them
- WHEN the customer asks to speak to a person THEN MUST call @[find_callback_slots].
@@ windows: a callback is a window, so a promise of a minute is a promise the team cannot keep
- MUST describe every callback time as a window.
@@ number: a mistyped digit sends the callback to a stranger
- WHEN the customer gives a phone number THEN MUST repeat their phone number to the customer.
@@ booking: the booking tool moves an open callback, so the one-per-customer limit lives there
- WHEN the customer chooses a callback window THEN MUST call @[book_callback].
@@ alarm: a personal alarm on the line means the customer may have no other way to call for help
- WHEN the customer has a personal alarm on their line THEN MUST call @[transfer_priority].
@@ cancel: cancelling frees the window for someone else
- WHEN the customer asks to cancel their callback THEN MUST call @[cancel_callback].

$TEST asks_for_person
  - input:: I've been in the queue for ages, can someone just ring me back? Account LF-204417.
  - expect::
    - calls find_callback_slots
    - offers only windows the tool returned

$TEST exact_time
  - input:: What time exactly will you call me? I need to know so I can step out of a meeting.
  - expect::
    - describes the callback time as a window
    - matches /^(?![\s\S]*\bat \d{1,2}(?::\d{2})?\s*(?:am|pm)\b)/i

$TEST confirms_number
  - input:: Book me the 2pm window please, my number is 07700 900461.
  - expect::
    - repeats their phone number to the customer
    - contains "07700 900461"
    - calls book_callback

$TEST personal_alarm
  - input:: My mum has a care alarm on this line and it's been dead since this morning, can you call me back tonight?
  - expect::
    - calls transfer_priority
    - does not offer a callback window

$TEST cancel
  - input:: I fixed it myself, you can cancel my callback. LF-204417.
  - expect::
    - calls cancel_callback
```

The `exact_time` regex fails any reply that names a single clock time after *at*, so *at 2pm* fails and *between 2pm and 2:30pm* passes. `personal_alarm` is the message where two triggers fire; the test says the transfer wins. The phone number is from the UK range reserved for drama, so it rings nobody.

tg check, score, test --dry and build - juno.tg ✓ A (99/100)

```
$ typeglish check juno.tg
✓ 1 file — 0 error, 0 warning, 0 info

$ typeglish score juno.tg
juno.tg — A (99/100)  proven errors: none  tiers: base+z3
  planes  runtime 98 (what the model reads) · hygiene 100 (source only)
  facets  enforceability 100 x.21 · hardness 100 x.12 · directness 84 x.08 · consistency 100 x.17 · structure 100 x.12 (hygiene) · annotation 100 x.12 (hygiene) · style 100 x.08 · security 100 x.08
  lever   directness 84/100 (up to +1 overall) — Use the imperative or a named doer ("Verify the order.", "You must ..."), keep the active voice (not "is verified" / "a review must take place"), and make every it/this point at something the prompt introduced.
  rules   6 of 6 rule-shaped lines read · 6/6 covered by $TEST

$ typeglish test juno.tg --dry
✓ juno.tg  coverage: 6/6 rules exercised
  · asks_for_person — "I've been in the queue for ages, can someone just ring me ba" (not run)
      · rubric — 2 prose expectations, judged on a live run (needs ANTHROPIC_API_KEY)
  · exact_time — "What time exactly will you call me? I need to know so I can " (not run)
      ✓ matches /^(?![\s\S]*\bat \d{1,2}(?::\d{2})?\s*(?:am|pm)\b)/i
      · rubric — 1 prose expectation, judged on a live run (needs ANTHROPIC_API_KEY)
  · confirms_number — "Book me the 2pm window please, my number is 07700 900461." (not run)
      ✓ contains "07700 900461"
      · rubric — 2 prose expectations, judged on a live run (needs ANTHROPIC_API_KEY)
  · personal_alarm — "My mum has a care alarm on this line and it's been dead sinc" (not run)
      · rubric — 2 prose expectations, judged on a live run (needs ANTHROPIC_API_KEY)
  · cancel — "I fixed it myself, you can cancel my callback. LF-204417." (not run)
      · rubric — 1 prose expectation, judged on a live run (needs ANTHROPIC_API_KEY)
✓ 1 prompt — 0 failed

$ typeglish build juno.tg
✓ built .typeglish/dist/juno.txt ← juno.tg (7c4175deba24, full)

$ cat .typeglish/dist/juno.txt
# Role
You are Juno, the chat assistant for Larkfield Fibre, a broadband provider.

# Callbacks
- WHEN the customer asks to speak to a person THEN MUST call find_callback_slots.
- MUST describe every callback time as a window.
- WHEN the customer gives a phone number THEN MUST repeat their phone number to the customer.
- WHEN the customer chooses a callback window THEN MUST call book_callback.
- WHEN the customer has a personal alarm on their line THEN MUST call transfer_priority.
- WHEN the customer asks to cancel their callback THEN MUST call cancel_callback.
```

Six of six rules read, all covered by a test. The artifact holds no wait threshold, no opening hours and no limit, so the phone team can change any of them on a Friday night without anyone touching the prompt.

The spec is shorter than the brief, and it holds more. The wait, the hours, the outage pause and the one-open-callback limit live in the queue system, behind two tools. The prompt keeps only what a chat agent can do: ask for windows, describe them honestly, read the number back, and know who should never be asked to wait.

## §6 Common questions

**How do I write a system prompt for an AI agent that books callbacks?**

Give the agent a tool that returns the open callback windows and another that books one, and keep the queue wait, the opening hours and the one-per-customer limit inside those tools. The prompt then holds only what the agent does in the chat: when to look up windows, how to describe a callback time, reading the phone number back, and who skips the queue.

**How does my chatbot know when the wait is long enough to offer a callback?**

It does not, and the prompt cannot tell it. The queue system knows the wait, the hours and whether callbacks are paused for an outage. Let a slots tool apply that policy and return either open windows or an empty list, so the agent offers a callback only when there is one to offer.

**Should my AI agent give the customer an exact callback time?**

No. A callback team works a queue, so the honest promise is a window, not a minute. Write one rule that describes every callback time as a window, and pin it with a test that fails any reply saying at a single clock time.

**Can TypeGlish catch a one-callback limit that the missed-callback rule breaks?**

Yes. NEVER book a second callback for the customer beside a WHEN rule that MUST book a second callback for the customer is a logic/contradiction error in typeglish 0.11.0, and typeglish build refuses to write the prompt until one of them goes.

Field note

`logic/contradiction` is a blocking error: `typeglish build` writes nothing while it stands. It only fires on rules the checker can compare, which is why two guarded rules about the same offer, *wait.tg* in §3, sail through. When you cannot move the overlap into a tool, pin it with a `$TEST` that sends the message where both conditions are true. If your callback agent also runs after the phone team goes home, [Your agent works nights. Nobody else does.](https://typeglish.dev/blog/agent-after-hours) covers what it can promise overnight.

∿ washed up Nov 9, 2026 ∿
