Giter Site home page Giter Site logo

Comments (4)

InfinytRam avatar InfinytRam commented on June 1, 2024

Hi @nouman937,

Let's try to isolate this issue to find the root cause of this problem.

Is this issue reproducible without omnichannel?

from botframework-sdk.

nouman937 avatar nouman937 commented on June 1, 2024

from botframework-sdk.

InfinytRam avatar InfinytRam commented on June 1, 2024

Hi @nouman937, I can look into this.

from botframework-sdk.

InfinytRam avatar InfinytRam commented on June 1, 2024

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:

Screen.Recording.2024-02-09.at.3.38.27.PM.mov

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

from botframework-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.