Environment Setup

Create a .env file:

OPENAI_API_KEY=your_openai_key
ZENDESK_SUBDOMAIN=your_subdomain
ZENDESK_API_TOKEN=your_api_token

Zendesk API Setup

  1. Go to Admin > Channels > API
  2. Create a new API token
  3. Note your subdomain (e.g., company.zendesk.com)

Agent Configuration

You can customize the agent’s behavior:

const supportAgent = createAgent({
  instructions: `You are a support agent that:
    - Verifies customer identity first
    - Creates tickets for valid requests
    - Maintains a professional tone
    - Escalates complex issues`,
  actions: [getCustomerInfo, createTicket],
  llm: createOpenAILLM({
    apiKey: process.env.OPENAI_API_KEY,
    model: "gpt-4-turbo-preview",
  }),
  training: {
    // Custom training instructions
    systemInstructions: `
      Always verify customer identity before taking actions.
      Create tickets only for actionable requests.
      Respond professionally and clearly.
    `,
  },
});

Action Configuration

Configure action behavior:

const getCustomerInfo = createAction({
  id: "getCustomerInfo",
  description: "Get customer information from email or ID",
  retries: 2,
  async run(context) {
    const zendesk = new ZendeskAPI({
      subdomain: process.env.ZENDESK_SUBDOMAIN,
      token: process.env.ZENDESK_API_TOKEN,
      timeout: 5000, // 5s timeout
    });
    // ... implementation
  },
});

Next Steps