mirror of
https://github.com/hexastack/hexabot
synced 2025-01-22 10:35:37 +00:00
feat: rename live chat tester to console
This commit is contained in:
parent
a3d7b83511
commit
5218233434
@ -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);
|
||||
}
|
||||
}
|
||||
|
3
api/src/extensions/channels/console/i18n/en/title.json
Normal file
3
api/src/extensions/channels/console/i18n/en/title.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"console_channel": "Admin Chat Console"
|
||||
}
|
3
api/src/extensions/channels/console/i18n/fr/title.json
Normal file
3
api/src/extensions/channels/console/i18n/fr/title.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"console_channel": "Testeur Live Chat"
|
||||
}
|
@ -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,
|
16
api/src/extensions/channels/console/index.d.ts
vendored
Normal file
16
api/src/extensions/channels/console/index.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
import CONSOLE_CHANNEL_SETTINGS, {
|
||||
CONSOLE_CHANNEL_NAMESPACE,
|
||||
} from './settings';
|
||||
|
||||
declare global {
|
||||
interface Settings extends SettingTree<typeof CONSOLE_CHANNEL_SETTINGS> {}
|
||||
}
|
||||
|
||||
declare module '@nestjs/event-emitter' {
|
||||
interface IHookExtensionsOperationMap {
|
||||
[CONSOLE_CHANNEL_NAMESPACE]: TDefinition<
|
||||
object,
|
||||
SettingMapByType<typeof CONSOLE_CHANNEL_SETTINGS>
|
||||
>;
|
||||
}
|
||||
}
|
7
api/src/extensions/channels/console/package.json
Normal file
7
api/src/extensions/channels/console/package.json
Normal file
@ -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"
|
||||
}
|
@ -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<typeof LIVE_CHAT_TEST_CHANNEL_NAME>[];
|
||||
] as const satisfies ChannelSetting<typeof CONSOLE_CHANNEL_NAME>[];
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"live_chat_tester_channel": "Live Chat Tester"
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"live_chat_tester_channel": "Testeur Live Chat"
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
import DEFAULT_LIVE_CHAT_TEST_SETTINGS, {
|
||||
LIVE_CHAT_TEST_CHANNEL_NAMESPACE,
|
||||
} from './settings';
|
||||
|
||||
declare global {
|
||||
interface Settings
|
||||
extends SettingTree<typeof DEFAULT_LIVE_CHAT_TEST_SETTINGS> {}
|
||||
}
|
||||
|
||||
declare module '@nestjs/event-emitter' {
|
||||
interface IHookExtensionsOperationMap {
|
||||
[LIVE_CHAT_TEST_CHANNEL_NAMESPACE]: TDefinition<
|
||||
object,
|
||||
SettingMapByType<typeof DEFAULT_LIVE_CHAT_TEST_SETTINGS>
|
||||
>;
|
||||
}
|
||||
}
|
@ -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"
|
||||
}
|
@ -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);
|
||||
|
@ -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'));
|
||||
|
@ -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
|
||||
|
@ -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.",
|
||||
|
@ -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.",
|
||||
|
@ -33,7 +33,7 @@ export const ChatWidget = () => {
|
||||
<UiChatWidget
|
||||
config={{
|
||||
apiUrl,
|
||||
channel: "live-chat-tester-channel",
|
||||
channel: "console-channel",
|
||||
token: "test",
|
||||
language: i18n.language,
|
||||
}}
|
||||
|
@ -19,7 +19,7 @@ export const ChatWidgetHeader = () => {
|
||||
<Box display="flex" alignItems="center" ml={2}>
|
||||
<HexabotLogoRound width={32} height={32} />
|
||||
<Typography component="h2" fontSize="1.25rem" ml={2}>
|
||||
{t("title.live_chat_tester")}
|
||||
{t("title.console")}
|
||||
</Typography>
|
||||
</Box>
|
||||
);
|
||||
|
@ -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',
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user