DEV Community

Ramandeep Singh
Ramandeep Singh

Posted on

How to build your own simple Agent

Many AI tools provide ready-made agents for customer service, but what if you want to build your own? Here’s a concise demo of a support agent that answers queries by routing them to specialized support agents in your UI application.

Demo gif

AI Tool: OpenAI Agents SDK

Project Example: Customer Support Agent

First, install the OpenAI Agents SDK

npm install @openai/agents
Enter fullscreen mode Exit fullscreen mode
  1. Just define agents as

typescript


const mainAgent = new Agent({
    name: "Main Agent",
    description: "A main agent that can help with product support issues",
    instructions: `You are a main agent that can help with product support issues.`,
    handoffs: [productSupportAgent, billingSupportAgent, accountSupportAgent],
});

Enter fullscreen mode Exit fullscreen mode

and then run the agent in typescript

typescript
const response = await run(mainAgent, userQuery);
return response.finalOutput;

Enter fullscreen mode Exit fullscreen mode

For the complete backend code, check out my GitHub repo here: https://github.com/r123singh/openai-typescript-agentsdk/tree/main/customer-support

Top comments (0)