Choose Your Integration
JavaScript SDK
Server-side and client-side SDK for Node.js, browsers, and TypeScript. Full API access with streaming support.
Widget API
Control the chat widget programmatically — open, close, send messages, and listen to events.
Forms & Triggers
Trigger forms programmatically and handle submissions with custom callbacks.
User Identity
Pass user context to personalize conversations and pre-fill forms with known data.
Custom Events
Track user actions and trigger automations based on custom events.
Webhooks
Receive real-time notifications when conversations happen or forms are submitted.
Quick Start
Option 1: Embed Script (Recommended)
The simplest way to add Ansa to your site. Add this script before the closing</body> tag:
ansa object is automatically available on window for programmatic control:
Option 2: JavaScript SDK
For server-side integrations or custom chat interfaces, install the SDK:API Overview
Widget API Methods
Theansa object exposes these methods when using the embed script:
| Method | Description |
|---|---|
ansa.open(message?) | Open the chat widget, optionally with a pre-filled message |
ansa.close() | Close the chat widget |
ansa.toggle() | Toggle the widget open/closed state |
ansa.isOpen() | Returns true if the widget is currently open |
ansa.identify(identity) | Set user identity and metadata |
ansa.resetUser() | Clear user identity |
ansa.showForm(form, options) | Display a form in the widget |
ansa.showBubbles(messages, duration?) | Show notification bubbles |
ansa.trigger(eventName, data?) | Fire a custom event for triggers |
ansa.getVisitorId() | Get the anonymous visitor ID |
SDK Methods
TheAnsaClient provides full API access:
| Method | Description |
|---|---|
chat(agentId, options) | Send a message and receive a response |
streamChat(agentId, options, callbacks) | Stream responses token-by-token |
getAgent(agentId) | Retrieve agent configuration |
listAgents() | List all agents in your organization |
getConversation(id) | Get conversation history |
listConversations(agentId) | List conversations for an agent |
Architecture
postMessage, and the widget communicates with the Ansa API. Webhooks notify your server of events in real-time.