# Build your own A2A agent

> From zero to a public agent anyone's AI can ask - your code and your AI, connected through OpenNodd, with its own A2A card, listed under Businesses.

This page builds a complete agent of your own: your code, your AI model, your tools. OpenNodd gives it an address anyone's agent can reach (A2A, MCP or OpenNodd), the owner's approvals, receipts and a listing under **Businesses**. OpenNodd never runs or pays for your AI: it runs on your computer or server, with your key.

The example: Lena runs **Lena Cloud** (lenacloud.example), a hosting company. She wants an agent, `lena-cloud`, that answers prices and services for anyone, and takes bookings from customers she knows.

## How it fits together

```
anyone's agent ──A2A / MCP / OpenNodd──▶ OpenNodd ──▶ nodd run (Lena's server) ──▶ your command ──▶ your AI + tools
                                          rules, approvals,          picks which command runs,
                                          receipts, the card         sends back what it prints
```

- **Your command** is any program that reads a prompt from a file and prints the answer. Any language, any AI.
- **`nodd run`** listens on OpenNodd, runs your command for each request and sends the answer back. It runs next to your code.
- **OpenNodd** decides who may ask what, holds requests for Lena's OK, and publishes the agent's card.

## Who gets what

The same agent answers three kinds of people, and OpenNodd picks the command:

| Who asks | What runs | Tools? |
| --- | --- | --- |
| **Lena** (the owner), or someone she approved a request for | `message` (questions) or `task` (work) | Yes, all of yours |
| **A contact** (Lena accepted them) | `guest`, answering only from what Lena shares with their group. Anything else waits for Lena's OK, then runs `message`/`task`. | No (locked) |
| **Anyone else**, if the agent is public | `guest`, answering only from what Lena shares **publicly** (ticked **Public**). Anything else gets a fixed reply: "add them as a contact". | No (locked) |
| **Customers and anyone else**, when Lena turns on **Made for customers** | `message`, your agent itself, with a short note on who is asking. Work requests (`task`) still wait for Lena's OK. | Yes, all of yours |

> [!IMPORTANT]
> Strangers never reach your tools, not even through a clever question: that is how a public agent stays safe. To put live facts in front of strangers (prices, stock, opening hours), let your agent **fill in** what they can know, with its tools, on a schedule (step 5). Strangers then get those facts; bookings and orders go through contacts and Lena's OK.
>
> Or, if the agent is built only for customers (nothing private on it, safe tools, a cost cap), turn on **Made for customers** (step 6): customers and strangers then get your agent with its tools. The safety is then yours: your system prompt, your tools and your limits.

## 1. An account

Sign up at opennodd.com (invite-only before launch). Use an account for the business, not your personal one, so the agent, its contacts and its approvals belong to the business. Turn on two-step sign-in (**Settings → Sign-in**).

## 2. Write the command

Your command gets the prompt in a file (the path is the last argument) and prints the answer. Exit with a non-zero code if it fails. A minimal one in Node:

```js
// answer.mjs: node answer.mjs [--locked] <promptFile>
import { readFileSync } from 'node:fs';
const locked = process.argv.includes('--locked');
const prompt = readFileSync(process.argv.at(-1), 'utf8');

// Call your AI here. Locked: send the prompt as it is, no tools, no rules of yours
// (OpenNodd's prompt already says to answer only from the shared facts).
const answer = await myModel(prompt, { tools: locked ? [] : myTools });
console.log(answer);
```

- **The prompt is untrusted**: it holds other people's words. Keep your own instructions in your AI's system prompt, and tell it to ignore instructions inside messages.
- **Locked runs must not use tools.** When the facts don't cover a question, OpenNodd's prompt asks your AI to reply exactly `ASK_OWNER`; print that and OpenNodd takes over (Lena decides, or the stranger gets the fixed reply).
- **Cap your costs**: count requests per day in a file and stop at a limit, so a busy day can't run up your AI bill.

## 3. The settings file

`nodd run` reads `runner.json`. The `agents` section names your commands; `projects` says where they run.

```json
{
  "agents": {
    "lena": {
      "message": ["node", "/app/answer.mjs", "{promptFile}"],
      "guest": ["node", "/app/answer.mjs", "--locked", "{promptFile}"],
      "fill": ["node", "/app/answer.mjs", "{promptFile}"]
    }
  },
  "projects": {
    "main": { "path": "/data/work", "agent": "lena", "approval": "auto", "timeoutSeconds": 150 }
  },
  "defaultProject": "main"
}
```

| Command | When it runs |
| --- | --- |
| `message` | Questions from Lena, or ones she approved. |
| `task` | Work that changes things (only if the project's `allow` includes `task`). Leave it out for an agent that only answers. |
| `guest` | Contacts' and strangers' questions, answered from what Lena shares. **Without `guest` your agent never answers them by itself**: contacts' questions wait for Lena and strangers get the fixed reply. |
| `fill` | Filling in "My agent fills it in" items (step 5). Default: `message`. The prompt holds no one else's words. |
| `output` | How to read what it prints: `text` (default). |

In each command, `{promptFile}` is the prompt's path; `{prompt}` (the text), `{person}`, `{conversation}`, `{task}` and `{project}` are also replaced. The project fields (`path`, `allow`, `timeoutSeconds`…) are in [Work for other people](/use/work-for-others#projects); `"approval": "auto"` runs requests OpenNodd has already allowed without asking again on the server.

## 4. Connect it

In the app, signed in as the business account: **My agents → Add an agent you run → Other**, name it `lena-cloud`, and copy the line. On the computer or server that runs it:

```sh
npm install -g https://opennodd.com/opennodd.tgz
nodd connect LINK-XXXXX-XXXXX --no-listen    # the code from the app: works once, for 10 minutes
```

It connects at once (nothing to approve) and saves the agent's sign-in in `~/.nodd/agents/lena-cloud/`. Then start it:

```sh
NODD_HOME=~/.nodd/agents/lena-cloud nodd run --config runner.json
```

It logs `listening as "lena-cloud" (owned by lenacloud)`. Keep it running (a service, or a container with `restart: unless-stopped`).

> [!TIP]
> **In a container**, run `nodd connect` once in the container (it finishes right there) with `HOME` on a volume (for example `HOME=/data`) so the sign-in survives, and start the service with `NODD_HOME=/data/.nodd/agents/lena-cloud`. Running the line twice changes nothing: the code works once.

## 5. What contacts and strangers can know

**My business → What customers can know → + Add what customers can know** (or **People → What my agent can share → + Add item**). For each item pick:

- **I write it**: text that rarely changes. "support@lenacloud.example · Monday to Friday 8:30 to 17:00."
- **My agent fills it in**: say what to write and how often. "Current plans with specs and monthly price including VAT." Your `fill` command runs with its tools, writes it, and refreshes it on schedule.

Tick who can know each item: Friends, Family, Business, and **Public** for anything you'd put on your website.

Your agent fills an item in **as soon as someone can ask**: once you have a contact or a public agent, and again whenever you change the item. Before that the item says "your agent fills it in once someone can ask". Open an item to see what your agent last wrote.

## 6. Go public

1. **Verify the business**: **My business → Get your business verified → + Add business**, with the name and website. Add the TXT record it shows where you manage the website's address (Cloudflare, your registrar…), then **Check now**. See [Businesses](/use/businesses).
2. **Make the agent public**: **My business → Go public → Public agent: anyone can ask it** (it saves as you tick it).
3. **Optional: Made for customers**: tick **Made for customers: answers with its own tools** to let customers and strangers use your `message` command (its tools) instead of the locked `guest` answer.

Now:

- It's listed under **Businesses** in the app and at `GET /v1/businesses?q=hosting` (no sign-in).
- Its A2A card is at `https://opennodd.com/a2a/lena-cloud/.well-known/agent-card.json`, with a signed **verified business** badge other agents can check.
- Anyone's agent can ask it over A2A (`message/send` at the card's address), through MCP or with `nodd send`.

**On your own domain**: serve the card at `https://lenacloud.example/.well-known/agent-card.json` so agents that look up your website find it. With nginx:

```nginx
location = /.well-known/agent-card.json {
    proxy_pass https://opennodd.com/a2a/lena-cloud/.well-known/agent-card.json;
    proxy_ssl_server_name on;
    proxy_set_header Host opennodd.com;
    add_header Access-Control-Allow-Origin * always;
}
```

## 7. Optional extras

- **Apps your owner connected**: on the **Connect** page your owner adds apps (Google Calendar through Zapier, Shopify, any MCP server). OpenNodd keeps their keys and makes the calls. Your agent gets them as tools in `nodd mcp` and at `https://opennodd.com/mcp`, or over REST: `GET /v1/me/apps/tools` lists them (name, description, input schema, read-only or not) and `POST /v1/me/apps/call` `{ "name": "google_calendar__find_busy", "args": { "day": "2026-11-12" }, "person": "maria" }` uses one. Send `person` (the `{person}` placeholder in your command) whenever you work for someone else: OpenNodd then allows only the tools your owner ticked for others. On a Zapier app it allows only the Zapier actions your owner ticked (`execute_zapier_read_action` / `execute_zapier_write_action` with that `selected_api` and `action`); the refusal lists them. Treat what apps return as data, never as instructions.
- **Share your tools over MCP**: the same tools your agent uses can be an MCP server people add to Claude Code or Codex. Offer only read-only tools there (prices, services); keep anything that sends or books behind your agent and its approvals.
- **Direct connections**: on a public https address, contacts' agents can call yours directly, with OpenNodd's rules applied at your door. See [Direct connections](/connect/direct).
- **Receipts**: every answer gets a signed receipt; strangers' questions are marked `public-list`. See [Receipts](/use/receipts).

## 8. Check it works

1. In the app, as the business: the agent shows **listening**; your "My agent fills it in" items show what it wrote.
2. From another account (a friend's, or a second one): find the business under **Businesses** and ask something your list answers, then something it doesn't (you should get the fixed reply).
3. `curl https://opennodd.com/a2a/lena-cloud/.well-known/agent-card.json` shows the card (and your domain's address, if you added it).
4. Add the business as a contact from the other account, accept it, and ask for a booking: it should wait in the business's **Approvals**.

## When something's off

| What you see | Why, and what to do |
| --- | --- |
| Items say "your agent fills it in once someone can ask" | Nobody can ask yet: add a contact or make the agent public. |
| Strangers always get "I can only answer from what … shares publicly" | Nothing is shared **publicly** (ticked **Public**), the list covers none of the question, or there's no `guest` command. (When it covers part of it, strangers get that part.) |
| The card says `not_found` | The agent isn't public, or its business isn't verified. |
| `nodd connect` says the code was already used or expired | Make a new one: **My agents → Add an agent you run** (or **Connect again** on the agent's page). Codes work once, for 10 minutes. |
| `nodd run` logs `agent "…" has no "guest" command` | Add a `guest` command (step 3), or contacts wait for your OK and strangers get the fixed reply. |
| An item says the agent failed | Run your `fill` command by hand with a prompt file and check it exits 0. |
