# Email and WhatsApp replies

Start a conversation, wait for the customer, read the thread and reply until the goal is met.

## Goal

Start a conversation, wait for the customer, read the thread and reply, until the goal is met.

## The prompt

```text
Message this customer on WhatsApp with the text I will give you, follow the message status, wait for their reply, then read the thread and answer. Try it first with a test key and a simulated customer reply.
```

## What your agent does

- `start_conversation`: the customer’s phone or email (or a contact id) and the first message. Email needs `channel_address_id` (the sender: ask, never pick). WhatsApp outside its 24-hour window needs `message.whatsapp_template`.
- `wait_for_status` follows queued, sending, sent, delivered and read or failed; `wait_for_message` waits for the reply. For many customers: `list_new_customer_messages` with `cursor` (each message comes once).
- `get_ticket_conversation` reads the thread and `send_ticket_message` (`mode: reply`) answers. Every send takes an `idempotency_key`.

## Recommendations

1. With a test key, `simulate_customer_message` writes a customer’s reply into a ticket of the test space, so the whole loop runs without a customer.
2. Send, follow its status, wait for the reply, read the thread, reply, wait again, and repeat.
3. A wait that ends empty returns the same cursor: call again with it.

## Pitfalls

- Reply windows are the channel’s own: `reply_window_state.way_out` says what may still go.

> **Recommendation:** Build and check everything with a test key (`rbk_test_…`): sends are simulated, nothing is charged and nothing reaches a customer.

> **Limits:** Rabt’s own AI agent only answers customers who write; reaching out first is your app’s job.
