> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runlayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# iMessage

> Let people text an agent from Messages: the agent's number, linking yours, setup, and limits

People can text one agent from Messages on their iPhone, iPad, or Mac. The agent answers as a text message in the same chat.

The channel runs through [Sendblue](https://sendblue.com), which rents a phone number ("line") that sends and receives iMessage. Your deployment comes with one: Runlayer's line.

## How it works

* **One number per deployment.** People text Runlayer's line, for example `+1 555 123 4567` (see [The agent's number](#the-agents-number)). Go shows it on the **Text message** card (see [Your numbers in Go](#go)).
* **Your workspace takes the number.** An admin turns iMessage on for one of your agents (see [Turn it on for your workspace](#turn-it-on)) and your workspace answers the number. Turning it on for another agent moves it to that agent. While an agent of another workspace on the deployment answers it, yours can't take it.
* **Each person reaches their own agent.** A linked number's texts go to its person's main agent in Go (the one they picked, or your workspace's default), so everyone texting the same number can reach a different agent. People with no main agent, and numbers not linked yet, reach the agent iMessage is turned on for. Pick a different main agent in Go and your next text goes to it.
* **Each person has one chat per agent.** Every text from the same number continues one conversation with that agent, the way an iMessage thread does. The agent sees the recent turns of that chat (the last 40 to 55 messages).
* **Text while the agent works.** A text sent while your agent is still answering joins the conversation like a follow-up in Go. When the agent is working on something you texted, it takes the new text into that task and texts back one answer. When it's answering something you started in Go, your text waits for that to finish and then gets its own answer by text. A photo can't join a task that's already running, so the agent asks you to send it again once it answers.
* **Runs as the person texting.** A text starts an agent run as the linked Runlayer user, with their access and their connector credentials. The run shows **iMessage** as its origin, and the agent's **Monitor** tab can filter by it.

## Turn it on for your workspace

iMessage is on for one agent of your workspace: the one that answers numbers not linked yet, and people with no main agent in Go. Agent pages don't show iMessage, so an admin turns it on through the [API](https://docs.runlayer.com/platform-api.md) with a personal API key. You need edit access to the agent and **Manage organization settings**, since the number serves the whole workspace.

```bash theme={null}
# Whether it's on for this agent, the number, the agent that answers now,
# and what blocks turning it on (setup_blocker)
curl "$RUNLAYER_BASE_URL/api/v1/agents/$AGENT_ID/imessage/status" \
  -H "x-runlayer-api-key: $RUNLAYER_API_KEY"

# Turn it on for this agent; it moves off any other agent of your workspace
curl -X PUT "$RUNLAYER_BASE_URL/api/v1/agents/$AGENT_ID/imessage" \
  -H "x-runlayer-api-key: $RUNLAYER_API_KEY"

# Turn it off; nothing answers until it's on for another agent
curl -X DELETE "$RUNLAYER_BASE_URL/api/v1/agents/$AGENT_ID/imessage" \
  -H "x-runlayer-api-key: $RUNLAYER_API_KEY"
```

The Runlayer Assistant can't answer iMessage (`400`). A `409` means the deployment has no number yet (see [Set up the channel](#set-up-the-number-operators)) or an agent of another workspace answers it.

Anyone without a main agent in Go who texts the number needs **run** access to this agent. Someone without it gets a reply asking them to request access from the agent's owner.

## Your numbers in Go

In Go, the **Text message** card under **Where your agent finds you** on your agent's Overview shows your linked number and where your texts go. Select it to open its settings: the number to text, the numbers you've linked, and, with nothing linked yet, a QR code: scan it with your iPhone to open Messages with a first text ready to send, then follow the link the agent texts back. Select **Unlink** next to a number to remove it.

## Link your number

Runlayer never trusts a phone number or Apple Account from the text alone. Each person links the number they text from to their Runlayer account once:

1. Text the agent's number from your phone.
2. The agent replies with a link. It expires in 15 minutes, and an unlinked number gets at most one link every 10 minutes.
3. Open the link and sign in to Runlayer. The page shows the number it will link; select **Link** to confirm.
4. The agent texts back that you're linked, followed by its contact card. Save the contact: Messages only shows previews of links from your contacts, so until then the links the agent sends stay plain text.
5. Text the agent again. From now on your texts start runs as you.

A number linked to one person can't be claimed by someone else. Your linked numbers are listed under **Your numbers** in the **Text message** card's settings in Go (see [Your numbers in Go](#go)); select **Unlink** next to one to remove it.

Only open a link the agent texted to your own phone. If someone forwards you one, the page shows their number: don't confirm it.

When a person is deactivated in Runlayer or in your directory, their linked numbers are removed. If they're reactivated, they link their number again.

A link also ends after 30 days without a text from that number, so a phone number the carrier later gives to someone else doesn't keep acting as you. Texting the agent again gets you a new link.

Until then, every text from a linked number acts as you, whoever sends it. If you lose your phone, or move the number to someone else, unlink it under **Your numbers** right away.

## The agent's number

The number is Runlayer's line, set up by whoever runs your deployment; nothing in Runlayer picks it. It's an ordinary US phone number, so people can save it as a contact.

* **iPhone users** get blue-bubble iMessages. A text the agent takes shows **Read**, and a typing indicator shows while the agent works. If the line has a name and photo, the agent shares them when you text from a linked phone number, so Messages can show who you're texting instead of a bare number.
* **Android and other phones** can text it too: Sendblue falls back to SMS, so replies arrive as green-bubble texts.
* **Apple Account emails** work as senders: if someone's iMessage sends from their email address, they link that address instead of a phone number.

## What the agent can do

* Use its connectors, skills, and memory as in any other run. Memory saved to the **User** scope follows the person into iMessage.
* Pause for [approval](https://docs.runlayer.com/platform-agents.md#hitl) when a tool needs one. Approvers handle it the usual way (Inbox or Slack); it can't be approved from Messages.
* Reply in plain text. Messages doesn't render markdown, so formatting is flattened, links become `text (url)`, and long answers are split into several bubbles.
* Listen to voice messages. A voice message you record in Messages is transcribed and the agent answers the transcript, as if you'd typed it. Transcription uses your workspace's OpenAI credentials (an OpenAI provider in **Settings → AI Providers**), whatever model the agent runs on; without them the agent texts back asking you to type instead.
* Look at photos. Send a photo or screenshot, with or without a message, and the agent sees it alongside what you wrote. iPhone camera photos (HEIC) work too: photos the agent's model can't take as sent are converted to JPEG and scaled down to 2048 pixels on their longest side. The agent sees a photo in the turn you send it, and can open it again if that turn picks up after an [approval](https://docs.runlayer.com/platform-agents.md#hitl); later texts know you sent one but can't look at it again.
* Keep threads straight. If you text again before an answer arrives, or you asked from inside a thread (an inline reply), the answer comes back as an inline reply to the text it answers. An answer to your latest text arrives as a normal message.
* See what you're replying to. Reply inline to one of the agent's messages, and the agent gets that message along with your text.

Not supported yet:

* Group chats. Texts in a group are ignored.
* Files, videos, and other attachments you send (photos and voice messages are the exceptions), and photos or files from the agent.
* Voice replies. The agent always answers in text.
* Tapbacks.
* Starting a new chat. Every text continues the same conversation.
* A number of your workspace's own. The deployment has one number, answered by one workspace at a time.

## Set up the channel (operators)

Go's **Text message** card appears once the deployment turns the channel on. On a self-hosted ECS deployment, set `enable_imessage_channel = true` and the `sendblue_*` inputs (the line's number, its API key pair, and a webhook secret) in the Terraform module, then point the line's Sendblue receive webhook at Runlayer. See [ECS optional features → iMessage channel](https://docs.runlayer.com/deployment/ecs-features.md#imessage-channel). To show a name and photo in people's chats, give the line a contact profile in Sendblue; see [Give the line a name and photo](https://docs.runlayer.com/deployment/ecs-features.md#give-the-line-a-name-and-photo). For a Runlayer-hosted workspace, ask your Runlayer contact.

## Troubleshooting

> [accordion] No Text message card in Go
>
> The deployment doesn't have the iMessage channel on. An operator has to turn it on first; see [Set up the channel](#set-up-the-number-operators).

> [accordion] The card says No number yet
>
> The deployment has the channel on but no Sendblue line configured. An operator adds it; see [Set up the channel](#set-up-the-number-operators).

> [accordion] Turning it on fails
>
> Turning iMessage on needs edit access to the agent, **Manage organization settings**, a line on the deployment, and no agent of another workspace answering it. The status endpoint's `setup_blocker` says which is missing. Once it's on, the same two permissions are enough to turn it off, even if the line has gone away.

> [accordion] I texted the agent and got no reply
>
> Check that iMessage is on for one of your agents (Go's **Text message** card says **Off in your workspace** when it isn't) and that Agents are enabled for your organization. Group chats are ignored. Operators can check the line's Sendblue receive webhook (URL and secret) and search the backend logs for `imessage_sendblue_send_failed`.

> [accordion] The chat shows a bare number, not a name and photo
>
> The line needs a name and photo set by an operator first; see [Give the line a name and photo](https://docs.runlayer.com/deployment/ecs-features.md#give-the-line-a-name-and-photo). The agent shares them over iMessage with linked phone numbers when a text starts a run, so Apple Account emails and SMS chats don't get them. How and when Messages shows them is up to the phone.

> [accordion] "This number is already linked to another Runlayer account"
>
> Someone else linked that number first. Only the person who linked it can remove it, from **Your numbers** in Go.

> [accordion] The link says it's invalid or expired
>
> Links expire after 15 minutes and work once, for the workspace the link came from. Text the agent again for a new one (one link every 10 minutes per number).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.