Skip to content

A shared line is the quickest way to try Photon. You add the phone number or email you text from, and Photon pairs it with a number from its shared pool. That number is your agent's. Text it, and the message reaches your project.

Prerequisites

You need:

1

Add the number you text from

Open iMessage in your project. If it asks you to choose a line, choose Shared line.

Under Add the number you or your user will send from, enter your iMessage phone number and select Add. To text from an Apple Account email instead, select Use an iMessage email instead.

Enter your own number, not a number for the agent. Sample data.

Use the identity your device sends from. On iPhone, check Settings → Apps → Messages → Send & Receive. A phone number and an Apple Account email are different senders, even when both are yours.

Add the number with code instead

This replaces Add in the dashboard; don't do both. Your API key needs platforms:write. Set the number in E.164 format, such as +14155550123, or your exact iMessage email. Set a unique setup key and reuse it if you retry:

Code
export PHOTON_TEST_SENDER="+14155550123"
export PHOTON_SETUP_KEY="first-agent-imessage-$(date +%s)"

Save the example as setup.ts, setup.py, src/main.rs, or main.go in the directory you prepared in project setup.

import { Photon } from "@photon-ai/api";

const required = (name: string): string => {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
};

const photon = new Photon({
  headers: { Authorization: `Bearer ${required("PHOTON_API_KEY")}` },
});
try {
  const assignment = await photon.projects.platforms.imessage.assignments.create({
    path: { id: required("PHOTON_PROJECT_ID") },
    headers: { idempotencyKey: required("PHOTON_SETUP_KEY") },
    body: { handle: required("PHOTON_TEST_SENDER") },
  });
  console.log(assignment.assignedPhoneNumber);
} catch {
  console.error("Could not assign the shared line. Check the key, permissions, and plan capacity.");
  process.exitCode = 1;
}
node setup.ts

The program prints your agent's number.

2

Text your agent's number

Photon assigns a number from the shared pool and shows Your assigned number is followed by the number. This is your agent's number.

Scan the code with your phone, or open Messages and start a new conversation with the agent's number. Send any message, such as hi. Make sure it sends as an iMessage (a blue bubble), not SMS.

3

Check that it arrived

The dashboard shows We received your message. From now on, everything you send to the agent's number reaches your project.

How a shared line works

  • Only messages from the number or email you added reach your project. Add each person who should talk to your agent.
  • The person texts first. Your agent can reply after their first message to the line, not before. This helps prevent spam.
  • A shared line supports direct conversations, not group chats, and can't take calls.

For a number of your own that can send first, join group chats, and take calls, get a dedicated line in iMessage.

If your message doesn't arrive

What you seeWhat to check
You can't add a numberYour plan's shared iMessage capacity. Members need write access to add people.
The message sends as SMS (green)iMessage is off for that identity, or you texted from a different number or email than the one you added.
The dashboard keeps waitingYou sent from a different identity. Check Send & Receive on your device, or add that identity.

Next: receive messages

Receive messages

Get each message to your agent's number as an event in your code.