@@ -6,6 +6,7 @@ import { AppSetting, DefaultMessage } from '../config/Settings';
66import { ActionIds } from '../enum/ActionIds' ;
77import { DialogflowRequestType , IDialogflowAction , IDialogflowMessage , IDialogflowPayload , LanguageCode , Message } from '../enum/Dialogflow' ;
88import { Logs } from '../enum/Logs' ;
9+ import { botTypingListener , removeBotTypingListener } from '../lib//BotTyping' ;
910import { Dialogflow } from '../lib/Dialogflow' ;
1011import { createDialogflowMessage , createMessage } from '../lib/Message' ;
1112import { handlePayloadActions } from '../lib/payloadAction' ;
@@ -66,6 +67,7 @@ export class PostMessageSentHandler {
6667 const { visitor : { token : visitorToken } } = room as ILivechatRoom ;
6768
6869 try {
70+ await botTypingListener ( rid , this . modify . getNotifier ( ) . typing ( { id : rid , username : DialogflowBotUsername } ) ) ;
6971 response = ( await Dialogflow . sendRequest ( this . http , this . read , this . modify , rid , text , DialogflowRequestType . MESSAGE ) ) ;
7072 } catch ( error ) {
7173 this . app . getLogger ( ) . error ( `${ Logs . DIALOGFLOW_REST_API_ERROR } ${ error . message } ` ) ;
@@ -90,11 +92,14 @@ export class PostMessageSentHandler {
9092 // synchronous handover check
9193 const { isFallback } = response ;
9294 if ( isFallback ) {
95+ await removeBotTypingListener ( rid ) ;
9396 return incFallbackIntentAndSendResponse ( this . read , this . modify , rid , createResponseMessage ) ;
9497 }
9598
9699 await createResponseMessage ( ) ;
97100
101+ await removeBotTypingListener ( rid ) ;
102+
98103 return resetFallbackIntent ( this . read , this . modify , rid ) ;
99104 }
100105
0 commit comments