-
Notifications
You must be signed in to change notification settings - Fork 66
Bot Framework V4 Human Handoff Middlewareset Issue #42
Description
Hello,
Please help me
I am a beginner for the Human Handover in the V4 bot framework. I am following the approach of the middleware. Also, I have the LUIS as well added as a service to my bot.
I added the middleware in my Startup.cs file as follows.
services.AddBot(options =>
{
options.CredentialProvider = new SimpleCredentialProvider(endpointService.AppId, endpointService.AppPassword);
// Catches any errors that occur during a conversation turn and logs them to currently
// configured ILogger.
ILogger logger = _loggerFactory.CreateLogger<BasicLUISBot>();
options.OnTurnError = async (context, exception) =>
{
logger.LogError($"Exception caught : {exception}");
await context.SendActivityAsync($"Sorry, it looks like something went wrong. {exception}");
};
options.Middleware.Add(new HandoffMiddleware(Configuration));
});
I am using the Microsoft.Bot.Builder version 4.1.5
My Middleware code is
public async Task OnTurnAsync(ITurnContext context, NextDelegate next, CancellationToken cancellationToken)
{
Activity activity = context.Activity;
if (activity.Type is ActivityTypes.Message)
{
MessageRouter.StoreConversationReferences(activity);
AbstractMessageRouterResult messageRouterResult = null;
// Check the activity for commands
if (await CommandHandler.HandleCommandAsync(context) == false)
{
messageRouterResult = await MessageRouter.RouteMessageIfSenderIsConnectedAsync(activity);
if (messageRouterResult is MessageRoutingResult
&& (messageRouterResult as MessageRoutingResult).Type == MessageRoutingResultType.NoActionTaken)
{
if (!string.IsNullOrWhiteSpace(activity.Text)
&& (activity.Text.ToLower() == "human"))
{
messageRouterResult = MessageRouter.CreateConnectionRequest(
MessageRouter.CreateSenderConversationReference(activity),
true);
}
else
{
// No action taken - this middleware did not consume the activity so let it propagate
await next(cancellationToken);
}
}
}
When I run the solution in the emulator, the create connection is assigned to "NotSetup" even i connected in two seperate instances in the emlator and during debug I get the following error

Please help me here