From 0b632c46aa6ade62a8f05671051b33f6623cd7eb Mon Sep 17 00:00:00 2001 From: AlexanderKanakis Date: Tue, 18 Oct 2022 15:41:56 +0300 Subject: [PATCH] Close room and throw error if sf bot username in Admin UI setting is invalid --- handlers/SalesforceAgentAssignedHandler.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/handlers/SalesforceAgentAssignedHandler.ts b/handlers/SalesforceAgentAssignedHandler.ts index 9ad56b9..c30a1ba 100644 --- a/handlers/SalesforceAgentAssignedHandler.ts +++ b/handlers/SalesforceAgentAssignedHandler.ts @@ -20,8 +20,13 @@ export class SalesforceAgentAssigned { ) {} public async exec() { + const technicalDifficultyMessage: string = await getAppSettingValue(this.read, AppSettingId.TECHNICAL_DIFFICULTY_MESSAGE); const salesforceBotUsername: string = await getAppSettingValue(this.read, AppSettingId.SALESFORCE_BOT_USERNAME); if (this.data.agent.username !== salesforceBotUsername) { + if (this.data.room.customFields?.isHandedOverFromDialogFlow === true) { + await sendLCMessage(this.read, this.modify, this.data.room, technicalDifficultyMessage, this.data.agent); + await this.modify.getUpdater().getLivechatUpdater().closeRoom(this.data.room, ErrorLogs.APP_CONFIGURATION_INVALID); + } return; } @@ -29,7 +34,6 @@ export class SalesforceAgentAssigned { const persistedData = await retrievePersistentTokens(this.read, assoc); const { persistentAffinity, persistentKey } = persistedData; const salesforceAgentName = (await retrievePersistentData(this.read, assoc)).salesforceAgentName; - const technicalDifficultyMessage: string = await getAppSettingValue(this.read, AppSettingId.TECHNICAL_DIFFICULTY_MESSAGE); let salesforceChatApiEndpoint: string = await getAppSettingValue(this.read, AppSettingId.SALESFORCE_CHAT_API_ENDPOINT); try {