API · Set up agents

Teach it your business

The Business Brain is what your agent knows and how it behaves. Build it from your website, write it yourself, or both. Render-mode sessions don't use it: there, your own agent does the thinking.

Build it from your website

  1. 1

    Set the website

    Create the agent with website_url, or set it with PATCH /v1/agent/{agent_id}.

  2. 2

    See which pages it found

    GET/v1/agent/{agent_id}/extract-links

    The pages linked from your homepage and sitemap, scored, each with a suggested category.

    Response

    {
      "homepage_url": "https://bloomhair.example",
      "links": [
        { "url": "https://bloomhair.example/services", "path": "/services", "anchor": "Services",
          "score": 92, "source": "homepage", "default_category": "primary" },
        { "url": "https://bloomhair.example/prices", "path": "/prices", "anchor": "Prices",
          "score": 88, "source": "homepage", "default_category": "primary" }
      ],
      "total_found": 14
    }
  3. 3

    Build

    POST/v1/agent/{agent_id}/generate-brain

    Send the pages to learn from. is_primary: true for the pages that describe the business (home, services, prices, contact), false for background reading. Then poll GET /v1/agent/{agent_id}/brain-status until it is no longer pending or processing: it takes a few minutes.

    curl -X POST https://talk.selviaai.com/v1/agent/42/generate-brain \
      -H "Authorization: Bearer $SELVIA_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"pages": [
            {"url": "https://bloomhair.example", "is_primary": true},
            {"url": "https://bloomhair.example/services", "is_primary": true},
            {"url": "https://bloomhair.example/blog/summer-trends", "is_primary": false}
          ]}'
brain_statusMeaning
pendingQueued.
processingBeing built. Conversation sessions for this agent answer 409 agent_building until it is done.
completeReady. The status answer also carries the instructions it produced.
failedSomething went wrong; build again, or write the instructions yourself.

Write it yourself

Set system_prompt on the agent with PATCH /v1/agent/{agent_id}: who it is, what the business offers, how it should talk and what it must never do. You can do this instead of a build, or edit what a build produced.

Add knowledge

A section of facts

POST/v1/agent/{agent_id}/kb-sections

A short titled piece of knowledge: opening hours, parking, a policy. List, change and delete them with the same path.

curl -X POST https://talk.selviaai.com/v1/agent/42/kb-sections \
  -H "Authorization: Bearer $SELVIA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"title": "Parking", "content": "Free parking behind the salon; enter from Oak Street."}'

Another page of your website

POST/v1/agent/{agent_id}/add-page

{"url": "https://…", "is_primary": true} reads one more page into what it knows. List the pages it learned from with GET /v1/agent/{agent_id}/pages/list.

The console's Business Brain editor (behaviour, business rules, Dynamic Instructions, questions visitors asked that it couldn't answer) is under /v1/agent/{agent_id}/v2/…. Every route is listed in All endpoints.