简体   繁体   English

识别Web应用程序机器人上的自适应卡点击

[英]Recognizing Adaptive Card Clicks on Web app bot

My adaptive cards aren't recognizing clicks on the web app bot but are working on my local bot emulator 我的自适应卡无法识别对Web应用程序机器人的点击,但正在使用我的本地机器人模拟器

protected override async Task OnMessageActivityAsync(ITurnContext turnContext, CancellationToken cancellationToken) { Logger.LogInformation("Running dialog with Message Activity."); 受保护的重写异步任务OnMessageActivityAsync(ITurnContext turnContext,CancellationToken cancelToken){Logger.LogInformation(“正在运行带有消息活动的对话框。”);

        if (turnContext.Activity.Type == ActivityTypes.Message)
        {
            string temp1 = turnContext.Activity.ChannelData.ToString();
            string boolean = "false";
            Logger.LogInformation(temp1.Length.ToString());
            int len = temp1.Length;
            if (len > 70)
            {


                if (temp1.Substring(70, 4) != null)
                    boolean = temp1.Substring(70, 4);
                Logger.LogInformation(temp1.Substring(70, 4));
                if (boolean.Equals("true"))
                    boolean = "True";
                else { boolean = "True"; }
                Logger.LogInformation(boolean);
                bool entry = System.Convert.ToBoolean(boolean);

                if (entry)
                {
                    JToken commandToken = JToken.Parse(turnContext.Activity.Value.ToString());

                    string command = commandToken["action"].Value<string>();
                    string commandPrompt = command;

/* THIS IS WHERE THE CLICKS GET RECOGNIZED*//// / *这是单击识别的地方* ////

                    if (commandPrompt.Equals("order"))
                    {
                        string[] paths = { ".", "Cards", "orderCard.json" };
                        string fullPath = Path.Combine(paths);
                        var welcomeCard = CreateAdaptiveCardAttachment(fullPath);
                        var response = CreateResponse(turnContext.Activity, welcomeCard);

                        await turnContext.SendActivityAsync(response, cancellationToken);
                    }
                    else if (command.ToLowerInvariant() == "inventory")
                    {
                        string[] paths = { ".", "Cards", "InventoryCard.json" };
                        string fullPath = Path.Combine(paths);
                        var welcomeCard = CreateAdaptiveCardAttachment(fullPath);
                        var response = CreateResponse(turnContext.Activity, welcomeCard);
                        await turnContext.SendActivityAsync(response, cancellationToken);
                    }
                    else if (command.ToLowerInvariant() == "somethingelse")
                    {
                        commandPrompt = "somethingelse";
                        await Dialog.Run(turnContext, ConversationState.CreateProperty<DialogState>("DialogState"), cancellationToken);
                    }
                    else if (command.ToLowerInvariant() == "ordernumber")
                    {
                        string[] paths = { ".", "Cards", "orderNumberCard.json" };
                        string fullPath = Path.Combine(paths);
                        var welcomeCard = CreateAdaptiveCardAttachment(fullPath);
                        var response = CreateResponse(turnContext.Activity, welcomeCard);
                        await turnContext.SendActivityAsync(response, cancellationToken);
                    }
                    else if (command.ToLowerInvariant() == "upsordernumber")
                    {
                        string[] paths = { ".", "Cards", "upsOrderNumberCard.json" };
                        string fullPath = Path.Combine(paths);
                        var welcomeCard = CreateAdaptiveCardAttachment(fullPath);
                        var response = CreateResponse(turnContext.Activity, welcomeCard);
                        await turnContext.SendActivityAsync(response, cancellationToken);

                    }
                    else if (command.ToLowerInvariant() == "trackingnumber")
                    {
                        string[] paths = { ".", "Cards", "trackingNumberCard.json" };
                        string fullPath = Path.Combine(paths);
                        var welcomeCard = CreateAdaptiveCardAttachment(fullPath);
                        var response = CreateResponse(turnContext.Activity, welcomeCard);
                        await turnContext.SendActivityAsync(response, cancellationToken);

                    }
                    else if (command.ToLowerInvariant() == "trackingnumber")
                    {
                        string[] paths = { ".", "Cards", "trackingNumberCard.json" };
                        string fullPath = Path.Combine(paths);
                        var welcomeCard = CreateAdaptiveCardAttachment(fullPath);
                        var response = CreateResponse(turnContext.Activity, welcomeCard);
                        await turnContext.SendActivityAsync(response, cancellationToken);

                    }
                    else if (command.ToLowerInvariant() == "skunumber")
                    {
                        string[] paths = { ".", "Cards", "skuNumberCard.json" };
                        string fullPath = Path.Combine(paths);
                        var welcomeCard = CreateAdaptiveCardAttachment(fullPath);
                        var response = CreateResponse(turnContext.Activity, welcomeCard);
                        await turnContext.SendActivityAsync(response, cancellationToken);

                    }
                    else if (command.ToLowerInvariant() == "ponumber")
                    {
                        string[] paths = { ".", "Cards", "poNumberCard.json" };
                        string fullPath = Path.Combine(paths);
                        var welcomeCard = CreateAdaptiveCardAttachment(fullPath);
                        var response = CreateResponse(turnContext.Activity, welcomeCard);
                        await turnContext.SendActivityAsync(response, cancellationToken);

                    }
                    else
                    {
                        await turnContext.SendActivityAsync($"I'm sorry, I didn't understand that. Please try again", cancellationToken: cancellationToken);
                    }
                }
            }
            else
            {
                await Dialog.Run(turnContext, ConversationState.CreateProperty<DialogState>("DialogState"), cancellationToken);
            }
        }

        // Run the Dialog with the new message Activity.

    }
}

} }

/*Json File*/
{
  "type": "AdaptiveCard",
  "selectAction": {
    "type": "Action.Submit"
  },
  "body": [
    {
      "type": "Container",
      "items": [
        {
          "type": "TextBlock",
          "size": "Medium",
          "weight": "Bolder",
          "text": "Hi How can I help you today?"
        }
      ]
    },
    {
      "type": "Container",
      "items": [
        {
          "type": "TextBlock",
          "text": "Please select one of the following options to get started",
          "wrap": true
        }
      ]
    }
  ],
  "actions": [
    {
      "type": "Action.Submit",
      "id": "orderButton",
      "title": "Order",
      "data": {
        "action": "order"
      }
    },
    {
      "type": "Action.Submit",
      "id": "inventoryButton",
      "title": "Inventory",
      "data": {
        "action": "inventory"
      }
    },
    {
      "type": "Action.Submit",
      "id": "somethingelseButton",
      "title": "Something Else",
      "data": {
        "action": "somethingElse"
      }
    }
  ],
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.0"
}

/ Json File / / Json文件 /

no error output on webappbot just won't open the next card. 在webappbot上没有错误输出,只是不会打开下一张卡。 But is working on my bot emulator 但是正在使用我的机器人模拟器

The issue is that both "Test in Web Chat" and the Web Chat iFrame code still uses WebChat V3, which doesn't support Adaptive Cards well. 问题是“在Web聊天中测试”和Web聊天iFrame代码仍然使用WebChat V3,它不能很好地支持自适应卡。 WebChat V4 should be rolling out to both of those in the next couple of weeks. WebChat V4应该在接下来的几周内同时推广到这两个平台。

In the meantime, you can switch from the <embed> to one of the WebChat Samples 同时,您可以从<embed>切换到WebChat示例之一

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以在 Web App Bot 中翻译自适应卡? - Is it possible to translate Adaptive Cards within the Web App Bot? 是否可以在瀑布对话框中设置带有日期输入的自适应卡片?(在 Web 和 Teams 上使用 Bot Framework) - Is it possible to set an adaptive card with date input in a waterfall dialog?(Using Bot Framework on Web and Teams) 在bot启动时发送自适应卡作为欢迎消息 - Sending an Adaptive Card on bot startup as the welcome message 更改自适应卡片机器人框架的分隔符属性 - Change separator property of a adaptive card bot framework 下拉自适应卡 - BOT 框架 - Drop down on adaptive card - BOT framework Bot Framework - 自适应卡 - 无法在 Direct Line 中渲染卡 - Bot Framework - Adaptive Card - Can't render card in Direct Line 自适应卡片:在自适应卡片的下拉列表中动态显示卡片:Bot Builder - Adaptive Card: Dynamically show Card on dropdown click in Adaptive Card : Bot Builder [BotFramework]:如何在瀑布对话框中捕获/提取通过C#Web聊天bot中呈现的自适应卡提交的值? - [BotFramework]: How to capture/extract the values submitted through Adaptive card rendered in C# Web Chat bot in a waterfall dialog? 自适应卡未在 web 应用程序中显示图像 - Adaptive Card is not showing the image in web application 是否可以打开URL并通过自适应卡向机器人提交“操作”? - Is it possible to open an URL and submit an “Action” to the bot via an adaptive card?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM