From 91e25f520fdf66b80d245c0313f8a03f10fccc4b Mon Sep 17 00:00:00 2001 From: AlexanderKanakis Date: Fri, 23 Jul 2021 17:30:38 +0300 Subject: [PATCH] Ensure that no response is sent to DF after escalation to live agent --- lib/Dialogflow.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/Dialogflow.ts b/lib/Dialogflow.ts index b1894d8..89e66ce 100644 --- a/lib/Dialogflow.ts +++ b/lib/Dialogflow.ts @@ -1,4 +1,5 @@ import { IHttp, IHttpRequest, IModify, IPersistence, IRead } from '@rocket.chat/apps-engine/definition/accessors'; +import { ILivechatRoom } from '@rocket.chat/apps-engine/definition/livechat'; import { IRoom } from '@rocket.chat/apps-engine/definition/rooms'; import { createSign } from 'crypto'; import { AppSetting } from '../config/Settings'; @@ -20,6 +21,12 @@ class DialogflowClass { requestType: DialogflowRequestType): Promise { const serverURL = await this.getServerURL(read, modify, http, sessionId); + const room = await read.getRoomReader().getById(sessionId) as ILivechatRoom; + + if (room.customFields && room.customFields.isHandedOverFromDialogFlow) { + return {isFallback: false}; + } + const queryInput = { ...requestType === DialogflowRequestType.EVENT && { event: request }, ...requestType === DialogflowRequestType.MESSAGE && { text: { languageCode: LanguageCode.EN, text: request } },