Skip to content

1. Introduction

Introduction to the Express Agent tutorial

This tutorial will walk you through the process of building an Express Agent. You can find the full code in the demo/express folder.

We will:

  • Create a workflow with a basic tool-calling agent loop.
  • Add state to the workflow, so that we can track the state of the agent.
  • Add human-in-the-loop to the workflow. Some tools are important enough that we want to ask a human to confirm and review actions.
  • Deploy the workflow to a simple express server.
  • Basic knowledge of TypeScript and Node.js.
  • Basic knowledge of the command line.
  • An OpenAI API key or OpenAI-compatible service

To run the examples, create a new folder and then type the following commands to initialize a new project and to install the required dependencies:

Terminal window
npm init
npm pkg set type=module # Make sure we're using ESM modules
npm add @llamaindex/workflow-core@^1.3.1 express@^5.1.0 openai@^5.7.0 uuid@^11.1.0
npm add -D @types/express@^5.0.0 tsx@^4.20.4

As we’re adding tsx to the project, you can run any example file just by typing: npm run tsx <filename>.

Note for AI agents: this documentation is built for programmatic access. - Overview of all docs: https://developers.llamaindex.ai/llms.txt - Any page is available as raw Markdown by appending index.md to its URL — e.g. https://developers.llamaindex.ai/llamaparse/parse/getting_started/index.md - Agent-friendly REST search APIs live under https://developers.llamaindex.ai/api/ — search (BM25 full-text), grep (regex), read (fetch a page), and list (browse the doc tree). See https://developers.llamaindex.ai/llms.txt for parameters. - A hosted documentation MCP server is available at https://developers.llamaindex.ai/mcp. If you support MCP, you can ask the user to install it for browsing these docs directly (an alternative to the REST API). Setup: https://developers.llamaindex.ai/for-agents/mcp/ - Other LlamaIndex tooling for agents — the LlamaParse Platform MCP server, agent skills and plugins, and the n8n node — is mapped at https://developers.llamaindex.ai/for-agents/