- Allow the chat-widget to connect to multiple servers (e.g. development and production)
- Created a full session overview
This commit is contained in:
Binary file not shown.
@@ -3,7 +3,7 @@
|
||||
Plugin Name: EveAI Chat Widget
|
||||
Plugin URI: https://askeveai.com/
|
||||
Description: Integrates the EveAI chat interface into your WordPress site.
|
||||
Version: 1.4.1
|
||||
Version: 1.5.0
|
||||
Author: Josako, Pieter Laroy
|
||||
Author URI: https://askeveai.com/about/
|
||||
*/
|
||||
@@ -28,7 +28,8 @@ function eveai_chat_shortcode($atts) {
|
||||
'api_key' => '',
|
||||
'domain' => '',
|
||||
'language' => 'en',
|
||||
'supported_languages' => 'en,fr,de,es'
|
||||
'supported_languages' => 'en,fr,de,es',
|
||||
'server_url' => 'https://evie.askeveai.com'
|
||||
);
|
||||
|
||||
// Merge provided attributes with defaults
|
||||
@@ -40,6 +41,7 @@ function eveai_chat_shortcode($atts) {
|
||||
$domain = esc_url_raw($atts['domain']);
|
||||
$language = sanitize_text_field($atts['language']);
|
||||
$supported_languages = sanitize_text_field($atts['supported_languages']);
|
||||
$server_url = esc_url_raw($atts['server_url']);
|
||||
|
||||
// Generate a unique ID for this instance of the chat widget
|
||||
$chat_id = 'chat-container-' . uniqid();
|
||||
@@ -52,7 +54,8 @@ function eveai_chat_shortcode($atts) {
|
||||
'$api_key',
|
||||
'$domain',
|
||||
'$language',
|
||||
'$supported_languages'
|
||||
'$supported_languages',
|
||||
'$server_url'
|
||||
);
|
||||
eveAI.initializeChat('$chat_id');
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class EveAIChatWidget extends HTMLElement {
|
||||
static get observedAttributes() {
|
||||
return ['tenant-id', 'api-key', 'domain', 'language', 'languages'];
|
||||
return ['tenant-id', 'api-key', 'domain', 'language', 'languages', 'server-url'];
|
||||
}
|
||||
|
||||
constructor() {
|
||||
@@ -87,6 +87,7 @@ class EveAIChatWidget extends HTMLElement {
|
||||
this.language = this.getAttribute('language');
|
||||
const languageAttr = this.getAttribute('languages');
|
||||
this.languages = languageAttr ? languageAttr.split(',') : [];
|
||||
this.serverUrl = this.getAttribute('server-url');
|
||||
this.currentLanguage = this.language;
|
||||
console.log('Updated attributes:', {
|
||||
tenantId: this.tenantId,
|
||||
@@ -94,7 +95,8 @@ class EveAIChatWidget extends HTMLElement {
|
||||
domain: this.domain,
|
||||
language: this.language,
|
||||
currentLanguage: this.currentLanguage,
|
||||
languages: this.languages
|
||||
languages: this.languages,
|
||||
serverUrl: this.serverUrl
|
||||
});
|
||||
}
|
||||
|
||||
@@ -104,14 +106,16 @@ class EveAIChatWidget extends HTMLElement {
|
||||
const domain = this.getAttribute('domain');
|
||||
const language = this.getAttribute('language');
|
||||
const languages = this.getAttribute('languages');
|
||||
const serverUrl = this.getAttribute('server-url');
|
||||
console.log('Checking if all attributes are set:', {
|
||||
tenantId,
|
||||
apiKey,
|
||||
domain,
|
||||
language,
|
||||
languages
|
||||
languages,
|
||||
serverUrl
|
||||
});
|
||||
return tenantId && apiKey && domain && language && languages;
|
||||
return tenantId && apiKey && domain && language && languages && serverUrl;
|
||||
}
|
||||
|
||||
createLanguageDropdown() {
|
||||
@@ -142,7 +146,7 @@ class EveAIChatWidget extends HTMLElement {
|
||||
console.log(`Initializing socket connection to Evie`);
|
||||
|
||||
// Ensure apiKey is passed in the query parameters
|
||||
this.socket = io('https://evie.askeveai.com', {
|
||||
this.socket = io(this.serverUrl, {
|
||||
path: '/chat/socket.io/',
|
||||
transports: ['websocket', 'polling'],
|
||||
query: {
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
// static/js/eveai-sdk.js
|
||||
class EveAI {
|
||||
constructor(tenantId, apiKey, domain, language, languages) {
|
||||
constructor(tenantId, apiKey, domain, language, languages, serverUrl) {
|
||||
this.tenantId = tenantId;
|
||||
this.apiKey = apiKey;
|
||||
this.domain = domain;
|
||||
this.language = language;
|
||||
this.languages = languages;
|
||||
this.serverUrl = serverUrl;
|
||||
|
||||
console.log('EveAI constructor:', { tenantId, apiKey, domain, language, languages });
|
||||
console.log('EveAI constructor:', { tenantId, apiKey, domain, language, languages, serverUrl });
|
||||
}
|
||||
|
||||
initializeChat(containerId) {
|
||||
@@ -21,6 +22,7 @@ class EveAI {
|
||||
chatWidget.setAttribute('domain', this.domain);
|
||||
chatWidget.setAttribute('language', this.language);
|
||||
chatWidget.setAttribute('languages', this.languages);
|
||||
chatWidget.setAttribute('server-url', this.serverUrl);
|
||||
});
|
||||
} else {
|
||||
console.error('Container not found');
|
||||
|
||||
@@ -3,7 +3,7 @@ Contributors: Josako
|
||||
Tags: chat, ai
|
||||
Requires at least: 5.0
|
||||
Tested up to: 5.9
|
||||
Stable tag: 1.4.1
|
||||
Stable tag: 1.5.0
|
||||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
@@ -23,10 +23,10 @@ This plugin allows you to easily add the EveAI chat widget to your WordPress sit
|
||||
|
||||
To add an EveAI Chat Widget to your page or post, use the following shortcode:
|
||||
|
||||
[eveai_chat tenant_id="YOUR_TENANT_ID" api_key="YOUR_API_KEY" domain="YOUR_DOMAIN" language="LANGUAGE_CODE" supported_languages="COMMA_SEPARATED_LANGUAGE_CODES"]
|
||||
[eveai_chat tenant_id="YOUR_TENANT_ID" api_key="YOUR_API_KEY" domain="YOUR_DOMAIN" language="LANGUAGE_CODE" supported_languages="COMMA_SEPARATED_LANGUAGE_CODES" server_url="Server URL for Evie"]
|
||||
|
||||
Example:
|
||||
[eveai_chat tenant_id="123456" api_key="your_api_key_here" domain="https://your-domain.com" language="en" supported_languages="en,fr,de,es"]
|
||||
[eveai_chat tenant_id="123456" api_key="your_api_key_here" domain="https://your-domain.com" language="en" supported_languages="en,fr,de,es" server_url="https://evie.askeveai.com"]
|
||||
|
||||
You can add multiple chat widgets with different configurations by using the shortcode multiple times with different parameters.
|
||||
|
||||
@@ -38,6 +38,9 @@ Contact your EveAI service provider to obtain your Tenant ID, API Key, and Domai
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 1.5.0 =
|
||||
* Allow for multiple servers to serve Evie
|
||||
|
||||
= 1.4.1 - 1.4...=
|
||||
* Bug fixes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user