Use this file to discover all available pages before exploring further.
Every Runflow project follows a simple convention: a main.ts file at the root that exports an async function main(). As your project grows, you organize code into folders that map directly to SDK concepts.
The main.ts file is the only required file. It must export an async function main(input) — this is the contract between your code and the Runflow engine.
main.ts
import { Agent, openai } from '@runflow-ai/sdk';import { identify } from '@runflow-ai/sdk/observability';const agent = new Agent({ name: 'My Agent', instructions: '...', model: openai('gpt-4o'),});export async function main(input: any) { identify(input.email || input.phone); const result = await agent.process({ message: input.message, sessionId: input.sessionId, }); return { message: result.message };}
What main() receives:
input.message — the user’s message (always present)
Centralize your prompts in a dedicated file, especially when they’re long or have multiple scenarios:
prompts/index.ts
export const systemPrompt = `You are a customer support agent for ACME Corp.## Behavior- Always be professional and empathetic- Respond in the customer's language- Search the knowledge base before answering technical questions## Tools- Use create-ticket for issues that need human follow-up- Use search-orders when customers ask about their orders- Use send-email to notify the team about urgent issues## Response Format- Be concise but complete- Use bullet points for lists- Always confirm actions taken`;export const escalationPrompt = `A customer issue needs escalation.Customer: {{customerName}}Issue: {{issue}}Priority: {{priority}}Write a brief summary for the support team.`;
For prompts managed through the Runflow portal, use loadPrompt() instead of local files. See Prompts for details.