0
votes

I have an adaptive card where I take dates from the user using a date picker adaptive card. I have running code for my web client, which works perfectly, Now when I integrate my code using Azure Channels for Microsoft Teams, the bot works fine, I get to see the adaptive card also but when I press submit button after filling in the dates on the adaptive card I am getting this error

[11:39 AM] mts-bot
    Microsoft.Bot.Schema.ErrorResponseException: Operation returned an invalid status code 'BadRequest'
at Microsoft.Bot.Connector.Conversations.ReplyToActivityWithHttpMessagesAsync(String conversationId, String activityId, Activity activity, Dictionary2 customHeaders, CancellationToken cancellationToken) at Microsoft.Bot.Connector.ConversationsExtensions.ReplyToActivityAsync(IConversations operations, String conversationId, String activityId, Activity activity, CancellationToken cancellationToken) at Microsoft.Bot.Builder.BotFrameworkAdapter.SendActivitiesAsync(ITurnContext turnContext, Activity[] activities, CancellationToken cancellationToken) at Microsoft.Bot.Builder.TurnContext.<>c__DisplayClass22_0.<<SendActivitiesAsync>g__SendActivitiesThroughAdapter|1>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.Bot.Builder.TurnContext.SendActivityAsync(IActivity activity, CancellationToken cancellationToken) at Microsoft.BotBuilderSamples.DispatchBot.ProcessLeaveApplicationLUIS(ITurnContext1 turnContext, LuisResult luisResult, CancellationToken cancellationToken) in D:\nikhil\Alfi\mts-qna+luis\Bots\DispatchBot.cs:line 897

I have tried looking for a solution for this issue I followed what was said in this - Chat BoT Exception: OnTurnAsync exception-- Operation returned an invalid status code 'BadRequest'

Here someone told to do this

var reply = new Activity();

to

var reply = turnContext.Activity.AsMessageActivity(); 

in onMessageActivityAsync method, but I am not sending a reply like this I am sending my response

await turnContext.SendActivityAsync(MessageFactory.Text("Hi how are you?"), cancellationToken);

Really looking ahead for a quick solution, I have raised the support request in Microsoft for this with ticket number 17896525 but its been 2 days not getting a solution from there.

 private Attachment LeavesDatesAdaptiveCardAttachment()
        {
            // combine path for cross platform support
            string[] paths = { ".", "Cards", "Dates.json" };
            string fullPath = Path.Combine(paths);
            var adaptiveCard = File.ReadAllText(fullPath);



            return new Attachment()
            {
                ContentType = "application/vnd.microsoft.card.adaptive",
                Content = JsonConvert.DeserializeObject(adaptiveCard),

            };
        }
1
Is this date-picker-card in a messaging extension or just conversation?JJ_Wailes
just conversationNikhil Bansal
Can you please share the adaptive card jsonSubhasish
The shared JSON is working form me. I am able to submit from the adaptive card. Can you thy this Adaptive card sampleSubhasish

1 Answers

0
votes

For rendering adaptive card in Teams we need to update data section for buttons in json file.

viz for web chat

            "type": "Action.Submit",
            "data": "Your Button Data",
            "title": "feedback"
          }

For MS Teams:

            "type": "Action.Submit",
            "data": {
              "msteams": {
                "type": "imback",
                "value": "Poor"
              }
            },
            "title": "feedback"
          }```