# How to give an AI agent an iMessage line

Guides, Engineering · 30 November 2026 · Mapier Labs

> Request a line, open the event stream, reply by conversation: how an AI agent gets its own iMessage number, and how to make it behave well there.

## How do you give an AI agent an iMessage line?

You ask a provider that runs Macs for a line, then connect your agent to its API: each incoming message arrives as an event, and the agent answers with a command. With Mapier Convo that is three steps: request a line in the console, open the event stream, and reply to the conversation each message came from.

Nothing runs on your side but your agent. There is no Mac to buy, no Apple account to keep signed in and no SDK to install: [the API](https://mapier.ai/convo/imessage-api) is plain HTTPS. If you want the background first, [what is an iMessage API?](https://mapier.ai/blog/what-is-an-imessage-api) explains why every such API runs on Macs.

## What is a line, and why does an agent need its own?

A line is one sender on one channel, such as a phone number. On iMessage it is a real Apple account signed in on a Mac in our fleet, so the people your agent talks to see an ordinary blue-bubble conversation from a phone number, with tapbacks and group chats behaving as they do between two iPhones. Nothing to install on their side, and no permission prompt.

An agent should have its own line rather than borrow a person's. Its conversations stay apart from that person's, a teammate can be given the same agent without handing over a phone, and when the agent misbehaves you can pause its line without touching anyone's own messages. A project can hold many lines, and one API key sends from all of them.

Two facts to know before you start: whoever texts a line becomes one of its contacts, and each line holds a set number of contacts, so a busy agent may need more than one. On iMessage the number belongs to Mapier, and you cannot move it to another provider.

## How do you request the line?

In the console, open iMessage and choose Request line. Pick how many lines you want, and why: for the first one, the reason is that it is the agent's first line. The request then reads Waiting on us, because a person at Mapier reviews every first request and sets up the number. When it reads Line added, the number is on the iMessage page and you can text it from your own phone.

Your code can make the same request with a key that holds the `lines:write` scope: a `POST` to `/v1/line-setups` asking for an iMessage line, then a poll of the setup until its state is verified and it names the new line. [Connect iMessage](https://docs.mapier.ai/convo/guides/connect/imessage) has every field.

*Two line requests in Convo's console: one already added, one waiting while a person at Mapier sets up its number.*

## How does the agent hear messages and answer them?

Open the event stream and leave it open. It is one long-lived connection that carries every incoming message and every command's result for your project. Each message carries a `conversationId`; hand the text to your agent, and send its answer back as a `message.send` that names only that conversation. Mapier sends it from the same line, on the same channel.

The answer to the send is `202`, which means accepted, not sent. The result arrives on the stream, and delivered and read follow when you ask for receipts. Keep the id of the last event you handled: when the connection drops, reconnect with it and the stream sends what you missed. If you would rather not hold a connection, signed webhooks carry the same events to your server. The [quickstart](https://docs.mapier.ai/convo/guides/get-started/quickstart) takes you from a text on your phone to a reply from the API.

*The loop on the stream: a message arrives, the agent's reply goes out by conversation, and its result and read receipt come back as events.*

## How do you make the agent behave well on iMessage?

People judge an agent on iMessage the way they judge a person, so use what Messages gives you and avoid what would read as a machine.

- Show typing while the agent works, and mark the conversation read when it has the message.
- React with a tapback where a person would, instead of sending one more message.
- Send each command with an `Idempotency-Key`, so a retry never texts someone twice.
- Treat an `ambiguous` result as unknown: look before you resend.
- Before the first message to an address someone typed, check that it can receive iMessage.
- Honour STOP and every other way a person asks you to stop; Mapier refuses further messages after an opt-out keyword, as a backstop.
- Keep it to conversations. Cold outbound, purchased lists and promotional blasts are outside what Convo is for, on any plan.

## What happens when something goes wrong?

Plan for three things. A command can fail, and its result names the kind of failure, such as the person, the content, the line, a rate limit or the transport, with the channel's own words in an error code to quote when you ask for help. A line can be unable to send for a while, paused or offline, and a send to it is refused with a reason that says which. And the stream will drop now and then even when all is well, so reconnect every time it closes and carry on from the last event you handled.

Write the agent's loop so that each of those is ordinary, not an emergency. The [troubleshooting guide](https://docs.mapier.ai/convo/guides/production/troubleshooting) covers what to check when a message does not arrive or the stream goes quiet.

## Can an agent have a phone number for calls and codes?

An iMessage line is for messages. For calls, texts and sign-up codes, Mapier's [agent phone numbers](https://mapier.ai/convo/numbers) page describes something else: a real mobile number on a real SIM, not VoIP, that your agents could use to call, text and receive login codes, turned on once and off whenever you choose. The page says Mapier customers get it first.

## Where do you start?

Access to Mapier is by approval: book a demo from [Convo's page](https://mapier.ai/convo), and Mapier sets up your account during the call. If a coding agent is doing the building, the docs carry a skill file and an MCP server it can read for itself; [build with a coding agent](https://docs.mapier.ai/convo/guides/agents/build-with-a-coding-agent) has the one prompt to give it.

Still choosing a provider? [Our comparison](https://mapier.ai/blog/imessage-api-providers-compared) sets Convo beside Linq, Sendblue, Photon, Blooio and the self-hosted route, and says where each fits better.

## Questions

### Can my agent use my own phone number on iMessage?

Not on Mapier today: iMessage lines are numbers Mapier provisions and operates on your behalf. If you need a specific one, tell us before you build.

### Can the agent send the first message?

On iMessage, yes: your agent can write first, to a phone number or an email address. Check first that the address can receive iMessage, and keep to conversations, never cold outreach.

### Can an agent take part in iMessage group chats?

Yes. It can start a group with an opening message, rename it, change who is in it, and send to everyone in it by the group's conversation id.

### Do I need an SDK?

No. The API is plain HTTPS with an OpenAPI description, so any language works, and the Mac automation underneath runs on our fleet.

### How does the agent hear replies?

On the event stream, one long-lived connection that resumes from the last event you handled, or as signed webhooks to your own server.

## Sources

- [Mapier: Connect iMessage](https://docs.mapier.ai/convo/guides/connect/imessage)
- [Mapier: Quickstart](https://docs.mapier.ai/convo/guides/get-started/quickstart)
- [Mapier: Key concepts](https://docs.mapier.ai/convo/guides/get-started/key-concepts)
- [Mapier: Groups](https://docs.mapier.ai/convo/guides/conversations/groups)
- [Mapier: Opt-out](https://docs.mapier.ai/convo/guides/production/opt-out)
- [Mapier: Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting)
- [Mapier: Build with a coding agent](https://docs.mapier.ai/convo/guides/agents/build-with-a-coding-agent)
