JavaScript API
Global methods available after loading the widget script.
Respondo.init(config)#
Initializes and mounts the widget. Must be called once. Returns the widget instance.
const widget = Respondo.init({
agentId: 'YOUR_AGENT_ID'
});Respondo.identify(identity)#
Attaches user identity to the current session. Call after login.
Respondo.identify({
email: 'user@example.com',
name: 'John Doe',
userId: 'usr_123',
userHash: 'hmac_sha256_signature', // optional, for identity verification
metadata: { plan: 'pro' },
properties: { // custom contact properties
account_type: 'enterprise', // keys defined in Agent Settings
region: 'eu-west'
}
});Respondo.destroy()#
Removes the widget from the page. Useful for SPAs when navigating to pages where the widget should not appear, or when a user logs out.
// On logout — remove widget and clear identity
Respondo.destroy();
// Reinitialize later if needed
Respondo.init({ agentId: 'YOUR_AGENT_ID' });Automatic Data Collection
The widget automatically captures and stores the following with each conversation:
| Data | Source |
|---|---|
| Client IP | HTTP headers |
| Browser / OS | User-Agent header |
| Language | Accept-Language header |
| Timezone | Intl API (JavaScript) |
| Page URL | window.location |
| Referrer | Referer header |