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

# SMS AI Agent

> Build an SMS agent for appointment management and customer queries

In this guide, we will walk you through building an Inbound SMS Agent to handle appointment-related queries such as cancellations, reschedules, and confirmations for a dentist's office. The SMS agent will be deployed on the dentist's phone number, and customers will interact via SMS for appointment management.

<Steps>
  <Step title="Define the Use Case">
    Before you begin building the agent, clearly define the use case and understand the customer’s needs. Think about the various scenarios a customer might encounter when communicating with your office via SMS. For example:

    * The customer responds to a reminder SMS and confirms their appointment.
    * The customer requests to cancel or reschedule the appointment.
    * The customer asks about the late policy or other appointment-related queries.
    * The customer asks questions regarding general policies (e.g., refund policy, office hours).

    Be sure to also consider any edge cases that may arise (e.g., customer asking about something outside of the scope).
  </Step>

  <Step title="Prepare a Mental Framework for the Agent’s Tasks">
    Imagine hiring a human customer service agent. Prepare a job description for your SMS agent that lists out the tasks it needs to handle. Some tasks for your inbound SMS agent might include:

    * Acknowledging appointment confirmations.
    * Handling customer questions about the late policy, rescheduling, and cancellations.
    * Verifying customer information and updating the calendar.
    * Referring to the knowledge base for general queries like the clinic's hours, services, or pricing.
    * Escalating to a human representative when needed (e.g., for complex or out-of-scope queries).
  </Step>

  <Step title="Define the Agent’s Tasks in Detail for Vibe Agent">
    Once you have a mental framework in place, define the tasks for the Vibe Agent in as much detail as possible. For instance:

    * The agent should greet the customer and acknowledge their response to the appointment reminder SMS.
    * If the customer confirms, the agent should thank them for the confirmation.
    * Handling late arrivals:
      * If the customer mentions being 10 minutes late, acknowledge that it's okay.
      * If the customer mentions being 10-30 minutes late, inform them of a late fee.
      * If the customer mentions being more than 30 minutes late, suggest they reschedule.
    * Rescheduling: If the customer wants to reschedule, check available slots in the calendar up to 1 week.
    * Cancellation: If the customer wants to cancel, the agent should cancel the appointment in the calendar and confirm the cancellation with the customer.
    * Handling general queries: If the customer asks about general policies (e.g., refund, office hours), the agent should refer to the knowledge base.

    Here’s a sample prompt for the agent:

    > I want to create an Inbound SMS Agent for my dentist's office that handles appointment-related queries. The agent will greet the customer and confirm their appointment if they respond to the reminder SMS. If the customer is late (within 10-30 minutes), the agent will inform them about the late fee. If they are more than 30 minutes late, the agent will suggest rescheduling. If the customer wants to cancel, the agent should cancel the appointment and confirm the cancellation. If the customer wants to reschedule, the agent will check available time slots and provide options. The agent will also handle general queries (like office hours, refund policy) by referring to the knowledge base and escalate to a human representative when necessary.

    <Frame>
      <img src="https://mintcdn.com/plivo/R0bB3pSVhMhsNJEx/aiagent/images/buildsmsagent1.jpg?fit=max&auto=format&n=R0bB3pSVhMhsNJEx&q=85&s=a7067702943015e4aa4e7193b3394e79" alt="" width="2880" height="1760" data-path="aiagent/images/buildsmsagent1.jpg" />
    </Frame>
  </Step>

  <Step title="Let Vibe Agent Work Its Magic">
    Allow [Vibe Agent](/docs/aiagent/aistudio/vibeagent) to place nodes in the agent flow builder. It will automatically generate the flow based on the prompts you’ve provided. Be patient and let it complete the flow. Occasionally, you might need to manually intervene (e.g., authorizing [third-party applications](/docs/aiagent/aistudio/mcptools) for tool calls like Calendar).

    <Frame>
      <img src="https://mintcdn.com/plivo/R0bB3pSVhMhsNJEx/aiagent/images/buildsmsagent2.png?fit=max&auto=format&n=R0bB3pSVhMhsNJEx&q=85&s=050e7c7f8a71a4bfccf9d90375dd1fc9" alt="" width="2166" height="1200" data-path="aiagent/images/buildsmsagent2.png" />
    </Frame>
  </Step>

  <Step title="Review the Workflow and Validate the Happy Path and Edge Cases">
    Once the [Vibe Agent](/docs/aiagent/aistudio/vibeagent) completes the first draft, review the entire workflow:

    * Verify if the agent is correctly identifying the customer’s status (appointment confirmed, reschedule, cancel).
    * Check the intent behind each [path](/docs/aiagent/aistudio/path) (confirming appointments, handling late arrivals, etc.).
    * Ensure the correct API calls (like checking calendar slots) are set up.
    * Ensure the [knowledge base](/docs/aiagent/aistudio/agentconfiguration/knowledgebase) is properly configured for answering general queries like office hours, refund policies, and late fees.

    <Frame>
      <img src="https://mintcdn.com/plivo/R0bB3pSVhMhsNJEx/aiagent/images/buildsmsagent3.png?fit=max&auto=format&n=R0bB3pSVhMhsNJEx&q=85&s=1b6896de100353e4c14068a0d02963d7" alt="" width="2164" height="1202" data-path="aiagent/images/buildsmsagent3.png" />
    </Frame>
  </Step>

  <Step title="Make Adjustments Based on New Edge Cases">
    While reviewing, if you think of a new edge case or find something that doesn’t work, you can either:

    * Ask Vibe Agent to fix it automatically by providing a detailed prompt.
    * Make the necessary changes directly in the flow builder.
  </Step>

  <Step title="Make Changes Yourself (If Necessary)">
    While Vibe Agent can handle most tasks, sometimes you may want to make minor adjustments yourself. Use our [Node Reference Guide](/docs/aiagent/aistudio/nodereference/aiconversation) to fully understand the available nodes and how to configure them for your specific use case.
  </Step>

  <Step title="Test the Agent">
    Test the agent by starting simple and expanding the complexity gradually. Use the [Playground](/docs/aiagent/aistudio/playground) to run initial tests, verifying basic functionalities such as:

    * Confirming appointments
    * Handling late arrivals and cancellations
    * Responding to generic queries from the knowledge base
  </Step>

  <Step title="Make Fixes if the Agent Isn’t Performing as Expected">
    If you find that the agent isn’t performing as expected in certain scenarios, go back to the Vibe Agent:

    * Provide a detailed prompt about what needs fixing.
    * Let it update the flow accordingly.
    * Alternatively, make the changes directly in the flow builder.
  </Step>

  <Step title="Deploy the Agent">
    Once you are satisfied with the agent's performance:

    * [Purchase a number from Plivo](/docs/aiagent/deploy/buynumber) (if you haven’t already).
    * Link the number to your [SMS Agent](/docs/aiagent/deploy/sms/smsagent) configuration.
    * Deploy the agent to handle real SMS.
  </Step>
</Steps>

Your SMS agent is now ready to handle customer appointments, confirmations, cancellations, and reschedules.
