> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trugen.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates

Templates define the **persona, behaviour, and conversational structure** of your AI Teammates. Rather than configuring every setting manually for each agent, templates give you a reusable blueprint — shareable across multiple agents, enabling fast iteration, consistent brand voice, and governance at scale.

***

## What Can a Template Include?

A template consists of the following configurable components, and more:

* **Avatar for Teammate** - Choose the visual identity your agent presents during live video conversations.
* **System Prompt** - Defines the agent's role, tone, and knowledge scope. This is the core directive that shapes reasoning and personality.
* **Knowledge Base Attachments** - Bind knowledge sources such as documents, products, FAQs, or APIs.
* **Agent Config** - Fine-tune model behaviour, session limits, recording preferences, and other agent-level settings.
* **Entry, Exit & Idle Timeout Messages** - Set custom greetings, farewells, and responses to user inactivity.
* **Behaviour & Safety Settings** - Control boundaries, compliance rules, escalation, and conversation guardrails.
* **Callback Events & Webhooks** - Trigger external workflows or UI updates based on session lifecycle events.

<Note>Templates ensure that every agent deployed by your organisation shares consistent brand voice, intelligence grounding, and conversation workflow — whether you have 1 agent or thousands.</Note>

***

## Create & Use a Template

<Note>Template creation and management can be performed using the API or visually through our Developer Platform.</Note>

<Steps>
  <Step title="Create a New Template">
    Create a conversational template using the API. This example shows a minimal configuration.

    <CodeGroup>
      ```bash Request theme={null}
      curl --request POST \
        --url https://api.trugen.ai/v1/template \
        --header 'Content-Type: application/json' \
        --header 'x-api-key: <api-key>' \
        --data '
      {
        "template_name": "Sales Assistant Template",
        "template_system_prompt": "You are a friendly AI sales assistant that guides users through product selection and answers detailed product questions clearly.",
        "config": {
          "systemPrompt": "Respond in a conversational tone and always ask follow-up questions.",
          "conversationalContext": "sales",
          "maxCallDuration": 300
        },
        "knowledge_base": [
          {
            "id": "15b12908-309f-4e0f-bcb0-a4e23d45169a",
            "name": "Product Catalog"
          }
        ],
        "is_active": true,
        "record": true,
        "callback_url": "",
        "callback_events": []
      }'
      ```

      ```json Response theme={null}
      {
        "id": "d65a4f92-44b1-4fe6-b2ac-a1cb66366ddc",
        "message": "Template created successfully"
      }
      ```
    </CodeGroup>

    <Note>Replace `<api-key>` with your actual API key generated from our [Developer Portal](https://app.trugen.ai).</Note>
  </Step>

  <Step title="Create an Agent from the Template">
    Use the template ID returned above to spin up a fully configured agent instantly.

    <CodeGroup>
      ```bash Request theme={null}
      curl --request POST \
        --url https://api.trugen.ai/v1/agent/bytemplate \
        --header 'Content-Type: application/json' \
        --header 'x-api-key: <api-key>' \
        --data '
      {
        "avatar_ids": [
          "ava_ed3a666dc5",
          "ava_ae61c9e28b"
        ],
        "template_id": "76d9ff1d-b1d5-4dee-9b9a-d4c4d58c9c55",
        "email": "demo@trugen.ai"
      }'
      ```

      ```json Response theme={null}
      {
        "id": "51ed8d70-9379-422f-aed4-f9f2b293ba4a",
        "message": "Agent created successfully"
      }
      ```
    </CodeGroup>

    <Note>Replace `template_id` with the actual template `id` returned in Step 1.</Note>
  </Step>
</Steps>

***

## Why Use Templates?

<CardGroup cols={2}>
  <Card title="Faster Deployment" icon="rocket">
    Clone-ready configurations let you launch new agents in seconds — no manual setup from scratch.
  </Card>

  <Card title="Consistency & Brand Control" icon="shield-check">
    Centralise personality, tone, and rules so every agent speaks with the same voice.
  </Card>

  <Card title="Scales to Any Size" icon="chart-line">
    Ideal for enterprise teams and multi-location rollouts — one template, thousands of agents.
  </Card>

  <Card title="Easy Experimentation" icon="flask">
    Modify a template and all agents built from it update instantly — no rebuilding required.
  </Card>
</CardGroup>

***

## What's Next?

<CardGroup cols={2}>
  <Card title="Templates API Reference" icon="book" href="/api-reference/endpoint/templatecreate">
    Full API set for creating, updating, retrieving, and deleting templates.
  </Card>

  <Card title="Knowledge Base" icon="database" href="/docs/agents/knowledge-base">
    Attach knowledge sources to your template so agents always have the right context.
  </Card>
</CardGroup>
