Skip to main content
Give your agent an address such as [email protected]. Send it ping from your personal inbox and receive Hello from your Photon agent! in the same email conversation.

Before you start

  • Complete Set up your project, including a key with project:read and project:write.
  • Have a domain you control and permission to edit its DNS records.
  • Have a separate inbox for sending and receiving your test email.
Use an unused subdomain, such as mail.your-domain.com, for your first test. Changing a domain’s receiving MX record changes where its email goes. Do not replace the MX records for a working company or personal inbox.
1

Connect your domain

Select your project in the dashboard and open Email. Under Connect a domain, enter the domain or subdomain you will use and select Connect domain. Enter only the domain, not https:// or a full email address.
Email dashboard with mail.example.org entered in the Connect a domain field.

Connect your own domain or an unused subdomain. The domain shown is sample data.

This replaces Connect domain in the dashboard. The key also needs platforms:write. Keep the same idempotency key when retrying this logical connection; create a different key for a different operation.
Run these exports once and save the value of PHOTON_SETUP_KEY. After an uncertain response, rerun only the program below. In a new terminal, restore the saved key rather than rerunning the date-based export; a newly generated key starts a different operation.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 an operation ID, not a ready domain. Return to Email and open its setup to configure DNS and follow verification.
2

Publish the DNS records

Open the domain’s setup page. At your DNS provider, add every record displayed by Photon, keeping its type, host, value, and MX priority. The values are specific to your domain; do not copy them from this image.
Email domain setup with verification checks, three DKIM CNAME records, bounce MX and SPF TXT records, and an inbound MX record.

Domain setup checks both sending identity and receiving DNS. This preview deliberately includes records that have not been found yet.

Some DNS providers append your zone name automatically. If yours does, enter the relative host it expects rather than adding the domain twice. For CNAME records on providers with a proxy option, use DNS only.Photon checks DNS automatically. Wait for the domain to show Connected and the required verification checks to complete before testing. DNS changes are not immediate; reopening the page does not make them propagate faster.
3

Choose your agent address and test sender

Choose an address under the connected domain, such as [email protected]. For this inbound-first flow, Photon resolves the receiving address when its first email arrives; you do not need a separate mailbox-creation API call.Set your actual agent address and your personal send-from address:
Use the exact address you send from, not a display name or a different alias. Start with a private email from you to the agent, without Cc or Bcc.
4

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.
5

Send your first email

Wait for Ready in your terminal. From the configured personal inbox, send a new email to your agent address with the subject First agent and a plain-text body containing only ping. Do not include a signature for this test.Check that Hello from your Photon agent! arrives as a reply in that conversation. The program prints Reply accepted and exits after one reply. The API accepting the request is only one checkpoint: receiving the email in your inbox confirms the round trip. Check spam or junk too.

How the reply stays in the conversation

The incoming Message provides the space.id, receivedBy.id, and its own Message ID. The program sends those as spaceId, senderId, and parentMessageId. Photon uses the persisted parent message to build email threading headers; do not invent an RFC Message-ID or set custom mail headers.
Email replies can include other participants. By default, recipients are inferred from the parent’s Reply-To or From and visible To/Cc addresses, excluding the selected sending address; Bcc is not inherited. This test uses one sender and one agent. Choose explicit recipient rules before automating multi-person threads, and do not turn this into an unrestricted autoresponder.

If the reply does not arrive

Keep building

Replace the fixed response with your agent’s logic, but keep the receiver and sender checks and a stable idempotency key. The exact ping trigger and single-reply exit deliberately limit this example; external autoresponders are not reliably identified by the sender’s kind alone. For a persistent inbox agent, move to live events, persist replay cursors, and define retry and email-recipient policies. The Socket.IO reply command does not send email; use the message HTTP endpoint for the reply.

Add iMessage

Reuse your message handling with a shared iMessage line.

Add voice

Give your agent a phone number people can call.