@useago/sdk) lets you integrate AGO agents into any web application. Use it to build fully custom chat interfaces, handle streaming responses, manage conversations, and register client-side functions that agents can invoke.
Installation
Quick Start
Vanilla JavaScript
Zero-Config Setup
If your page already includes the AGO widget script or meta tags, usecreateAgo to auto-detect configuration:
window.AGO.basepathglobal variable<meta name="ago-base-url">tagdata-ago-base-urlattribute on the body or a script tag
React
Vue.js
Angular
Configuration
Create a client instance with the following options:Sending Messages
Basic Message
Message with Options
Speech to Text
Useclient.transcribeAudio() to turn a recording into text the user can review before sending:
getConfig() reports speechToTextEnabled: false and audio uploads return 403.
- Accepted formats: FLAC, MP3, MP4/M4A, MPEG/MPGA, OGG, WAV and WebM, up to 25 MB. The file name must have the matching extension.
- Record on HTTPS (or
localhost) after the user grants microphone access. In an iframe, addallow="microphone"and check that the host page’s Permissions Policy allows it. - To mark a message as dictated in conversation history, send it through the SDK API with the
transcription_idsreturned by the transcription endpoint.
Streaming Events
Listen to events for real-time updates as the agent responds:Conversations
List Conversations
Load a Conversation
Get Messages
Feedback
Submit thumbs-up or thumbs-down feedback on agent responses:Tool Call Interactions
When an agent invokes a tool that requires user input (such as a form or a confirmation), the SDK emits events you can handle:Events Reference
Defining Reusable Functions
UsedefineFunction to create reusable function definitions that agents can invoke on the client side:
useAgoFunction hook:
Page Context
Tell the agent what the user is looking at: the active order, the visible dashboard filter, the open ticket. Context entries are sent with every message, and the agent reads them alongside its instructions.Vanilla JavaScript
React
Use theuseAgoContext hook to attach context declaratively. It registers when the component mounts and cleans up on unmount:
SSE Streaming Helpers
The SDK provides helper functions for working with streaming responses:React Components
The SDK provides pre-built React components for common use cases.AgoProvider
Provides the AgoClient to your entire React app via context:ChatWidget
A complete, ready-to-use chat interface:Message
Renders a single message with markdown formatting and sources. For the last message, enable follow-up suggestions and provide your click handler:- Markdown rendering, including GitHub-flavored markdown: bold, italic, headings, lists, code blocks, links, blockquotes, tables, task lists, and strikethrough
- Agent name display for assistant messages when
showAgentName={true}; names are hidden by default - Knowledge source citations with links
- Follow-up reply buttons when the message has suggestions and
isLast={true};onFollowUpClickreceives the selected reply text, and buttons are disabled when this handler is omitted - Streaming indicator while a response is in progress
Markdown
Renders a raw markdown string the same wayMessage renders assistant content. Use it when you build a fully custom chat UI but still want consistent markdown output:
React Hooks
useAgo
Creates and manages the SDK client lifecycle:useMessages
Manages messages within a conversation:useConversation
Manages the conversation list and selection:Custom Chat UI Example
Build a fully custom interface using hooks:Cleanup
Destroy the client when you no longer need it, to remove its listeners:useAgo hook handles cleanup automatically on unmount.
Related
- Client Functions — Let agents call functions in your page
- Conversational Forms — Let agents fill forms through conversation
- SDK API Reference — REST endpoints used by the SDK
- Widget Configuration — Widget settings
- Widget & SDK Authentication — Authentication setup
- Deploy the Chat Widget — Deployment guide
