Install and configure the AGO SDK to build custom chat experiences in your application.
- 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+
npm install @useago/sdkCreate 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!,
});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?");| 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 |
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.
- Build a custom chat UI with React
- Create client functions your agent can call
- Embed the widget with a simple script tag