@vectorize-io/chat
v0.1.0
Published
Vectorize Chat Widget - NPM wrapper for CDN-hosted chat widget
Readme
@vectorize-io/chat
AI chat widget for websites.
Installation
npm install @vectorize-io/chatUsage
import { initVectorizeChat } from '@vectorize-io/chat';
await initVectorizeChat({
apiUrl: 'https://agents.vectorize.io/api/chat/agents/YOUR-AGENT-ID',
agentId: 'YOUR-AGENT-ID',
apiKey: 'YOUR-API-KEY'
});That's it. The chat widget is now on your page.
Required Configuration
You need these 3 things:
apiUrl- The API endpoint for your agentagentId- Your agent IDapiKey- Your API key
Widget Control
The initVectorizeChat function returns a widget instance with these methods:
const widget = await initVectorizeChat({
apiUrl: 'https://agents.vectorize.io/api/chat/agents/YOUR-AGENT-ID',
agentId: 'YOUR-AGENT-ID',
apiKey: 'YOUR-API-KEY'
});
widget.open(); // Open the chat
widget.close(); // Close the chat
widget.toggle(); // Toggle open/closed
widget.destroy(); // Remove the widgetReact Example
import { useEffect } from 'react';
import { initVectorizeChat } from '@vectorize-io/chat';
function App() {
useEffect(() => {
initVectorizeChat({
apiUrl: `https://agents.vectorize.io/api/chat/agents/${process.env.REACT_APP_VECTORIZE_AGENT_ID}`,
agentId: process.env.REACT_APP_VECTORIZE_AGENT_ID,
apiKey: process.env.REACT_APP_VECTORIZE_API_KEY
});
}, []);
return <div>Your app</div>;
}TypeScript
Full TypeScript support is included.
License
MIT
Release
To release a new version, run:
version=x.y.z
git checkout main
npm version $version
git commit -am "Release $version"
git push origin main
git tag $version
git push origin main --tags