Open nouman937 opened 8 months ago
Hi @nouman937,
Let's try to isolate this issue to find the root cause of this problem.
Is this issue reproducible without omnichannel?
Hi,
We haven't tried it without Omnichannel as it will require further configurations and development.
On Sun, 21 Jan 2024, 5:02 am Ram Page, @.***> wrote:
Hi @nouman937 https://github.com/nouman937,
Let's try to isolate this issue to find the root cause of this problem.
Is this issue reproducible without omnichannel?
— Reply to this email directly, view it on GitHub https://github.com/microsoft/botframework-sdk/issues/6632#issuecomment-1902452272, or unsubscribe https://github.com/notifications/unsubscribe-auth/BCPWAN2RYMNYIVFG6WMEJWLYPRLK7AVCNFSM6AAAAABCDICKV2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBSGQ2TEMRXGI . You are receiving this because you were mentioned.Message ID: @.***>
Hi @nouman937, I can look into this.
Hi @nouman937,
I isolated this issue from omnichannel and was not able to repro. The OnMessageActivityAsync
handler successfully gets triggered when a user selects an option from adaptive card in Facebook.
I modified the 02.echo-bot sample to send the adaptive card like this:
protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
var receivedText = turnContext.Activity.Text?.ToLower();
if (receivedText == "card")
{
await SendAdaptiveCardAsync(turnContext, cancellationToken);
}
else
{
var replyText = $"Echo: {turnContext.Activity.Text}";
await turnContext.SendActivityAsync(MessageFactory.Text(replyText, replyText), cancellationToken);
}
}
private async Task SendAdaptiveCardAsync(ITurnContext turnContext, CancellationToken cancellationToken)
{
var card = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0))
{
Actions = new List<AdaptiveAction>
{
new AdaptiveSubmitAction
{
Title = "Option 1",
Data = "option1"
},
new AdaptiveSubmitAction
{
Title = "Option 2",
Data = "option2"
}
}
};
var attachment = new Attachment
{
ContentType = AdaptiveCard.ContentType,
Content = JObject.FromObject(card)
};
var response = MessageFactory.Attachment(attachment);
await turnContext.SendActivityAsync(response, cancellationToken);
}
Demo:
https://github.com/microsoft/botframework-sdk/assets/38049078/97c5c3ba-aba3-44b0-b246-29db491f959d
Documentation followed: https://learn.microsoft.com/en-us/azure/bot-service/bot-service-channel-connect-facebook?view=azure-bot-service-4.0&tabs=messenger
Attached is the tested bot sample: 02.echo-bot.zip
We are using Azure bot framework that is connected to Omnichannel solution. Customer connects to Facebook messenger it gets routed to Omnichannel and then omnichannel routes the conversation to Azure bot as an agent. Bot is asking customer to select an option using adaptive card which is being used as CardActivity and sent to customer using ChoicePrompt as can be seen in the code below. Based on the option select, We are performing further action like initiating a chat with actual agent in omnichannel. The issue is that when customer select an option from adaptive card on Facebook, the "OnMessageActivityAsync" is not getting triggered in our DialogBot class and hence we are not able to find out what the customer has selected. This functionality is working fine on bot emulator but not on Facebook as can be seen in snapshots
To Reproduce
1) Create adaptive card with one user input 2) Integrate it with Facebook 3) Based on user input, parse the response within chatbot code
Expected behavior
When user selects an option, the OnMessageActivityAsync should be triggered with user input response
Code for Adaptive Card
//Card Activity Cardactivity = MessageFactory.Attachment(new Attachment { ContentType = AdaptiveCard.ContentType, // Convert the AdaptiveCard to a JObject Content = JObject.FromObject(card), });
return await stepContext.PromptAsync(nameof(ChoicePrompt), new PromptOptions { Prompt = (Activity)Cardactivity, Choices = ChoiceFactory.ToChoices(stepList), // Don't render the choices outside the card Style = ListStyle.None, }, cancellationToken);
Screenshots
Attached