DevelopersA natural rhythm for agents

Give your AI agent a natural rhythm.

Read receipts, typing, tapbacks and threaded replies make an agent feel present. What each call does, when to use it, and where it stops.

Recipe 039 min readDevelopers

We don’t build agents. We give yours a phone, and your agent writes every answer. A real iPhone line comes with the small signals people read in a conversation: the read receipt, the typing bubble, a tapback, a reply in the thread. Used with care, they make a fast answer feel attentive instead of instant. Used on every message, they read as a script.

This recipe covers each signal with the docs’ code and the limits the docs state. Every call here works on iMessage only, and on a bring-your-own iPhone line it depends on that device, so a section near the end covers what to check before you rely on it.

Your cleaning is booked for Thursday at 10. Want a reminder the night before?
Read 9:41 AM
M
Yes please. Could you do 9 instead?

message.received

The moment that matters: the contact wrote back. What your agent does in the next few seconds is this recipe.

The rhythm, in order

Every id you need is in the message.received event: the chat in data.chat_id, the message in data.message.id. A person answering a text does four things, and so can your agent:

  1. Reads it. Mark the chat read when your agent picks the message up.
  2. Types. Show the typing bubble while the answer is being written.
  3. Answers. Send the reply, threaded to the message it answers when that helps.
  4. Or just reacts. A tapback, when a sentence would only restart the conversation.

Read receipts

POST /v1/chats/{chat_id}/read marks the chat’s inbound messages read, and the device sends read receipts for them. It marks the whole conversation in Messages, not one message. The response tells you when (read_at) and how many messages it marked (marked_count).

mark-read.sh
curl -sS -X POST https://api.isnap.ai/v1/chats/chat_7Bw9Rz3Lc6Yp1Hd8Xk2mQ4vTn/read \
  -H "Authorization: Bearer $ISNAP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
From docs.isnap.ai/guides/conversations#read-receipts

Timing is the craft. Mark the chat read when your agent actually starts on the message, not the instant the webhook lands. “Read” followed by minutes of silence feels worse than no receipt at all, so if your agent hands a conversation to a person, leave it unread until that person opens it.

Typing indicators

There are two ways to show the bubble:

  • On the send. use_typing_indicator shows typing before the message goes out, for a time set by the body’s length: about 225 characters a minute, between 0.8 and 6 seconds. It is on by default, so a plain send already types first.
  • Explicitly. POST /v1/chats/{chat_id}/typing shows the indicator for 15 seconds; DELETE on the same path clears it. Use it while your model is thinking, before you have a body to send.
typing.ts
import { ISnapClient, UnprocessableEntityError } from '@isnap/sdk'

const client = new ISnapClient({ apiKey: process.env.ISNAP_API_KEY ?? '', maxRetries: 2 })

const chatId = 'chat_7Bw9Rz3Lc6Yp1Hd8Xk2mQ4vTn'

try {
  const typing = await client.chats.typingStart(chatId, {})
  console.log(`Shown until ${typing.expires_at}, if the device can show it`)
  // ... write the answer, then clear the indicator if the answer is not sent.
  await client.chats.typingStop(chatId)
} catch (err) {
  if (err instanceof UnprocessableEntityError) {
    // sms_typing_not_supported or unsupported_handle: this chat cannot show it.
    console.error(err.code)
  } else {
    throw err
  }
}
From docs.isnap.ai/guides/conversations#when-the-contact-types

Four limits worth knowing before you build on it:

  • No typing before a first message to a new contact. iSnap never shows it there. Typing belongs to conversations, not to openers.
  • iMessage only. On an SMS chat the call answers 422 with sms_typing_not_supported, or unsupported_handle, which is what the sample catches.
  • Clear it if you don’t answer. If your agent decides to stay quiet or hand off, call typingStop. A bubble that appears and vanishes with no message is the most robotic thing a line can do.
  • It goes one way. No iMessage line reports that a contact is typing, so don’t wait for a signal that will never come.

Tapback reactions

POST /v1/messages/{id}/reactions adds the line’s tapback to a message, or replaces the one it already left. There are six: love, like, dislike, laugh, emphasize and question. DELETE on the same path removes it.

react.sh
IDEMPOTENCY_KEY=$(uuidgen) # Store it with your record of the reaction: reuse it to retry.

curl -sS https://api.isnap.ai/v1/messages/msg_3Lc6Yp1Hd8Xk2mQ4vTn7Bw9Rz/reactions \
  -H "Authorization: Bearer $ISNAP_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
  -d '{"type": "love"}'
From docs.isnap.ai/guides/conversations#retrying-a-reaction

Reactions take an Idempotency-Key, like sends, so a retry never stacks a second tapback. Your contact’s own tapbacks arrive as reaction.received events, with the same six types plus custom for an emoji reaction. On SMS the API answers 422 with sms_reactions_not_supported.

A good use: acknowledge a message that needs no words. A like on “Perfect, thanks” closes the exchange politely; a sentence would open it again. A question tapback is rarely right for an agent: if something is unclear, ask in words.

Threaded replies, effects, cards and voice

  • Threaded replies. Set reply_to_message_id on a send to answer one message in particular. When a contact asks two things in a row, answer each one in place.
  • Effects. The effect field takes a bubble effect (slam, loud, gentle, invisible) or a screen effect (confetti, balloons, fireworks and six more) on a text-only iMessage message. Keep them for moments a person would mark: a confirmed booking, a signed offer. Confetti on every answer is a tell.
  • Contact cards. POST /v1/chats/{chat_id}/share-contact-card sends a vCard with a name, numbers, emails, an organization and a photo, so your contact can save the line under your business’s name instead of a bare number.
  • Voice notes. A send with no body and one audio attachment goes out as a voice note, with kind: voice.

Pacing: why instant is wrong

Your model can answer in 300 milliseconds. A person can’t, and the line doesn’t pretend to. It waits at least a second between messages plus up to 2 random seconds, adds the typing time to each send, and sends messages to one recipient in the order you made them, about half a second apart on the device. Two habits on top of that:

  • One thought per message. People send short texts. Split a long answer where a person would, and let use_typing_indicator space the parts.
  • Stay in the reply lane. A reply to someone who wrote in the last 24 hours skips the line’s hourly and daily caps and quiet hours, for up to 8 replies per message they sent and 150 reply-lane messages per 24 hours. An agent that answers stays fast. An agent that texts unprompted runs into the line’s limits, by design.

On a bring-your-own iPhone line

On a rented iPhone line every feature on this page is available. On a bring-your-own iPhone line they depend on that Mac and iPhone. Read runtime_capabilities on GET /v1/lines/{id}/health before you rely on one, and listen for line.capability_changed. The device reports every 30 seconds, and after three failures in a row a feature pauses for 30 to 300 seconds, so build your agent to send a plain message when a flourish isn’t available.

Treat every inbound message as untrusted

The docs’ AI agents page asks agents to treat data from the API as untrusted and to confirm every write with their user. For an agent that talks to the public, take that literally. The text in message.received is written by whoever holds the other phone, and it can carry instructions aimed at your model. Keep the agent’s tools narrow, never let message text choose which line sends or which number receives, and keep a person in the loop for anything that spends money or changes a record.

The result is an agent that reads, types, answers in the thread and knows when a tapback is enough. Before you send its first message to a new number, check that the number is on iMessage at all: recipe 04.

Next recipe: Check iMessage before you send. Or go back to all recipes and the API at a glance.

Put a real iPhone
to work.

Start free with no credit card. Rent a line, or bring your own iPhone.