Quick Start
Get your EchoAI assistant running in under 2 minutes with these simple steps.
Include the Echo SDK script in your HTML file before the closing </body> tag.
<script src="https://cdn.echoaichat.com/sdk/echo-sdk.js"></script> Create a new EchoSDK instance with your assistant identifier.
const echoWidget = new EchoSDK({
container: '#echo-chat',
assistantIdentifier: 'dovjmm372762'
}); #echo-chat.
Installation
Complete HTML example to get you started quickly.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Website</title>
</head>
<body>
<!-- Your website content -->
<!-- Echo Chat Container -->
<div id="echo-chat" style="height: 500px;"></div>
<!-- Echo SDK -->
<script src="https://cdn.echoaichat.com/sdk/echo-sdk.js"></script>
<script>
const echoWidget = new EchoSDK({
container: '#echo-chat',
assistantIdentifier: 'dovjmm372762',
height: '100%'
});
</script>
</body>
</html> Live Preview
Configure the widget options below and see changes in real time. The generated code updates automatically.
Core Options
Essential configuration options for your Echo widget.
| Option | Type | Description |
|---|---|---|
container Required | string | Element | CSS selector or DOM element where the chat will be mounted |
assistantIdentifier Required | string | Your unique assistant identifier from the Echo dashboard |
height Optional | string | number | Widget height (e.g., "500px", "100%", 500) |
autoFocus Optional | boolean | Auto-focus input field on load. Default: false |
userContext Optional | string | Additional context about the user (max 1000 chars) |
starterQuestions NEW | Array | Override default starter questions (max 5) |
onError Optional | function | Error callback: (error: Error) => void |
Text Customization
Customize UI text with the textConfig option.
const echoWidget = new EchoSDK({
container: '#echo-chat',
assistantIdentifier: 'dovjmm372762',
textConfig: {
inputPlaceholder: 'Ask me anything...',
sourcesLabel: 'Knowledge Sources',
searchingText: 'Searching...',
toolsText: 'Processing...',
loadingText: 'Thinking...'
}
}); | Property | Type | Description |
|---|---|---|
inputPlaceholder | string | Placeholder text for the input field |
sourcesLabel | string | Label for knowledge sources section |
searchingText | string | Text shown while searching |
toolsText | string | Text shown while processing tools |
loadingText | string | Text shown while loading response |
Starter Questions
Override default starter questions to customize the initial chat experience.
Basic Usage
const echoWidget = new EchoSDK({
container: '#echo-chat',
assistantIdentifier: 'dovjmm372762',
starterQuestions: [
{ question: 'What are your pricing plans?' },
{ question: 'How do I get started?' },
{ question: 'Can I see a demo?' }
]
}); Behavior
- Maximum 5 questions — Additional questions are ignored
- Max 200 characters — Longer text is truncated
- Empty array
[]— Hides all starter questions - Undefined — Uses default questions from dashboard
Page-Specific Example
// Dynamic questions based on current page
function getStarterQuestions() {
const path = window.location.pathname;
if (path.includes('/pricing')) {
return [
{ question: 'Compare pricing plans' },
{ question: 'Do you offer discounts?' },
{ question: 'Enterprise options?' }
];
}
if (path.includes('/docs')) {
return [
{ question: 'How do I install the SDK?' },
{ question: 'Show me code examples' }
];
}
// Use dashboard defaults
return undefined;
}
const echoWidget = new EchoSDK({
container: '#echo-chat',
assistantIdentifier: 'dovjmm372762',
starterQuestions: getStarterQuestions()
}); User Context
Pass metadata about the current user or session to the AI assistant. The context is injected into the AI's system prompt, enabling personalized responses without users repeating information.
Plain Text
const echoWidget = new EchoSDK({
container: '#echo-chat',
assistantIdentifier: 'dovjmm372762',
userContext: 'Company size: 50-100 employees, Industry: Healthcare, Plan: Enterprise'
}); JSON Format (Recommended)
For structured data, use JSON.stringify(). This gives the AI clearly labeled fields to reference.
// Structured context with JSON (recommended)
const user = await fetchCurrentUser();
const echoWidget = new EchoSDK({
container: '#echo-chat',
assistantIdentifier: 'dovjmm372762',
userContext: JSON.stringify({
userId: user.id,
membershipTier: 'gold',
companySize: '50-100 employees',
accountAge: '2 years',
cartItems: 3,
rewardPoints: 1250
})
}); Dynamic Context
Build context from your application state at initialization time.
// Dynamic context based on application state
function buildContext() {
const user = getCurrentUser();
const cart = getCartState();
return JSON.stringify({
name: user.firstName,
plan: user.subscription.plan,
cartTotal: cart.total,
itemCount: cart.items.length,
preferredLanguage: user.locale
});
}
const echoWidget = new EchoSDK({
container: '#echo-chat',
assistantIdentifier: 'dovjmm372762',
userContext: buildContext()
}); Limits & Rules
| Aspect | Detail |
|---|---|
| Max length | 1000 characters — exceeding throws an error |
| Type | String only (plain text or JSON) |
| Scope | Per conversation thread — set at creation, cannot be updated mid-conversation |
| Validation | Enforced both client-side (SDK) and server-side (API) |
Best Practices
- Use identifiers instead of full names (
userId: "user_123") - Include non-sensitive metadata: plan tier, company size, preferences
- Use JSON format for structured data
- Only include data that improves AI responses
- Include passwords, SSN, or credit card numbers
- Store highly sensitive PII
- Include data users wouldn't want the AI to know
- Pass API keys or credentials
Code Examples
Common integration patterns for different use cases.
Embedded Widget
const echoWidget = new EchoSDK({
container: '#echo-chat',
assistantIdentifier: 'dovjmm372762',
height: '600px',
autoFocus: true,
textConfig: {
inputPlaceholder: 'Ask me anything...',
sourcesLabel: 'References'
}
}); With User Context
// Personalize based on logged-in user
const user = getCurrentUser();
const echoWidget = new EchoSDK({
container: '#echo-chat',
assistantIdentifier: 'dovjmm372762',
userContext: `Name: ${user.name}, Plan: ${user.plan}`,
starterQuestions: [
{ question: 'How do I upgrade my plan?' },
{ question: "What's new in my account?" }
]
}); Full Configuration
const echoWidget = new EchoSDK({
container: '#echo-chat',
assistantIdentifier: 'dovjmm372762',
height: '100%',
autoFocus: true,
textConfig: {
inputPlaceholder: 'How can I help you today?',
sourcesLabel: 'Knowledge Sources',
searchingText: 'Searching...',
toolsText: 'Processing...',
loadingText: 'Generating response...'
},
userContext: 'Premium user, prefers detailed answers',
urlContextOptions: {
autoDetect: true
},
starterQuestions: [
{ question: "What's new this week?" },
{ question: 'Show me advanced features' },
{ question: 'API integration guide' }
],
onError: (error) => {
console.error('Echo SDK error:', error);
}
});