Caveats, Pitfalls and Tips
Every item here happened to someone. Each one says what you see, and what to do.
Your app's events
No message.channel: drafts refused. A conversation whose events carry no channel is filed under api. Drafts are refused there ("proposal not authorized") until a disclosure decision exists for api, even though you decided draft-only for in_app. Send "channel": "in_app" from the first event. For conversations already on api, decide draft-only for api too: a conversation's channel never changes.
No message.visibility: never answered. A message without visibility counts as internal. Send "visibility": "customer" on every message the customer sees.
Re-posting an event changes nothing. Events are deduplicated by source_event_id: the same id again answers duplicate, whatever the body says. To correct state (a holder, a status), post a new event with a new id.
Say who holds the ticket, every time. Send assignee ({ name, email }, or {} for nobody) on every event, so follow-ups and reminders reach the right teammate. See The ticket holder.
Name your teammates. On outbound messages send author: "agent" and author_name, so the case shows who answered.
Post after commit. Enqueue the event job after your transaction commits; a job that runs first may post an event about a row that rolls back.
Drafts into your app
No message.withdraw, no drafts. Until your app serves message.withdraw and it is registered, ReplyBrain sends it no assistant draft at all; the case asks a person instead.
valid_until. Drafts that state the customer's own facts reach your app only if it declared it enforces valid_until, refusing to send a draft after it. Drafts resting only on approved answers are unaffected.
In-app attachments are not read yet. Files a customer attaches in your app's desk do not reach ReplyBrain. Mail attachments are read (text, Markdown, PDF, .docx, images).
Facts
No account:, no facts. A topic served without account: answers every account-scoped request not_found.
Labels, not codes. A draft says what your facts say. Serve status_label: "Refund sent" so no customer ever reads status: 7.
No binding, no facts. A case uses a customer's facts only once it is bound to their account: a verified session in the event, a desk that only takes signed-in customers, or an identity a teammate confirmed. Until then drafts use your approved answers only.
Mailboxes
Wait two minutes. After a new mailbox or alias is set up, wait about two minutes before the first test mail. A mail sent earlier can bounce.
Google Groups. Allow external members, then add the ingress address as a member. Test a +suffix address before going live; if the group refuses it, ask for reply tokens to be turned off.
Replies from Gmail are invisible. A reply sent from your own mail client never reaches the case unless the support address is CC'd. Reply from the console.
Test from a stranger's address. On a group mailbox your teammates' own mail is read as theirs, not a customer's. Send tests from an address that is not a teammate's.
Signatures and keys
Clock drift fails signatures. A signature outside five minutes is refused (401). Keep NTP on.
Sign the exact bytes and path. Sign the raw body you send (not a re-serialized copy) and the path as sent, mount prefix included, plus any query string.
Rotate with two keys. Deploy the new and the old secret together, new first; retire the old one only after the switch. See Security.
The API
Reuse the Idempotency-Key on retries. A new key is a new command. A 5xx or a timeout after a write means the effect may have happened: read the resource, or reconcile, before sending again.
202 is not done. It means recorded. Poll the Location or read the event stream.
Context queries take account_id. Name the account by its ReplyBrain id; account_ref and account_scope in a reference are refused (400).