|
| 1 | +--- |
| 2 | +title: Build an agent from a template |
| 3 | +sidebarTitle: Template quickstart |
| 4 | +--- |
| 5 | + |
| 6 | +Create your first AI agent step-by-step. No coding required. In this quickstart, you'll use the pre-defined **Email Assistant** [template](/langsmith/agent-builder-templates) that organizes and manages your inbox for you. |
| 7 | + |
| 8 | +Feel free to follow along with this example or you can: |
| 9 | + |
| 10 | +- Customize the instructions and tools for your own agent needs. |
| 11 | +- Select a different template. |
| 12 | + |
| 13 | +<Callout icon="comment" color="#8B5CF6" iconType="regular"> |
| 14 | +You'll interact with your agent through chat, just like texting a helpful assistant. |
| 15 | +</Callout> |
| 16 | + |
| 17 | +## Before you start |
| 18 | + |
| 19 | +You'll need: |
| 20 | +- A LangSmith account ([sign up here](https://smith.langchain.com)). |
| 21 | +- A Gmail account. |
| 22 | +- A Google calendar. |
| 23 | +- An OpenAI or Anthropic API key (Step 1 will show you how to get one). |
| 24 | + |
| 25 | +## Step 1. Get your API key |
| 26 | + |
| 27 | +Your agent needs an API key to connect to an AI model. The AI model is what allows your agent to understand and respond to your requests. |
| 28 | + |
| 29 | +<Tabs> |
| 30 | + <Tab title="OpenAI (ChatGPT)"> |
| 31 | + 1. Go to [platform.openai.com/api-keys](https://platform.openai.com/api-keys). |
| 32 | + 1. Click **Create new secret key**. |
| 33 | + 1. Give it a name like "Agent Builder". |
| 34 | + 1. Copy the key (it starts with `sk-`). |
| 35 | + 1. Save it somewhere safe, you'll need it in Step 2. |
| 36 | + </Tab> |
| 37 | + |
| 38 | + <Tab title="Anthropic (Claude)"> |
| 39 | + 1. Go to [console.anthropic.com/settings/keys](https://console.anthropic.com/settings/keys). |
| 40 | + 2. Click **Create Key**. |
| 41 | + 3. Give it a name like "Agent Builder". |
| 42 | + 4. Copy the key (it starts with `sk-ant-`). |
| 43 | + 5. Save it somewhere safe, you'll need it in Step 2. |
| 44 | + </Tab> |
| 45 | +</Tabs> |
| 46 | + |
| 47 | +<Info> |
| 48 | +**Cost:** Both services charge based on use. |
| 49 | +</Info> |
| 50 | + |
| 51 | +## Step 2. Add your API key to LangSmith |
| 52 | + |
| 53 | +Now you'll add your API key to LangSmith so your agents can use it: |
| 54 | + |
| 55 | +<Steps> |
| 56 | + <Step title="Open Settings"> |
| 57 | + 1. Go to [smith.langchain.com](https://smith.langchain.com). |
| 58 | + 2. Click the <Icon icon="gear" /> **Settings** icon in the bottom left. |
| 59 | + </Step> |
| 60 | + |
| 61 | + <Step title="Go to Secrets"> |
| 62 | + Click the **Secrets** tab at the top. |
| 63 | + </Step> |
| 64 | + |
| 65 | + <Step title="Add your key"> |
| 66 | + 1. Click **Add secret**. |
| 67 | + 2. For **Key**, enter: |
| 68 | + - `OPENAI_API_KEY` (if using OpenAI) |
| 69 | + - `ANTHROPIC_API_KEY` (if using Anthropic) |
| 70 | + 3. For **Value**, paste the API key you copied in Step 1. |
| 71 | + 4. Click **Save secret**. |
| 72 | + </Step> |
| 73 | +</Steps> |
| 74 | + |
| 75 | +<Callout type="success" icon="check" color="#10B981" iconType="regular"> |
| 76 | +Your agent now has access to an AI model to understand and respond to your requests. Next, you'll create your agent. |
| 77 | +</Callout> |
| 78 | + |
| 79 | +## Step 3. Create your agent |
| 80 | + |
| 81 | +<Steps> |
| 82 | + <Step title="Navigate to Agent Builder"> |
| 83 | + 1. In the [LangSmith UI](https://smith.langchain.com), click <Icon icon="mouse-pointer"/> **Switch to Agent Builder** at the top of the left-hand navigation. |
| 84 | + </Step> |
| 85 | + |
| 86 | + <Step title="Choose a template"> |
| 87 | + 1. Select **Templates** in the left-hand navigation. |
| 88 | + 1. Select **Email Assistant** template. |
| 89 | + 1. Click **Use this template**. |
| 90 | + |
| 91 | + <Tip> |
| 92 | + If you don't want to start with a template, you have two other options. From the **+ New Agent** page: |
| 93 | + - Use the chat interface to describe your agent, and it will help you create it step-by-step. |
| 94 | + - Select **Create manually instead** to build your agent without any pre-filled responses on the configuration page. |
| 95 | + </Tip> |
| 96 | + </Step> |
| 97 | + |
| 98 | + <Step title="Authorize accounts"> |
| 99 | + Your agent will ask you to connect your Google accounts: |
| 100 | + |
| 101 | + 1. Click **Connect**. |
| 102 | + 2. Sign in with your Google account. |
| 103 | + 3. Review permissions and click **Allow**. |
| 104 | + 4. You'll be redirected back to LangSmith where your agent will be created. |
| 105 | + </Step> |
| 106 | + |
| 107 | +</Steps> |
| 108 | + |
| 109 | +<Info> |
| 110 | +Your agent only accesses your accounts when working on tasks you give it. You can revoke access anytime in your Google account settings. |
| 111 | +</Info> |
| 112 | + |
| 113 | +## Step 4. View the agent template |
| 114 | + |
| 115 | +<Steps> |
| 116 | + |
| 117 | + <Step title="View and customize the template"> |
| 118 | + |
| 119 | + At this point, you can review the template instructions for the email assistant. If needed, you can make adjustments to the instructions. |
| 120 | + |
| 121 | + If you made any changes, click **Save changes**. |
| 122 | + </Step> |
| 123 | + |
| 124 | + <Step title="Start a test chat"> |
| 125 | + 1. In the right-hand panel of the configuration page, select the **Test Chat** tab. |
| 126 | + 2. Try out the email assistant in the chat interface, for example: |
| 127 | + |
| 128 | + > _Apply a "Review" label to emails that I receive, which require some kind of review from me_ |
| 129 | + </Step> |
| 130 | + |
| 131 | + <Step title="Agent starts working"> |
| 132 | + Your agent will start work and provide a **Continue** option for each step that requires your approval. |
| 133 | + |
| 134 | + <img |
| 135 | + className="block dark:hidden" |
| 136 | + src="/langsmith/images/agent-builder-response.png" |
| 137 | + alt="Test chat output view with response including approvals for Gmail tool." |
| 138 | + /> |
| 139 | + |
| 140 | + <img |
| 141 | + className="hidden dark:block" |
| 142 | + src="/langsmith/images/agent-builder-response-dark.png" |
| 143 | + alt="Test chat output view with response including approvals for Gmail tool." |
| 144 | + /> |
| 145 | + |
| 146 | + 3. As you test out the agent, you can make edits to the instructions, or add tools that you may need. Click **Save changes** when you're happy with the results. |
| 147 | + |
| 148 | + </Step> |
| 149 | + |
| 150 | +</Steps> |
| 151 | + |
| 152 | +## Edit your agent |
| 153 | + |
| 154 | +You may want to update your agent's instructions or include more tools. You can directly chat with your agent to ask for updates, or you can: |
| 155 | + |
| 156 | +1. From **My Agents** in the left-hand navigation, select the agent you want to edit. |
| 157 | +1. Select <Icon icon="pencil"/> **Edit Agent**. |
| 158 | + |
| 159 | +From the agent's edit page, you can: |
| 160 | + |
| 161 | +- Add tools with **+ Add tool** to connect more apps and services like Slack, GitHub, or Linear. |
| 162 | +- Add further helpers with **+ Add sub-agent** to break complex tasks into specialized sub-tasks. |
| 163 | +- Request pauses for reviews on existing tools. |
| 164 | +- Modify existing tools. |
| 165 | +- Explore features that can trigger your agent to start a task. |
| 166 | + |
| 167 | +## Next steps |
| 168 | + |
| 169 | +Now that you've created your first agent, here's what to explore: |
| 170 | + |
| 171 | +<CardGroup cols={2}> |
| 172 | + <Card title="Try more templates" icon="shapes" href="/langsmith/agent-builder-templates"> |
| 173 | + Explore pre-built agents for common tasks |
| 174 | + </Card> |
| 175 | + |
| 176 | + <Card title="Add automation" icon="bolt" href="/langsmith/agent-builder-essentials#triggers"> |
| 177 | + Run your agent automatically with triggers (Slack, email, schedules) |
| 178 | + </Card> |
| 179 | + |
| 180 | + <Card title="Connect more tools" icon="puzzle-piece" href="/langsmith/agent-builder-tools"> |
| 181 | + Add Slack, GitHub, Linear, and more |
| 182 | + </Card> |
| 183 | + |
| 184 | + <Card title="Build complex agents" icon="sitemap" href="/langsmith/agent-builder-essentials#sub-agents"> |
| 185 | + Use sub-agents to break down big tasks |
| 186 | + </Card> |
| 187 | +</CardGroup> |
0 commit comments