@@ -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' ;
@@ -73,6 +74,7 @@ export class PostMessageSentHandler {
7374 const { visitor : { token : visitorToken } } = room as ILivechatRoom ;
7475
7576 try {
77+ await botTypingListener ( rid , this . modify . getNotifier ( ) . typing ( { id : rid , username : DialogflowBotUsername } ) ) ;
7678 response = ( await Dialogflow . sendRequest ( this . http , this . read , this . modify , rid , text , DialogflowRequestType . MESSAGE ) ) ;
7779 } catch ( error ) {
7880 this . app . getLogger ( ) . error ( `${ Logs . DIALOGFLOW_REST_API_ERROR } ${ error . message } ` ) ;
@@ -97,11 +99,14 @@ export class PostMessageSentHandler {
9799 // synchronous handover check
98100 const { isFallback } = response ;
99101 if ( isFallback ) {
102+ await removeBotTypingListener ( rid ) ;
100103 return incFallbackIntentAndSendResponse ( this . read , this . modify , rid , createResponseMessage ) ;
101104 }
102105
103106 await createResponseMessage ( ) ;
104107
108+ await removeBotTypingListener ( rid ) ;
109+
105110 return resetFallbackIntent ( this . read , this . modify , rid ) ;
106111 }
107112
0 commit comments