Companion plugin for the JENSi AI SaaS API. Connect your WordPress to JENSi AI for results using RAG.
PHP >= 8Node >= 18
composer installnpm installnpm run devornpm run build
Make sure to edit the .env file with the correct variables.
You may also see HTTPS errors in the console if using HTTPS, in this case you will need to access the HMR server URL directly in your browser and accept the SSL certificate to continue.
If you see an empty admin section, this is most likely the issue.
- Floating Button: A responsive circular button that appears on all front-end pages
- Expandable Chat Window: Clean, modern chat interface with conversation history
- Real-time Streaming: Uses WebSocket connections for streaming responses
- Persistent Conversations: Chat sessions are saved in localStorage and persist across page loads
- Responsive Design: Works on desktop and mobile devices
- Configurable: Can be enabled/disabled and customized through WordPress admin
- Go to WordPress Admin > JENSi AI > Settings
- Enter your JENSi AI API Key
- Select an Agent for the chat widget to use
- Make sure Enable Chat Widget is checked
- Save your settings
The chat widget uses these REST API endpoints:
POST /wp-json/jensi_ai/v1/chat/send-message- Send a message to start or continue a chatGET /wp-json/jensi_ai/v1/chat/{chat_id}- Get chat history and detailsPOST /wp-json/jensi_ai/v1/chat/create- Create a new chat session (optional)
The widget connects to the JENSi AI WebSocket server for real-time message streaming:
- Local Development:
wss://jensi-ai.test:8090 - Production:
wss://ai.jensi.com:8090
WebSocket events:
message.streaming- Partial message content during streamingmessage.complete- Final complete message
- First Visit: User clicks the floating button and sees a welcome message
- Start Chat: User types a message, which creates a new chat session
- Streaming Response: The AI agent responds with streaming text via WebSocket
- Persistent Session: Chat ID is saved in localStorage for session continuity
- Continued Conversation: Subsequent messages use the existing chat session
- ChatWidget.vue: Main Vue component handling the entire chat interface
- chat-widget.ts: Entry point that mounts the widget to the DOM
- chat-widget.css: Styled with modern CSS and smooth animations
- ChatController.php: REST API controller for chat operations
- ChatWidgetLoader.php: Handles enqueueing assets and configuration
- Main.php: Initializes the chat widget loader
- Chat Sessions: Stored in JENSi AI cloud (not locally)
- Chat ID: Stored in browser localStorage for session persistence
- Settings: Stored in WordPress database
You can control where the chat widget appears using the filter:
add_filter('jensi_ai_chat_widget_should_load', function($should_load) {
// Don't show on checkout pages
if (is_page('checkout')) {
return false;
}
return $should_load;
});add_filter('jensi_ai_chat_widget_config', function($config) {
// Add custom metadata
$config['customData'] = [
'user_id' => get_current_user_id(),
'page_title' => get_the_title()
];
return $config;
});- Check that Enable Chat Widget is enabled in settings
- Verify you have a valid API Key configured
- Make sure an Agent is selected
- Check browser console for JavaScript errors
- Verify the WebSocket URL in browser network tab
- Check for SSL certificate issues in development
- Ensure firewall/proxy allows WebSocket connections
- Check WordPress REST API is working:
/wp-json/jensi_ai/v1/chat/ - Verify API key has proper permissions
- Check agent ID is valid and accessible
# Development with hot reload
npm run dev
# Production build
npm run buildsrc/chat-widget/
├── chat-widget.ts # Entry point
├── ChatWidget.vue # Main component
assets/
├── chat-widget.css # Styles
includes/
├── Api/ChatController.php # API endpoints
├── ChatWidgetLoader.php # Asset loader
POST /wp-json/jensi_ai/v1/chat/send-message
Content-Type: application/json
X-WP-Nonce: {nonce}
{
"message": "Hello, how can you help me?",
"chat_id": "optional-existing-chat-id",
"agent_id": "agent-uuid-if-starting-new-chat"
}GET /wp-json/jensi_ai/v1/chat/{chat_id}
X-WP-Nonce: {nonce}- All API calls are nonce-protected
- Chat sessions are scoped to the browser (localStorage)
- No sensitive data is stored locally
- WebSocket connections use secure WSS protocol in production