Vectorize Chat Widget - NPM wrapper for CDN-hosted chat widget
npm install @vectorize-io/chatAI chat widget for websites.
``bash`
npm install @vectorize-io/chat
`javascript
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.
You need these 3 things:
- apiUrl - The API endpoint for your agentagentId
- - Your agent IDapiKey
- - Your API key
The initVectorizeChat function returns a widget instance with these methods:
`javascript
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 widget
`
`jsx
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 Your app;
}
Full TypeScript support is included.
MIT
`bash
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
``