Skip to main content

1. Create Your Project

The fastest way to start is with the CLI:
This creates the following structure:

2. Understanding main.ts

Every Runflow agent needs a main.ts file at the project root. It must export an async function main() — this is the function the Runflow engine calls when your agent receives a message.
The main.ts file and the export async function main() are required. Without them, your agent won’t work when deployed or tested with rf test.

3. Add Memory

Enable conversation history so your agent remembers previous messages:
Memory is automatically bound to the user you identified with identify(). Same user = same conversation history across sessions.

4. Add a Tool

Tools let your agent perform actions — call APIs, query databases, send messages. Create them in separate files under tools/:
tools/weather.ts
Then register it in your agent:
main.ts
Always mention your tools in the agent’s instructions. The LLM needs to know when to use each tool. Be specific: “Use the weather tool when users ask about temperature or weather conditions.”

5. Test Locally

Run the interactive testing interface:
This opens a web UI where you can:
  • Chat with your agent in real time
  • See which tools are being called
  • Inspect memory and trace data
  • Test conversation continuity

6. Add Business Metrics

Use track() to emit events that power dashboards in the Runflow portal:
main.ts

7. Deploy

When you’re ready, deploy to production:

Next Steps

Project Structure

Learn how to organize your project as it grows

Best Practices

Tips for writing effective agents

Core Concepts

Deep dive into Agents, Memory, Tools, and more

Real-World Examples

See production-ready examples