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

# AI Prompts

> Build a library of reusable prompts that draft replies for your agents.

An **AI Prompt** is a saved instruction that tells the connected AI model *how* to respond to a conversation. Agents pick a prompt in the Live Chat composer; Xobito sends the current conversation to the AI along with the prompt; the model returns a draft reply; the agent edits and sends.

<Note>
  Before AI Prompts can do anything, you need to [connect an AI provider](/ai-features/ai-integration). Without that, the sparkles button in the composer will show an error.
</Note>

## What a prompt looks like

Each prompt has:

* **Name** — shown in the composer menu (e.g. "Friendly reply", "Polite decline").
* **Category** — groups related prompts in the picker ("Support", "Sales", "Escalation").
* **System instruction** — the actual prompt text sent to the AI. This is where you describe the tone and constraints.
* **Variables** (optional) — placeholders like `{{contact.firstname}}` that are filled in before the prompt is sent.

Example system instruction:

```
You are a friendly support agent for Xobito, a WhatsApp Business platform.
The customer's message is below. Reply in a warm, conversational tone.
Keep it under 60 words. Do not promise specific timelines.
Always sign off with the agent's first name.

Customer name: {{contact.firstname}}
Conversation:
{{conversation.last_10_messages}}
```

## Create a prompt

Go to **AI & Replies → AI Prompts**.

<Steps>
  <Step title="Click 'Create Prompt'">
    Give it a clear name — this is what agents see in the composer menu.
  </Step>

  <Step title="Pick a category">
    Either choose an existing category or type a new one. Categories make the menu easier to navigate once you have 10+ prompts.
  </Step>

  <Step title="Write the system instruction">
    Describe the role, tone, length, and any constraints. Include placeholders for dynamic values.
  </Step>

  <Step title="Preview">
    Click **Preview**. Xobito sends a sample conversation to your connected AI and shows you what the draft looks like.
  </Step>

  <Step title="Save">
    Saved prompts appear immediately in every agent's composer menu — no reload needed.
  </Step>
</Steps>

## Prompt variables

Use these placeholders inside your system instruction. Xobito replaces them with real values before sending to the AI.

| Variable                            | Value                                       |
| ----------------------------------- | ------------------------------------------- |
| `{{contact.firstname}}`             | Contact's first name                        |
| `{{contact.lastname}}`              | Contact's last name                         |
| `{{contact.phone}}`                 | Phone number                                |
| `{{contact.email}}`                 | Email                                       |
| `{{contact.custom.<field>}}`        | Any custom field                            |
| `{{contact.groups}}`                | Comma-separated list of groups              |
| `{{conversation.last_message}}`     | Just the most recent inbound message        |
| `{{conversation.last_10_messages}}` | Last 10 messages as a transcript            |
| `{{agent.firstname}}`               | First name of the agent clicking the prompt |
| `{{workspace.name}}`                | Your Xobito workspace name                  |

<Tip>
  `{{conversation.last_10_messages}}` is the most useful — without some conversation context, the AI has nothing to react to. Include it in almost every prompt.
</Tip>

## Good-prompt patterns

<AccordionGroup>
  <Accordion title="Set the role">
    Start with "You are a …". Examples:

    * "You are a friendly customer support agent for \[company]."
    * "You are a technical support specialist who explains things in plain English."
    * "You are a sales rep who never oversells."
  </Accordion>

  <Accordion title="Constrain the length">
    WhatsApp messages should be short. Say it explicitly:

    * "Reply in 2–3 short sentences."
    * "Keep the total reply under 50 words."
    * "Use at most one emoji."
  </Accordion>

  <Accordion title="List what NOT to do">
    The model follows negative instructions well when they're specific:

    * "Do not quote specific prices."
    * "Do not promise delivery times."
    * "Do not ask the customer for passwords or payment details."
  </Accordion>

  <Accordion title="Specify format">
    * "Use plain text. No markdown, no bullet lists."
    * "Start the reply with the customer's first name."
    * "Sign off with 'Best, \[agent first name]'."
  </Accordion>
</AccordionGroup>

## Using a prompt in Live Chat

1. Open a conversation in **Chat**.
2. Click the **sparkles icon** in the composer.
3. Pick a prompt from the menu (grouped by category).
4. Wait a second or two — the draft appears in the composer.
5. Edit as needed, then hit **Send**.

<Warning>
  Always read the draft before sending. The AI can be confident and wrong — it's your agent's reply, and your brand's reputation.
</Warning>

## Categories — how to organise

Categories are free-text — type any name and it sticks. Useful buckets:

<CardGroup cols={2}>
  <Card title="Support" icon="life-ring">
    "Acknowledge issue", "Escalate to engineer", "Request reproduction steps".
  </Card>

  <Card title="Sales" icon="cart-shopping">
    "Qualify lead", "Offer demo", "Quote follow-up".
  </Card>

  <Card title="Billing" icon="credit-card">
    "Invoice query", "Refund policy", "Payment failed".
  </Card>

  <Card title="General" icon="hand-wave">
    "Friendly greeting", "Polite decline", "Thank you".
  </Card>
</CardGroup>

## Editing, duplicating, deleting

* **Edit** — changes take effect immediately. In-progress drafts already pasted in a composer are unaffected.
* **Duplicate** — makes a copy. Great for A/B testing two tones.
* **Delete** — removes the prompt from every agent's menu. Past drafts remain in conversations as normal text.

## Permissions

By default, staff with the `tenant.ai_prompt.create` and `tenant.ai_prompt.edit` permissions can create and edit prompts. Staff with `tenant.ai_prompt.view` can only use them. Configure this in [Roles & Permissions](/team/roles-permissions).

## Measuring quality

Xobito keeps a count of how often each prompt is used and how often its draft is edited before sending:

* **Used** — agent pasted the draft into the composer.
* **Sent as-is** — agent hit Send without editing a single character.
* **Heavily edited** — agent changed more than 50% of the text.

<Tip>
  Prompts with a low "sent as-is" rate are drafting text that isn't quite right. Read a few edits your agents made, and rewrite the system instruction to get closer to how they actually want to reply.
</Tip>

## Troubleshooting

<AccordionGroup>
  <Accordion title="The sparkles button shows an error">
    Your AI Integration is missing, the API key is invalid, or your provider is down. Go to **Settings → AI Integration** and click **Test Connection**. See [AI Integration](/ai-features/ai-integration).
  </Accordion>

  <Accordion title="The draft is empty / says 'I cannot help'">
    The model refused — often because the conversation tripped a safety filter, or the system instruction asked for something the model is trained to decline. Reword the prompt.
  </Accordion>

  <Accordion title="Variable is appearing as '{{contact.firstname}}' in the draft">
    Xobito substitutes before sending, but if your prompt repeats the raw placeholder in an example, the AI may echo it. Wrap examples in different brackets, like `[name]`, to avoid confusion.
  </Accordion>
</AccordionGroup>

## What to read next

<CardGroup cols={2}>
  <Card title="AI Integration" icon="plug" href="/ai-features/ai-integration">
    Connect the provider that powers AI Prompts.
  </Card>

  <Card title="Canned Replies" icon="clipboard" href="/ai-features/canned-replies">
    For static, non-AI quick replies.
  </Card>
</CardGroup>
