← Back to Tutorials

3. Build Your First Agent

Hello World Agent

Let's build a simple agent that greets users and remembers their name.

JavaScript / TypeScript

import { Agent, AgentClient } from "@microsoft/agents";
import { DefaultAzureCredential } from "@azure/identity";

const agent = new Agent({
  name: "GreeterAgent",
  instructions: "You are a friendly greeter. Greet the user warmly and remember their name.",
  model: "gpt-4o",
  auth: new DefaultAzureCredential(),
});

const client = new AgentClient(agent);
const response = await client.sendMessage("Hi, I'm Snehal!");
console.log(response.text);

Agent Configuration

PropertyDescriptionExample
nameUnique identifier"GreeterAgent"
instructionsSystem prompt defining behavior"You are a friendly..."
modelLLM to use"gpt-4o"
temperatureCreativity (0-1)0.7

Prompt Design Best Practices

Agent Lifecycle

An agent progresses through these states:

  1. Created — definition saved
  2. Configured — memory, tools, and guardrails attached
  3. Active — ready to receive messages
  4. Processing — handling a conversation turn
  5. Idle — waiting for next input
Agent workflow loop: input, parse, LLM, tool execution, guardrails, respond
✏️ Exercise: Modify the GreeterAgent to greet the user in a different language based on their preference. Add a language property to the instructions and test with "Hello" in Spanish, French, and Japanese.