- Allow the chat-widget to connect to multiple servers (e.g. development and production)
- Created a full session overview
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user