bot-handoff
Version:
Bot hand off module for the Microsoft Bot Framework. It allows you to transfer a customer from talking to a bot to talking to a human.
23 lines (19 loc) • 911 B
text/typescript
import * as Promise from 'bluebird';
import { IMessage } from 'botbuilder';
import { IHandoffMessage } from './../IHandoffMessage';
import { IProvider } from './../provider/IProvider';
export function getTranscribeBotMessagesMiddleware(provider: IProvider): (s: IMessage, n: Function) => void {
return (msg: IMessage, next: Function) => {
const message = msg as IHandoffMessage;
//tslint:disable
let transcribePromise = Promise.resolve() as Promise<any>;
//tslint:enable
// if neither agentAddress nor customerAddress are defined, then the message originated from the bot
if (message.type === 'message' && !message.customerAddress) {
transcribePromise = provider.addBotMessageToTranscriptIgnoringConversationState(message);
}
//tslint:disable
return transcribePromise.then(() => next())
//tslint:enable
};
}