In Gemini Enterprise, agents are created within the context of an
[app](https://docs.cloud.google.com/gemini/enterprise/docs/concepts#ase-apps). You can create a new agent in
two primary ways:

- [Create an agent using a prompt](https://docs.cloud.google.com/gemini/enterprise/docs/agent-designer/create-agent#create-agent-prompt): This is the quickest way to create an agent. You describe the agent's purpose, and Workflow Builder generates the initial version for you within your app. This is ideal for basic agents or as a starting point for more complex ones.
- [Create an agent using the flow builder](https://docs.cloud.google.com/gemini/enterprise/docs/agent-designer/create-agent#create-agent-flow): This method gives you direct, granular control over the agent's design from the beginning. It's ideal for designing complex, multi-step agents that require specific subagent configurations and logic flows.

These methods are flexible, and
you can combine them to suit your requirements. For example, you can start with
a prompt to generate the initial agent and then switch to the flow builder to
visually refine its logic and add complexity.

## Best practices for creating agents

To ensure your agents perform effectively and efficiently, consider the
following best practices:

- **Define clear objectives:** clearly state what you want your agent to achieve. A well-defined objective helps in designing the agent's logic and evaluating its performance.
- **Start small, then expand:** begin with a basic agent that handles core functionalities. Once it's stable, gradually add more features and complexity.
- **Break down complex tasks:** for multi-step agents, divide large tasks into smaller, manageable sub-tasks. Each subagent should have a specific role.
- **Test iteratively:** regularly test your agent at each stage of development. This helps identify and fix issues early.
- **Provide clear instructions:** when using prompts, be specific and concise. Avoid ambiguity to ensure the agent understands its purpose. See [Best
  practices for writing prompts to create an agent](https://docs.cloud.google.com/gemini/enterprise/docs/agent-designer/create-agent#best-practice-prompt).

## Before you begin

- Ensure you have an app with the necessary data sources connected. For more information, see [Create an app](https://docs.cloud.google.com/gemini/enterprise/docs/create-app), [Connect a
  Google data source](https://docs.cloud.google.com/gemini/enterprise/docs/create-data-store), and [Connect a
  third-party data
  source](https://docs.cloud.google.com/gemini/enterprise/docs/connect-third-party-data-source).
- Ensure that you have enabled the Agent Designer feature toggle for your web app. For more information, see [Manage web app
  features](https://docs.cloud.google.com/gemini/enterprise/docs/manage-web-app-features).

## Create an agent using a prompt

Use this method to quickly generate an agent using conversational input.

### Console

To create an agent using a natural language prompt, do the following:

1. In the Google Cloud console, go to the **Gemini Enterprise
   \> Apps** page.

   [Gemini Enterprise](https://console.cloud.google.com/gemini-enterprise/)
2. Select your app and copy the Gemini Enterprise web app
   URL from the **Dashboard**.

3. Open the web app URL in a new browser tab.

4. In the web app navigation menu, click **+ Create agent**.

   The **Workflow Builder** page appears.
5. In the chat box, enter a
   prompt that describes your agent's purpose and intended behavior.

   > [!NOTE]
   > **Note:** You can't use conversational prompts to enable or connect to data stores from the *Cloud sources* category (for example, BigQuery, Cloud Storage, Cloud SQL). Create your agent using the flow builder for such tasks.

   > [!TIP]
   > **Tip:** See [Best practices for writing prompts to create an
   > agent](https://docs.cloud.google.com/gemini/enterprise/docs/agent-designer/create-agent#best-practice-prompt).

6. Optional: Click ![Agents
   icon](https://docs.cloud.google.com/static/gemini/enterprise/docs/images/agent-designer/database_spark_icon.png)
   **Manage your data** and enable or disable the data sources you want your
   agent to use.

7. Optional: Click **Add files** to upload
   any additional reference materials for your agent to use.

8. Click **Submit**.

   The Workflow Builder canvas appears, displaying a live preview of
   your agent.
9. In the **Preview** tab, interact with your agent to test and
   evaluate its responses.

10. Optional: Refine your agent's function and behaviour by providing
    additional instructions in the left chat pane.

11. To view the overall details of your agent, go to the **Flow** tab and click the main agent node.

    - Optional: In the **Knowledge** section, click **Add files** to upload any additional reference materials for your agent.
    - Optional: In the **Personalization** section, add starter prompts that guide users on how to interact with the agent. You can add as many starter prompts as you like, but the system shows you a random selection of up to three prompts at a time.
12. Optional: Click the **Schedule** tab to configure execution schedules for your agent. For more information about agent schedules, see [Schedule agent executions](https://docs.cloud.google.com/gemini/enterprise/docs/agent-designer/schedule-agent).

13. Click **Create** to
    launch and start using your agent.

    > [!NOTE]
    > **Note:** Exiting the Workflow Builder canvas without clicking **Create** puts your agent in a *Draft* state.

### Best practices for writing prompts to create an agent

The prompt you provide helps Gemini understand your goals and generate
the best possible agent. To get clear and relevant responses, follow these
guidelines and best practices:

- **Provide enough context to eliminate ambiguity**

  Be specific about what you want the agent to do. For example, specify the
  level of detail, the types of examples to use, or the required output. This
  helps Gemini Enterprise to generate an agent plan that is
  more relevant and specific to your needs.

  Not recommended: `Create an agent for sales emails.`

  Recommended: `Create an agent that drafts follow-up emails for new sales leads from my CRM. It should search for the contact's company, summarize their business, and suggest how our product can help them.`
- **Set boundaries or limitations on the agent's output**

  Define what the agent should and shouldn't do. You can set limits on the
  length of its responses, the format, the tone, or specific elements to
  include or exclude. This helps the agent stay focused and produce more
  predictable results.

  Not recommended: `Create a sales email agent.`

  Recommended: `Create an agent that drafts follow-up emails for sales leads. The drafts should always use a professional tone, be no more than three paragraphs, and never include personal information about the client.`
- **Prompt Gemini to ask you questions**

  Instruct Gemini to ask you questions, if needed. This allows
  Gemini to gather details that it might have missed, and ensures
  that the resulting agent plan meets your expectations.

  Not recommended: `Create an agent to handle sales emails.`

  Recommended: `I need an agent that can help me draft sales emails. First, ask me what information you need to effectively qualify a lead and draft a personalized message.`

**Examples of effective prompts**

- **Simple example:** `Create a sales email agent that drafts concise
  follow-up emails to new leads. The tone should be professional, and the
  email should be no more than three paragraphs.`

- **Advanced example:** `Create an agent that automatically drafts sales
  emails to leads. Use my Gmail and access emails with the 'leads' label.
  First, ask me to confirm which leads you should prioritize and what the main
  selling points are for each. Once you have this information, your drafts
  should be no more than three paragraphs and use a professional tone. Don't
  include any technical jargon or slang and never include any personal
  information about the client.`

## Create an agent using the flow builder

Use this method for granular control over agent design, model selection, and
multi-step orchestration.

### Console

To create an agent using the flow builder, do the following:

1. Open your Gemini Enterprise web app in a browser.
2. In the web app navigation menu, click **+ Create agent**.

   The **Workflow Builder** page appears.
3. Click **Proceed to builder** to directly open the **Workflow Builder \> Flow** tab.

   A default agent named **My Agent** is created in the Workflow Builder canvas.
4. To view and configure the overall agent details,
   click the **My Agent** node and do the following:

   1. **Name:** enter a name for your agent.
   2. **Description:** enter a summary of the agent's purpose.
   3. **Instructions:** provide a detailed set of instructions that define the agent's objectives, tasks, and behaviors.
   4. **Model:** select the Gemini LLM model for the agent to use.
   5. **Data and tools:** click **Add data sources \&
      tools** to add the data sources connected to your app.
   6. Optional: In the **Knowledge** section, click **Add files** to upload any additional reference materials for your agent.
   7. Optional: In the **Personalization** section, add starter prompts that guide users on how to interact with the agent. You can add as many starter prompts as you like, but the system shows you a random selection of up to three prompts at a time.
5. Build your
   subagent flow:

   1. In the **Flow** tab, hold the pointer over the main agent node, and then click **Add
      subagent**.
   2. Configure the subagent details.
6. Repeat *step 5* as
   needed to complete your subagent flow logic.

7. Optional: Click the **Schedule** tab to configure execution schedules for your agent.

8. Click the **Preview** tab to interact with your agent to test and
   evaluate if your agent flow logic is performing as expected.

9. Click
   **Create** to launch and start using your agent.

   > [!NOTE]
   > **Note:** Exiting the Workflow Builder canvas without clicking **Create** puts your agent in a *Draft* state.

## What's next

- Learn how to [use an
  agent](https://docs.cloud.google.com/gemini/enterprise/docs/agent-designer/use-agent).
- Learn how to [schedule agent executions](https://docs.cloud.google.com/gemini/enterprise/docs/agent-designer/schedule-agent).
- Learn how to [edit an
  agent](https://docs.cloud.google.com/gemini/enterprise/docs/agent-designer/edit-agent).
- Learn how to [delete an
  agent](https://docs.cloud.google.com/gemini/enterprise/docs/agent-designer/delete-agent).