-
Notifications
You must be signed in to change notification settings - Fork 528
Bot.Builder.Community.Adapters.Alexa not working with the VA #2403
Comments
This is probably caused by the default RouterDialog implementation. One option to try is overriding the ContinueDialogAsync method in MainDialog with the behavior you want. |
@samaea I have reproduced the issue. @lauren-mills was right, it is due to the RouterDialog looking for a value on the activity and treating it as an event, rather than a normal message activity. You can add the following override to your MainDialog as a workaround. With the only change being that we are checking if the channel ID is Alexa. After adding this change I can successfully get a response from the VA via Alexa. Hope that resolves your issue. protected override async Task<DialogTurnResult> OnContinueDialogAsync(DialogContext innerDc, CancellationToken cancellationToken = default)
{
var activity = innerDc.Context.Activity;
if (activity.IsStartActivity())
{
await OnStartAsync(innerDc);
}
switch (activity.Type)
{
case ActivityTypes.Message:
{
if (activity.Value != null && activity.ChannelId != "alexa")
{
await OnEventAsync(innerDc);
}
else if (!string.IsNullOrEmpty(activity.Text))
{
var result = await innerDc.ContinueDialogAsync();
switch (result.Status)
{
case DialogTurnStatus.Empty:
{
await RouteAsync(innerDc);
break;
}
case DialogTurnStatus.Complete:
{
await CompleteAsync(innerDc);
// End active dialog
await innerDc.EndDialogAsync();
break;
}
default:
{
break;
}
}
}
break;
}
case ActivityTypes.Event:
{
await OnEventAsync(innerDc);
break;
}
default:
{
await OnSystemMessageAsync(innerDc);
break;
}
}
return EndOfTurn;
} |
Thanks @garypretty! I have an open work item for the next release to refactor RouterDialog to align more with the SDK, so I can take this feedback in for that work as well. |
What project is affected?
Virtual Assistant.
What language is this in?
C#
What happens?
BotBuilder.Community.Adapters.Alexa doesn't seem to work with the VA.
What are the steps to reproduce this issue?
Followed the instructions here:- https://github.com/BotBuilderCommunity/botbuilder-community-dotnet/tree/develop/libraries/Bot.Builder.Community.Adapters.Alexa
Bot.Builder.Community.Adapters.Alexa;
Bot.Builder.Community.Adapters.Alexa.Integration.AspNet.Core;
Bot.Builder.Community.Adapters.Alexa.Middleware;
Before this code
I added:
What were you expecting to happen?
When testing the Alexa Skill through Alexa's developer console or via an Alexa device, for it to respond, but unfortunately it ends up calling OnEventSync() even though the activity type is of type message.
Can you share any logs, error output, etc.?
System.NullReferenceException thrown from the MainDialog.cs file:
Any screenshots or additional context?
Response from the VA to Alexa (response generated from the Startup.cs context.SendActivityAsync:- await context.SendActivityAsync("Sorry, something went wrong. Please try again later." + context + " Exception:" + exception):
The text was updated successfully, but these errors were encountered: