Skip to content

Latest commit

 

History

History
80 lines (55 loc) · 1.93 KB

getting-started.md

File metadata and controls

80 lines (55 loc) · 1.93 KB

Getting Started with the AGO SDK

Install and configure the AGO SDK to build custom chat experiences in your application.

Prerequisites

  • A JavaScript or TypeScript project (React, Next.js, Vue, Angular, or vanilla)
  • Your AGO instance URL (e.g., https://YOUR-DOMAIN.useago.com)
  • Node.js 16+

Install the SDK

npm install @useago/sdk

Initialize the client

Create a configuration file in your project (e.g., src/lib/ago.ts):

import { AgoClient } from "@useago/sdk";

export const agoClient = new AgoClient({
  baseUrl: import.meta.env.VITE_AGO_BASE_URL,
});

For Next.js:

const agoClient = new AgoClient({
  baseUrl: process.env.NEXT_PUBLIC_AGO_BASE_URL!,
});

Send your first message

const response = await agoClient.sendMessage("How do I reset my password?");
console.log(response.content);

Messages are streamed by default. Listen to real-time chunks:

agoClient.on("message:chunk", (data) => {
  process.stdout.write(data.content);
});

await agoClient.sendMessage("How do I reset my password?");

Configuration options

Option Required Description
baseUrl Yes Your AGO instance URL
defaultAgentId No Agent to use for all messages
userEmail No Identify the current user
userJwt No JWT token for authenticated sessions
debug No Enable console debug logging

Zero-config alternative

If your page already has the AGO widget script, the SDK can auto-detect the configuration:

import { createAgo } from "@useago/sdk";

const client = createAgo();

This reads from window.AGO, <meta> tags, or data-ago-* attributes automatically.

Next steps