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

# Writing and Optimizing

> A guide on the fundamental principles and best practices for creating high-performance prompts for Volubile voice agents.

## Designing Prompts for AI Voice Agents

The effectiveness of your AI voice agents largely relies on the quality of the prompts you design. A well-crafted prompt guides the language model (LLM) to interact in a relevant, natural manner and aligns with your business objectives. This page details the fundamental principles and best practices for creating high-performance prompts for Volubile phone agents.

## The Foundations of Prompt Writing

A prompt is the initial instruction you provide to the LLM. It defines the context, the task to be accomplished, the tone to adopt, and the constraints to respect.

### Clarity and Precision

<Note>
  The LLM interprets your instructions literally. Therefore, be as clear and precise as possible.
</Note>

<CardGroup cols={3}>
  <Card title="Avoid Ambiguities" icon="circle-exclamation">
    Vague terms can lead to unexpected and inconsistent responses.
  </Card>

  <Card title="Define Jargon" icon="book">
    If your field uses specific vocabulary, clarify it in the prompt.
  </Card>

  <Card title="Specify Format" icon="align-left">
    Be explicit about the expected output format if necessary.
  </Card>
</CardGroup>

### Provide Context

The more relevant context the LLM has, the better it can tailor its response to the specific situation.

<Tabs>
  <Tab title="Agent's Role">
    ```text theme={null}
    You are a Volubile technical support agent tasked with helping customers resolve
    their connectivity issues with the platform. You are patient, methodical, and you
    communicate clearly.
    ```

    <Tip>
      Describe not only the agent's function but also their "personality" to achieve the desired tone.
    </Tip>
  </Tab>

  <Tab title="Call Context">
    ```text theme={null}
    If the user is calling because they cannot log into the platform, the most common issues are:
    1. Forgotten password (70% of cases)
    2. Username entry error (20% of cases)
    3. Account locked after too many attempts (10% of cases)
    ```

    <Tip>
      Include information on likely scenarios to help the agent anticipate needs.
    </Tip>
  </Tab>

  <Tab title="Dynamic Information">
    ```text theme={null}
    Available customer information:
    - Name: {{client.name}}
    - Email: {{client.email}}
    - Last login: {{client.last_login}}
    - Account status: {{client.account_status}}
    ```

    <Tip>
      Use context variables to personalize the interaction in real-time.
    </Tip>

    <Card title="Context" icon="brackets-curly" href="./prompt/context" horizontal>
      For more information on call contexts
    </Card>
  </Tab>
</Tabs>

### Use Examples (Few-Shot Prompting)

Providing concrete examples of questions and expected answers can significantly enhance the model's performance, especially for complex tasks or specific formats.

<CodeGroup>
  ```text Example 1 theme={null}
  User: "Hello, I can't reset my password."
  Agent: "Hello, I understand. To reset your password, you can go to our website
  volubile.ai/reset and follow the instructions. Have you tried this approach?"
  ```

  ```text Example 2 theme={null}
  User: "I have a problem with my invoice."
  Agent: "I can help you with that. Could you please provide me with your customer number or the invoice number
  in question?"
  ```

  ```text Example 3 theme={null}
  User: "Your service is really bad!"
  Agent: "I'm really sorry to hear that you had a bad experience. I'm here to help you resolve this
  issue. Can you please clarify what happened so I can provide you with the best solution?"
  ```
</CodeGroup>

<Tip>
  Include varied examples, including difficult situations or special cases, to prepare the agent for
  all possible scenarios.
</Tip>

### Define Constraints

Clearly indicate what the agent should not do or say to avoid undesirable behaviors.

<AccordionGroup>
  <Accordion title="Form Constraints" icon="ruler">
    * **Response Length:** "Limit your responses to 2 or 3 concise sentences to maintain a natural conversational pace over the phone."
    * **Style:** "Adopt a professional and empathetic tone. Avoid technical jargon unless the user seems comfortable with those terms."
    * **Structure:** "Structure your explanations in clear, numbered steps when giving instructions."
  </Accordion>

  <Accordion title="Content Constraints" icon="shield">
    * **Confidential Information:** "Never ask for the user's full password. Do not disclose any personal information about other customers."
    * **Service Limitations:** "Do not make promises that the company cannot keep. If you don't know the answer, offer to transfer the call to a specialist."
    * **Sensitive Topics:** "Avoid discussions on political, religious, or controversial issues, even if the user brings them up."
  </Accordion>

  <Accordion title="Regulatory Constraints" icon="scale-balanced">
    * **Nature of the Agent:** "Specify that you are an AI assistant if asked."
    * **Legal Disclaimers:** "For calls regarding contracts, always specify that 'This call is recorded for training and quality control purposes.'"
  </Accordion>
</AccordionGroup>

## Optimizing Prompts

Creating prompts is an iterative process. Continuously test and refine your prompts to achieve the best results.

### Iteration and Testing

<Steps>
  <Step title="Start Simple">
    Begin with a basic prompt that covers essential functionalities.
  </Step>

  <Step title="Test with Varied Scenarios">
    Pose simple, complex, unexpected, or poorly formulated questions to the agent to assess its robustness.
  </Step>

  <Step title="Analyze Responses">
    Identify weaknesses and note cases where the agent deviates from the desired behavior.
  </Step>

  <Step title="Adjust and Strengthen">
    Modify the prompt by enhancing problematic instructions. Using superlatives like "it is very important that" can help reinforce certain constraints.
  </Step>

  <Step title="Repeat the Process">
    Continue testing and refining until satisfactory performance is achieved across all scenarios.
  </Step>
</Steps>

### Structuring the Prompt

Use delimiters (such as ###) to clearly structure the different sections of your prompt (context, instructions, examples, constraints). This helps the LLM better understand the request.

```md theme={null}
### Role ###
You are a virtual agent of Volubile, specializing in scheduling appointments for our sales advisors.

### Context ###
The user is calling to schedule a demonstration of our new software solution.

### Instructions ###
1. Greet the user professionally and friendly.
2. Ask for their availability for the current week and the next.
3. Offer a specific time slot based on the advisors' calendar availability (accessible via the `get_calendar_availabilities` tool).
4. Confirm the appointment by summarizing the date and time.
5. If no slots are suitable, suggest contacting them again later.

### Constraints ###
- Do not offer appointments on weekends.
- Limit each intervention to a maximum of two sentences.
- Use formal address.

### Examples ###
User: "I would like to schedule an appointment for a demo."
Agent: "Hello! I’d be happy to assist. What would your availability be this week or next for a demonstration?"
```

### Watch the Length

While context is important, an excessively long prompt can introduce noise and dilute key instructions. Focus on relevant information for the task at hand.
