diff --git a/api/src/channel/channel.service.ts b/api/src/channel/channel.service.ts index 93802ef3..4c2d9986 100644 --- a/api/src/channel/channel.service.ts +++ b/api/src/channel/channel.service.ts @@ -10,7 +10,7 @@ import { Injectable, UnauthorizedException } from '@nestjs/common'; import { Request, Response } from 'express'; import { SubscriberService } from '@/chat/services/subscriber.service'; -import { LIVE_CHAT_TEST_CHANNEL_NAME } from '@/extensions/channels/live-chat-tester/settings'; +import { CONSOLE_CHANNEL_NAME } from '@/extensions/channels/console/settings'; import { WEB_CHANNEL_NAME } from '@/extensions/channels/web/settings'; import { LoggerService } from '@/logger/logger.service'; import { @@ -116,20 +116,20 @@ export class ChannelService { } /** - * Handles a websocket request for the live chat tester channel. + * Handles a websocket request for the admin chat console channel. * It considers the user as a subscriber. * * @param req - The websocket request object. * @param res - The websocket response object. */ - @SocketGet(`/webhook/${LIVE_CHAT_TEST_CHANNEL_NAME}/`) - @SocketPost(`/webhook/${LIVE_CHAT_TEST_CHANNEL_NAME}/`) - async handleWebsocketForLiveChatTester( + @SocketGet(`/webhook/${CONSOLE_CHANNEL_NAME}/`) + @SocketPost(`/webhook/${CONSOLE_CHANNEL_NAME}/`) + async handleWebsocketForAdminChatConsole( @SocketReq() req: SocketRequest, @SocketRes() res: SocketResponse, ) { this.logger.log( - 'Channel notification (Live Chat Tester Socket) : ', + 'Channel notification (Admin Chat Console Socket) : ', req.method, ); @@ -158,7 +158,7 @@ export class ChannelService { country: '', labels: [], channel: { - name: LIVE_CHAT_TEST_CHANNEL_NAME, + name: CONSOLE_CHANNEL_NAME, isSocket: true, }, }, @@ -172,7 +172,7 @@ export class ChannelService { polling: false, }; - const handler = this.getChannelHandler(LIVE_CHAT_TEST_CHANNEL_NAME); + const handler = this.getChannelHandler(CONSOLE_CHANNEL_NAME); return handler.handle(req, res); } } diff --git a/api/src/extensions/channels/live-chat-tester/i18n/en/label.json b/api/src/extensions/channels/console/i18n/en/label.json similarity index 100% rename from api/src/extensions/channels/live-chat-tester/i18n/en/label.json rename to api/src/extensions/channels/console/i18n/en/label.json diff --git a/api/src/extensions/channels/console/i18n/en/title.json b/api/src/extensions/channels/console/i18n/en/title.json new file mode 100644 index 00000000..d4c6be17 --- /dev/null +++ b/api/src/extensions/channels/console/i18n/en/title.json @@ -0,0 +1,3 @@ +{ + "console_channel": "Admin Chat Console" +} diff --git a/api/src/extensions/channels/live-chat-tester/i18n/fr/label.json b/api/src/extensions/channels/console/i18n/fr/label.json similarity index 100% rename from api/src/extensions/channels/live-chat-tester/i18n/fr/label.json rename to api/src/extensions/channels/console/i18n/fr/label.json diff --git a/api/src/extensions/channels/console/i18n/fr/title.json b/api/src/extensions/channels/console/i18n/fr/title.json new file mode 100644 index 00000000..2f22cb98 --- /dev/null +++ b/api/src/extensions/channels/console/i18n/fr/title.json @@ -0,0 +1,3 @@ +{ + "console_channel": "Testeur Live Chat" +} diff --git a/api/src/extensions/channels/live-chat-tester/index.channel.ts b/api/src/extensions/channels/console/index.channel.ts similarity index 90% rename from api/src/extensions/channels/live-chat-tester/index.channel.ts rename to api/src/extensions/channels/console/index.channel.ts index ae62962a..6dca5c3d 100644 --- a/api/src/extensions/channels/live-chat-tester/index.channel.ts +++ b/api/src/extensions/channels/console/index.channel.ts @@ -21,11 +21,11 @@ import { WebsocketGateway } from '@/websocket/websocket.gateway'; import BaseWebChannelHandler from '../web/base-web-channel'; -import { LIVE_CHAT_TEST_CHANNEL_NAME } from './settings'; +import { CONSOLE_CHANNEL_NAME } from './settings'; @Injectable() -export default class LiveChatTesterHandler extends BaseWebChannelHandler< - typeof LIVE_CHAT_TEST_CHANNEL_NAME +export default class ConsoleChannelHandler extends BaseWebChannelHandler< + typeof CONSOLE_CHANNEL_NAME > { constructor( settingService: SettingService, @@ -40,7 +40,7 @@ export default class LiveChatTesterHandler extends BaseWebChannelHandler< websocketGateway: WebsocketGateway, ) { super( - LIVE_CHAT_TEST_CHANNEL_NAME, + CONSOLE_CHANNEL_NAME, settingService, channelService, logger, diff --git a/api/src/extensions/channels/console/index.d.ts b/api/src/extensions/channels/console/index.d.ts new file mode 100644 index 00000000..7080300f --- /dev/null +++ b/api/src/extensions/channels/console/index.d.ts @@ -0,0 +1,16 @@ +import CONSOLE_CHANNEL_SETTINGS, { + CONSOLE_CHANNEL_NAMESPACE, +} from './settings'; + +declare global { + interface Settings extends SettingTree {} +} + +declare module '@nestjs/event-emitter' { + interface IHookExtensionsOperationMap { + [CONSOLE_CHANNEL_NAMESPACE]: TDefinition< + object, + SettingMapByType + >; + } +} diff --git a/api/src/extensions/channels/console/package.json b/api/src/extensions/channels/console/package.json new file mode 100644 index 00000000..7de9aa68 --- /dev/null +++ b/api/src/extensions/channels/console/package.json @@ -0,0 +1,7 @@ +{ + "name": "hexabot-channel-console", + "version": "2.0.0", + "description": "The Admin Chat Console Channel Extension for Hexabot Chatbot / Agent Builder.", + "author": "Hexastack", + "license": "AGPL-3.0-only" +} \ No newline at end of file diff --git a/api/src/extensions/channels/live-chat-tester/settings.ts b/api/src/extensions/channels/console/settings.ts similarity index 78% rename from api/src/extensions/channels/live-chat-tester/settings.ts rename to api/src/extensions/channels/console/settings.ts index 19f80b21..0f7102a9 100644 --- a/api/src/extensions/channels/live-chat-tester/settings.ts +++ b/api/src/extensions/channels/console/settings.ts @@ -12,83 +12,83 @@ import { SettingType } from '@/setting/schemas/types'; import { Web } from '../web/types'; -export const LIVE_CHAT_TEST_CHANNEL_NAME = 'live-chat-tester-channel'; +export const CONSOLE_CHANNEL_NAME = 'console-channel'; -export const LIVE_CHAT_TEST_CHANNEL_NAMESPACE = 'live_chat_tester_channel'; +export const CONSOLE_CHANNEL_NAMESPACE = 'console_channel'; export default [ { - group: LIVE_CHAT_TEST_CHANNEL_NAMESPACE, + group: CONSOLE_CHANNEL_NAMESPACE, label: Web.SettingLabel.verification_token, value: 'test', type: SettingType.text, }, { - group: LIVE_CHAT_TEST_CHANNEL_NAMESPACE, + group: CONSOLE_CHANNEL_NAMESPACE, label: Web.SettingLabel.allowed_domains, value: config.frontendPath, type: SettingType.text, }, { - group: LIVE_CHAT_TEST_CHANNEL_NAMESPACE, + group: CONSOLE_CHANNEL_NAMESPACE, label: Web.SettingLabel.start_button, value: true, type: SettingType.checkbox, }, { - group: LIVE_CHAT_TEST_CHANNEL_NAMESPACE, + group: CONSOLE_CHANNEL_NAMESPACE, label: Web.SettingLabel.input_disabled, value: false, type: SettingType.checkbox, }, { - group: LIVE_CHAT_TEST_CHANNEL_NAMESPACE, + group: CONSOLE_CHANNEL_NAMESPACE, label: Web.SettingLabel.persistent_menu, value: true, type: SettingType.checkbox, }, { - group: LIVE_CHAT_TEST_CHANNEL_NAMESPACE, + group: CONSOLE_CHANNEL_NAMESPACE, label: Web.SettingLabel.greeting_message, value: 'Welcome! Ready to start a conversation with our chatbot?', type: SettingType.textarea, }, { - group: LIVE_CHAT_TEST_CHANNEL_NAMESPACE, + group: CONSOLE_CHANNEL_NAMESPACE, label: Web.SettingLabel.theme_color, value: 'teal', type: SettingType.select, options: ['teal', 'orange', 'red', 'green', 'blue', 'dark'], }, { - group: LIVE_CHAT_TEST_CHANNEL_NAMESPACE, + group: CONSOLE_CHANNEL_NAMESPACE, label: Web.SettingLabel.show_emoji, value: true, type: SettingType.checkbox, }, { - group: LIVE_CHAT_TEST_CHANNEL_NAMESPACE, + group: CONSOLE_CHANNEL_NAMESPACE, label: Web.SettingLabel.show_file, value: true, type: SettingType.checkbox, }, { - group: LIVE_CHAT_TEST_CHANNEL_NAMESPACE, + group: CONSOLE_CHANNEL_NAMESPACE, label: Web.SettingLabel.show_location, value: true, type: SettingType.checkbox, }, { - group: LIVE_CHAT_TEST_CHANNEL_NAMESPACE, + group: CONSOLE_CHANNEL_NAMESPACE, label: Web.SettingLabel.allowed_upload_size, value: 2500000, type: SettingType.number, }, { - group: LIVE_CHAT_TEST_CHANNEL_NAMESPACE, + group: CONSOLE_CHANNEL_NAMESPACE, label: Web.SettingLabel.allowed_upload_types, value: 'audio/mpeg,audio/x-ms-wma,audio/vnd.rn-realaudio,audio/x-wav,image/gif,image/jpeg,image/png,image/tiff,image/vnd.microsoft.icon,image/vnd.djvu,image/svg+xml,text/css,text/csv,text/html,text/plain,text/xml,video/mpeg,video/mp4,video/quicktime,video/x-ms-wmv,video/x-msvideo,video/x-flv,video/web,application/msword,application/vnd.ms-powerpoint,application/pdf,application/vnd.ms-excel,application/vnd.oasis.opendocument.presentation,application/vnd.oasis.opendocument.tex,application/vnd.oasis.opendocument.spreadsheet,application/vnd.oasis.opendocument.graphics,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.openxmlformats-officedocument.wordprocessingml.document', type: SettingType.textarea, }, -] as const satisfies ChannelSetting[]; +] as const satisfies ChannelSetting[]; diff --git a/api/src/extensions/channels/live-chat-tester/i18n/en/title.json b/api/src/extensions/channels/live-chat-tester/i18n/en/title.json deleted file mode 100644 index 41fcdeba..00000000 --- a/api/src/extensions/channels/live-chat-tester/i18n/en/title.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "live_chat_tester_channel": "Live Chat Tester" -} diff --git a/api/src/extensions/channels/live-chat-tester/i18n/fr/title.json b/api/src/extensions/channels/live-chat-tester/i18n/fr/title.json deleted file mode 100644 index e4f67ea7..00000000 --- a/api/src/extensions/channels/live-chat-tester/i18n/fr/title.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "live_chat_tester_channel": "Testeur Live Chat" -} diff --git a/api/src/extensions/channels/live-chat-tester/index.d.ts b/api/src/extensions/channels/live-chat-tester/index.d.ts deleted file mode 100644 index 22f24702..00000000 --- a/api/src/extensions/channels/live-chat-tester/index.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -import DEFAULT_LIVE_CHAT_TEST_SETTINGS, { - LIVE_CHAT_TEST_CHANNEL_NAMESPACE, -} from './settings'; - -declare global { - interface Settings - extends SettingTree {} -} - -declare module '@nestjs/event-emitter' { - interface IHookExtensionsOperationMap { - [LIVE_CHAT_TEST_CHANNEL_NAMESPACE]: TDefinition< - object, - SettingMapByType - >; - } -} diff --git a/api/src/extensions/channels/live-chat-tester/package.json b/api/src/extensions/channels/live-chat-tester/package.json deleted file mode 100644 index dd5dcbf6..00000000 --- a/api/src/extensions/channels/live-chat-tester/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "hexabot-channel-live-chat-tester", - "version": "2.0.0", - "description": "The Web Channel Extension for Hexabot Chatbot / Agent Builder for website integration", - "author": "Hexastack", - "license": "AGPL-3.0-only" -} diff --git a/api/src/websocket/websocket.gateway.spec.ts b/api/src/websocket/websocket.gateway.spec.ts index 6f7956b2..c24407fc 100644 --- a/api/src/websocket/websocket.gateway.spec.ts +++ b/api/src/websocket/websocket.gateway.spec.ts @@ -49,8 +49,8 @@ describe('WebsocketGateway', () => { ioClient = io('http://localhost:3000', { autoConnect: false, transports: ['websocket', 'polling'], - // path: '/socket.io/?EIO=4&transport=websocket&channel=web', - query: { EIO: '4', transport: 'websocket', channel: 'web' }, + // path: '/socket.io/?EIO=4&transport=websocket&channel=web-channel', + query: { EIO: '4', transport: 'websocket', channel: 'web-channel' }, }); app.listen(3000); diff --git a/api/src/websocket/websocket.gateway.ts b/api/src/websocket/websocket.gateway.ts index d401fc2b..f556c609 100644 --- a/api/src/websocket/websocket.gateway.ts +++ b/api/src/websocket/websocket.gateway.ts @@ -209,6 +209,7 @@ export class WebsocketGateway this.logger.verbose('Client connected, attempting to load session.'); try { const { searchParams } = new URL(`ws://localhost${client.request.url}`); + if (client.request.headers.cookie) { const cookies = cookie.parse(client.request.headers.cookie); if (cookies && config.session.name in cookies) { @@ -223,7 +224,7 @@ export class WebsocketGateway 'Unable to load session, creating a new one ...', err, ); - if (searchParams.get('channel') === 'web') { + if (searchParams.get('channel') === 'web-channel') { return this.createAndStoreSession(client, next); } else { return next(new Error('Unauthorized: Unknown session ID')); @@ -237,7 +238,7 @@ export class WebsocketGateway return next(new Error('Unable to parse session ID from cookie')); } } - } else if (searchParams.get('channel') === 'web') { + } else if (searchParams.get('channel') === 'web-channel') { return this.createAndStoreSession(client, next); } else { return next(new Error('Unauthorized to connect to WS')); diff --git a/docker/.env.example b/docker/.env.example index 3691d0ed..f9daf1a9 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -57,5 +57,5 @@ NEXT_PUBLIC_SSO_ENABLED=false # Widget APP_WIDGET_PORT=5173 REACT_APP_WIDGET_API_URL=http://${APP_DOMAIN}:${API_PORT} -REACT_APP_WIDGET_CHANNEL=web +REACT_APP_WIDGET_CHANNEL=web-channel REACT_APP_WIDGET_TOKEN=token123 diff --git a/frontend/public/locales/en/translation.json b/frontend/public/locales/en/translation.json index 1b902f60..9811b52b 100644 --- a/frontend/public/locales/en/translation.json +++ b/frontend/public/locales/en/translation.json @@ -220,8 +220,7 @@ "log_entry": "Log entry", "dashboard": "Dashboard", "warning": "Warning", - "live_chat_tester": "Live Chat Tester", - "live-chat-tester": "Live Chat Tester" + "console": "Admin Chat Console" }, "label": { "terms": "I have read and approve the terms and conditions.", diff --git a/frontend/public/locales/fr/translation.json b/frontend/public/locales/fr/translation.json index 19f67cf5..d06616c7 100644 --- a/frontend/public/locales/fr/translation.json +++ b/frontend/public/locales/fr/translation.json @@ -220,8 +220,7 @@ "log_entry": "Journal des entrées", "dashboard": "Tableau de bord", "warning": "Avertissement", - "live_chat_tester": "Testeur Live Chat", - "live-chat-tester": "Testeur Live Chat" + "console": "Console de Chat Admin" }, "label": { "terms": "J'ai lu et approuvé les termes et conditions.", diff --git a/frontend/src/app-components/widget/ChatWidget.tsx b/frontend/src/app-components/widget/ChatWidget.tsx index f94cd3ae..4f177184 100644 --- a/frontend/src/app-components/widget/ChatWidget.tsx +++ b/frontend/src/app-components/widget/ChatWidget.tsx @@ -33,7 +33,7 @@ export const ChatWidget = () => { { - {t("title.live_chat_tester")} + {t("title.console")} ); diff --git a/widget/src/constants/defaultConfig.ts b/widget/src/constants/defaultConfig.ts index 5d189244..a1711da2 100644 --- a/widget/src/constants/defaultConfig.ts +++ b/widget/src/constants/defaultConfig.ts @@ -8,7 +8,7 @@ export const DEFAULT_CONFIG = { apiUrl: process.env.REACT_APP_WIDGET_API_URL || 'http://localhost:4000', - channel: process.env.REACT_APP_WIDGET_CHANNEL || 'live-chat-tester-channel', + channel: process.env.REACT_APP_WIDGET_CHANNEL || 'console-channel', token: process.env.REACT_APP_WIDGET_TOKEN || 'test', language: 'en', };