Create an agent app

This guide shows you how to build and test a simple shirt ordering agent app. When interacting with this agent app, you can ask for the store location, get store hours, or make a shirt order.

Before you begin

You should do the following before reading this guide:

  1. If you have not already, follow the Dialogflow setup instructions.

About agent apps

An agent app is composed of one or more agents. Each agent has a clearly defined and limited scope. An agent has the following data:

X Item
Name A name used to identify the agent.
Goal Goals are high level descriptions of what the agent should accomplish.
Instructions Instructions are high level steps that should be taken to accomplish the agent's goal.
Examples Examples are sample conversations between an end-user and the agent. These examples are effectively few-shot prompt examples for the LLM.

Create the application

To create the application:

  1. Go to the Vertex AI Conversation console:

    Vertex AI Conversation console

  2. Select your project from the console drop-down.

  3. If you have not already activated the API, read and agree to the Terms of Service, then click Continue and activate the API.

  4. Click Create a New App or New App.

  5. Select Agent.

  6. Provide "Shirt Ordering Assistant" for the app name.

  7. Select a region.

  8. Click Create.

  9. The user interface takes you to the default agent named Default Agent.

  10. Click the back button to see the list of agents.

Create the order agent

The Order agent handles shirt orders. To create this agent:

  1. Click Create.
  2. Enter the name: Order.
  3. Enter the following goal:

    You are a shirt store ordering agent. Help customers purchase shirts.
    Help the customer choose a size and color.
    The shirts come in small, medium, and large.
    The shirts can be red, green, or blue.
    
  4. Enter the following instructions:

    - If the customer has not provided a size, ask them to choose a size.
    - If the customer has not provided a color, ask them to choose a color.
    - Once the customer has selected a size and color for the shirt,
      repeat the selection to the customer, and ask them to confirm the selection.
    - Once the customer has confirmed their selection,
      let them know that the shirt is now ordered.
    - Do not provide prices or collect payment.
    - Do not collect the customer's name or address.
    
  5. Click Save.

    Screenshot of order agent app

  6. Click the back button to return to the agent list.

Create the information agent

The Information agent handles questions about the store. To create this agent:

  1. Click Create.
  2. Enter the name: Information.
  3. Enter the following goal:

    You provide information about a shirt store.
    The store is open between 8 AM and 6 PM every day.
    The store is located at 1007 Mountain Drive, Gotham City, NJ.
    
  4. Enter the following instructions:

    - If the customer asks for the store location, provide them with the address.
    - If the customer asks for the store hours, provide them with the hours.
    
  5. Click Save.

  6. Click the back button to return to the agent list.

Update the default agent

When you first created the application, a default agent was created for you. This agent should steer the conversation to the appropriate agents with specific goals. In the instructions below, you can see how the default agent references the other agents. To update this agent:

  1. Click the default agent. This agent has a highlighted star.
  2. Enter the following goal:

    You are an agent for a shirt store.
    Your name is "Samantha".
    Your job is to direct customers to other agents based on the customer's questions.
    
  3. Enter the following instructions:

    - If the customer hasn't been greeted yet, greet the customer,
      introduce yourself, and ask the user how you can help.
    - If the customer wants information about the store,
      route them to ${AGENT: Information}
    - If the customer wants to purchase a shirt,
      route them to ${AGENT: Order}
    
  4. Click Save.

  5. Click the back button to return to the agent list.

Provide examples

At this point, your agent is functional. However, You must provide examples to ensure quality responses.

You can manually provide examples from the Examples tab when you have an agent open. However, it is often easier to have a conversation with the functioning agent and save the conversation as an example.

An example conversation with a default agent is short. This agent just needs to direct you to another agent. To have a conversation with the default agent:

  1. Close or cancel any panel that might be present on the right side of the screen. You want to see the simulator panel that contains Send a message to see how your agent responds.
  2. Select the default agent.
  3. Select the model: gemini-pro.
  4. In the text box that says Enter user input, type Hello, then press enter.
  5. The agent responds with a greeting.

To save this conversation as an example:

  1. Click the Save as an example button near the top right of the interface.
  2. The example editor panel opens. You can use this editor to add, edit, delete, or reorder actions.
  3. Provide the example name: Greeting.
  4. Update the agent responses as necessary.
  5. Click Save.

    Screenshot of greetings example

Add a location example for the information agent:

  1. Close or cancel any panel that might be present on the right side of the screen. If necessary, reset the conversation with the reset restart_alt button.
  2. Select the information agent.
  3. Select the model: gemini-pro.
  4. Enter the message: Where are you located?.
  5. The agent responds with a location.
  6. Save this conversation as an example named Location. Only the default agent examples can start with a user action, so you must delete the action that contains "Where are you located".

Add an hours example for the information agent:

  1. Similar to steps above, but enter the message: What are your hours? and name the example: Hours.

Add a selection example for the order agent:

  1. Similar to steps above, but name the example Selection, select the order agent, and send the following messages:

    • I want to buy a shirt
    • Large
    • Green
    • Yes

    Screenshot of example entry

Test the agent app

Your agent app is now ready to test. Open the simulator panel and have a conversation with the agent. You do not need to have the same conversations as above. For example, you can ask this agent app which colors are available for shirts. If you are not getting the desired behavior, refining your examples and creating new ones will improve responses.

Interacting with the agent app using the API

See Interactions with the API.