Skip to main content
Send ping from your iPhone or Mac and receive Hello from your Photon agent!. This walkthrough uses a shared iMessage line and a small program on your computer. You do not need a public webhook server or an AI model yet.

Before you start

  • Complete Set up your project, including a key with project:read and project:write.
  • Have an iMessage-enabled phone number or Apple-account email you can send from, and a plan with shared iMessage capacity. Check plans and billing before assigning a seat.
  • Keep Messages available on your device. You must start the conversation; a shared line cannot send an unsolicited first message.
1

Add the identity you will send from

In the dashboard, select your project and open iMessage. Under Add the number you or your user will send from, enter your own iMessage phone number. To test with an Apple-account email instead, select Use an iMessage email instead.
Shared iMessage setup asks for the number the user will send from, with Add and an email alternative.

Enter the human sender's identity, not a number for the agent. Dashboard preview with sample data.

On iPhone, check Settings → Apps → Messages → Send & Receive to confirm the identity you will use. A phone number and an Apple-account email are different senders, even when both belong to you.Select Add, then complete Assign a number from the shared pool. Copy the assigned number. That is your agent’s number; your own identity is the test sender. Only messages from the assigned sender reach this shared-line connection.
This replaces the dashboard assignment; do not run both for the same test. The key also needs platforms:write. Assignment uses plan capacity. Set PHOTON_TEST_SENDER to your phone in E.164 format, such as +14155550123, or your exact iMessage email. Set PHOTON_SETUP_KEY to a unique value and keep it unchanged when retrying this same assignment.
Run these exports once and save the value of PHOTON_SETUP_KEY. Retry only the program below with that same key. In a new terminal, restore the saved value instead of generating another key.Save the example as setup.ts, setup.py, src/main.rs, or main.go in the directory you prepared in project setup.
The program prints the assigned number. Save it as PHOTON_AGENT_HANDLE below. Do not create an agent User ID from this number; the incoming message supplies the IDs used for its reply.
2

Configure your test identities

Use your actual values, not the sample phone numbers shown here. Include + and the country code for phone numbers. Keep email spelling consistent with the identity used in Messages.
3

Run your agent

This program uses the SDK messaging methods: listMessages polls for a new message every two seconds for up to two minutes, sendMessage replies once, and the program exits. The client validates responses against the contract and retries transient failures, so the code checks only the walkthrough’s own rules.It only answers a plain-text ping from your configured test sender to your configured agent. Surrounding whitespace is ignored, but signatures or other text are not. For email, a plain-text part may accompany an HTML alternative. HTML-only email is not a match.The reply reuses the incoming message’s space.id, receivedBy.id, and id as spaceId, senderId, and parentMessageId. Its stable Idempotency-Key is first-agent-reply:<incoming Message ID>.Save the code for one language in the directory from project setup:
When it prints Ready, continue to the next step and send your test message. If it exits with an API error, fix that error before sending another test. 429 means stop and honor the response’s retry guidance; do not increase the polling frequency.
This is a bounded connection test, not a production inbox consumer. It queries from five seconds before launch but ignores messages created before this run started. It rechecks that fixed window to account for eventual consistency. Keep your computer’s clock synchronized. After restarting, send a fresh ping after Ready; the program does not recover older messages. A timed-out send may still be dispatched. If you retry that original message separately, reuse its original message ID and idempotency key rather than issuing a new logical reply.
4

Send ping and check the reply

Wait for Ready in your terminal. In Messages, start a new direct conversation with the assigned number, choose the send-from identity you added, and send exactly ping. Make sure it is an iMessage, not SMS.You should receive Hello from your Photon agent! in the same conversation. The program prints Reply accepted and exits after one reply. That terminal message means Photon accepted the send; seeing the text on your device confirms the complete round trip.Send a new ping after starting the program again to repeat the test. An old conversation from before the current shared assignment does not establish permission to reply; send a fresh message after assignment.

If the reply does not arrive

Turn the test into your agent

Replace the fixed reply with your application or model’s response only after this round trip works. Keep the sender checks, use the incoming conversation’s Space ID and receiving agent’s User ID, and retain a stable idempotency key for each incoming message. Do not answer your own outbound messages. For a long-running agent, use live events with durable replay cursors, rather than expanding this short polling test. The Socket.IO reply command is an HTTP webhook response; it is not how an agent sends an iMessage.

Add email

Reuse the reply pattern with an address on your domain.

Add voice

Connect a voice-capable number. Shared iMessage lines do not support calls.