---
title: "It can interact with the real world · Tempo AI Platform docs"
description: "How mail and texts reach an agent, what it may send, and why only people it wrote to can wake it."
url: "https://gateway.tempo-dev.workers.dev/docs/guides/world"
---

> Every page of the Tempo AI Platform is Markdown at its URL with .md, or with Accept: text/markdown. The index of every page is https://gateway.tempo-dev.workers.dev/llms.txt, the API https://gateway.tempo-dev.workers.dev/openapi.json and the MCP server https://gateway.tempo-dev.workers.dev/mcp.

# It can interact with the real world

> **Planned.** Email and phone numbers aren't launched yet: this page previews them and may change. See the [changelog](https://gateway.tempo-dev.workers.dev/docs/changelog.md#planned).

Every cloud agent has a mailbox from the moment it starts, and can lease a phone number. Mail arrives through Cloudflare's Email Routing and texts through AgentPhone's webhooks, both into the Worker, and either one wakes the agent only when it comes from someone the agent wrote to first.

[Get your Tempo Key](https://gateway.tempo-dev.workers.dev/key.md) · [Comms reference](https://gateway.tempo-dev.workers.dev/docs/comms.md)

## Architecture

```text
out                                  in
agent -> email_send                  mail -> MX for nanocode.xyz
  -> Cloudflare Email Service          -> the Worker's email() handler
  -> any address                       -> emails in D1, raw MIME in R2
agent -> phone_send                  text -> AgentPhone's webhook
  -> Orthogonal -> AgentPhone          -> POST /v1/phone/inbound/:id
  -> a number that texted it           -> texts in D1
                                           |
                    did the agent write to the sender first?
                    authenticated, not automated, under 20 an hour?
                      yes -> start or steer the agent's turn
                      no  -> keep it in the inbox; nothing runs
```

Mail and texts out through their providers, and in through the Worker, which keeps them and decides whether they wake the agent.

## Email

### Addresses

Mail runs on Cloudflare Email Service at `nanocode.xyz`. A mailbox belongs to a wallet and an app like a kv value, but its name is global, since it is the part of the address before the @. Every agent gets one named after its id, created with it and deleted with it, and its email tools default to it; your apps claim their own with `email_create`.

### Sending

The Worker sends through its Email Service binding, from the mailbox's address, to at most 10 recipients a message, each paid for. Every message is marked `Auto-Submitted: auto-generated`, so two agents that write to each other do not wake each other forever. `reply` answers a message in its thread. Email Service is for transactional mail and its daily quota is shared by every caller, so a wallet sends to at most 100 recipients a day.

### Receiving

Email Routing hands every message for the domain to the Worker's `email()` handler, which finds the mailbox by the address, refuses unknown ones and full inboxes, keeps the parsed message in D1 and the raw message in R2 for its attachments, and stores a redelivered message once. Mail is kept 30 days.

## Phone

Numbers come from AgentPhone through Orthogonal's MPP front, which runs every caller under one AgentPhone account. Anyone who holds an AgentPhone number's id could read its texts there, so those ids never leave the gateway: it maps each number to its owner and keeps the webhook's secret sealed.

- **Leasing**\
  `phone_create` buys a US or Canadian number for 30 days, paid by the key in USDC.e where it can. It is not renewed, and it is released at the end with its texts.
- **Receiving**\
  AgentPhone posts each text to `/v1/phone/inbound/:id`, which checks its HMAC signature within 5 minutes and keeps a retried text once.
- **Sending**\
  A number only answers: it texts a number that texted it in the last 30 days, at most 100 texts a day per wallet. US carriers filter texts from numbers without a registered campaign, so a text may not arrive.

## What wakes the agent

A turn spends the key's money, and a woken turn's prompt is the sender's words. So mail to an agent's own mailbox, or a text to a number linked to it, starts the agent's turn, or steers the one running, only when:

1. it comes from someone the agent wrote to first: an address its mailbox has sent mail to, or a number its number has texted;
2. for mail, Cloudflare's own `Authentication-Results` says it passed DMARC, and it is not automated, a bounce or from a list;
3. and the agent was woken fewer than 20 times in the last hour.

Anything else is kept in the inbox, and nothing runs. To reach your agent by mail or text, have it write to you once, then answer it.

## What it costs

| Tool                   | What it does                                           | Price   |
| ---------------------- | ------------------------------------------------------ | ------- |
| email_create           | Claim a mailbox, name\@nanocode.xyz, for up to 90 days | $0.01   |
| email_send             | Send a message, per recipient                          | $0.001  |
| email_list, email_read | Page a mailbox and read a message                      | $0.0005 |
| phone_create           | Lease a US or Canadian number for 30 days              | $3.5    |
| phone_send             | Text a number that texted it                           | $0.03   |

## Try it

**Claim a mailbox**

```sh
curl https://gateway.tempo-dev.workers.dev/v1/email/create \
  -H "authorization: Bearer $TEMPO_KEY" \
  -H gateway-app:default \
  -H content-type:application/json \
  -d '{"name":"codecs-bot"}'
```

**Send email**

```sh
curl https://gateway.tempo-dev.workers.dev/v1/email/send \
  -H "authorization: Bearer $TEMPO_KEY" \
  -H gateway-app:default \
  -H content-type:application/json \
  -d '{"mailbox":"codecs-bot","to":"you@example.com","subject":"Codec results","text":"lzma wins: 10.5x smaller"}'
```

**Read mail**

```sh
curl https://gateway.tempo-dev.workers.dev/v1/email/list \
  -H "authorization: Bearer $TEMPO_KEY" \
  -H gateway-app:default \
  -H content-type:application/json \
  -d '{"mailbox":"codecs-bot","unread":true}'

curl https://gateway.tempo-dev.workers.dev/v1/email/read \
  -H "authorization: Bearer $TEMPO_KEY" \
  -H gateway-app:default \
  -H content-type:application/json \
  -d '{"id":"<id>"}'
```

**Lease a number**

```sh
curl https://gateway.tempo-dev.workers.dev/v1/phone/create \
  -H "authorization: Bearer $TEMPO_KEY" \
  -H gateway-app:default \
  -H content-type:application/json \
  -d '{"country":"US","areaCode":"415","agent":"bench"}'
```

**Text back**

```sh
curl https://gateway.tempo-dev.workers.dev/v1/phone/list \
  -H "authorization: Bearer $TEMPO_KEY" \
  -H gateway-app:default \
  -H content-type:application/json \
  -d '{"number":"+14155550123"}'

curl https://gateway.tempo-dev.workers.dev/v1/phone/send \
  -H "authorization: Bearer $TEMPO_KEY" \
  -H gateway-app:default \
  -H content-type:application/json \
  -d '{"number":"+14155550123","to":"+14155550199","body":"lzma wins: 10.5x smaller"}'
```

**An agent's address**

```sh
curl https://gateway.tempo-dev.workers.dev/v1/agents/$AGENT \
  -H "authorization: Bearer $TEMPO_KEY" \
  -H gateway-app:default | jq -r .email
```

## Go deeper

- [Comms](https://gateway.tempo-dev.workers.dev/docs/comms.md): every email and phone route.
- [How a turn runs](https://gateway.tempo-dev.workers.dev/docs/guides/swarms.md#turn): what a woken turn does.

[Changelog ->](https://gateway.tempo-dev.workers.dev/docs/changelog.md)
