--- title: Connect applications to agents slug: /agent-tutorial --- import Icon from "@site/src/components/icon"; This tutorial shows you how to connect a JavaScript application to a [Langflow agent](/agents). With an agent, your application can use any connected tools to retrieve more contextual and timely data without changing any application code. The tools are selected by the agent's internal LLM to solve problems and answer questions. ## Prerequisites * [Install and start Langflow](/get-started-installation) * Create a [Langflow API key](/api-keys-and-authentication) * Install the [Langflow JavaScript client](/typescript-client) * Create an [OpenAI API key](https://platform.openai.com/api-keys) This tutorial uses an OpenAI LLM. If you want to use a different provider, you need a valid credential for that provider. ## Create an agent flow The following steps modify the **Simple Agent** template to connect a [**Directory** component](/legacy-core-components) and a [**Web Search** component](/web-search) as tools for an **Agent** component. The **Directory** component loads all files of a given type from a target directory on your local machine, and the **Web Search** component performs a DuckDuckGo search. When connected to an **Agent** component as tools, the agent has the option to use these components when handling requests. 1. In Langflow, click **New Flow**, and then select the **Simple Agent** template. 2. Remove the **URL** and **Calculator** tools, and then add **Directory** and **Web Search** components to your flow. 3. In the **Directory** component's **Path** field, enter the directory path and file types that you want to make available to the **Agent** component. In this tutorial, the agent needs access to a record of customer purchases, so the directory name is `customer_orders` and the file type is `.csv`. Later in this tutorial, the agent will be prompted to find `email` values in the customer data. You can adapt the tutorial to suit your data, or, to follow along with the tutorial, you can download [`customer-orders.csv`](/files/customer_orders.csv) and save it in a `customer_orders` folder on your local machine. 4. In the **Directory** and **Web Search** [components' header menus](/concepts-components#component-menus), enable **Tool Mode** so you can use the components with an agent. 5. Connect the **Directory** and **Web Search** components' **Toolset** ports to the **Agent** component's **Tools** port. 6. In the **Agent** component, enter your OpenAI API key. If you want to use a different provider or model, edit the **Model Provider**, **Model Name**, and **API Key** fields accordingly. 7. To test the flow, click