You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{ "summary": "Sure, Please select the title, date & time for the meeting.", "fromDateTime": "", "toDateTime": "2025-01-08T04:45:00.000Z", "isAllDayEvent": true, "timeZone": "India Standard Time", "data": [ { "defaultDurationMinute": 15, "maxARP": 0, "maxBookingDuration": 0, "spaceTypeId": 2, "subSpaceTypeIds": [ 2 ], "earlyCheckinMinute": 15, "spaceCheckIn": true, "notificationTimes": [ { "subSpaceTypeId": 2, "time": 15 } ] } ] }
using following method in .NET solution
private AdaptiveCard GenerateAdaptiveCard(string contentPath, string cardData) { if (string.IsNullOrWhiteSpace(contentPath)) throw new ArgumentNullException(nameof(contentPath)); /*if (!string.IsNullOrWhiteSpace(cardData)) throw new ArgumentNullException(nameof(cardData));*/ var cardTemplate = File.ReadAllText(contentPath); var template = new AdaptiveCardTemplate(cardTemplate); var cardJson = template.Expand(cardData); //return cardJson; //// Parse the JSON AdaptiveCardParseResult result = AdaptiveCard.FromJson(cardJson); //// Get card from result AdaptiveCard card = result.Card; //card.Version = new AdaptiveSchemaVersion("1.3"); return card; ////var cardJson = new AdaptiveTransformer().Transform(cardTemplate, cardData); ////return AdaptiveCard.FromJson(cardJson).Card; }
public Activity GetActivityMessageForAdaptiveCard(string contentPath, string cardData) { if (string.IsNullOrWhiteSpace(contentPath)) throw new ArgumentNullException(nameof(contentPath)); /*if (!string.IsNullOrWhiteSpace(cardData)) throw new ArgumentNullException(nameof(cardData));*/ var adaptiveCard = this.GenerateAdaptiveCard(contentPath, cardData); var attachment = new Microsoft.Bot.Schema.Attachment { ContentType = AdaptiveCard.ContentType, Content = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(adaptiveCard)) //JsonConvert.DeserializeObject(adaptiveCard) }; var message = MessageFactory.Text(string.Empty); message.Attachments = new List<Attachment> { attachment }; message.InputHint = InputHints.IgnoringInput; ////message.Text = AdaptiveCardSpeakMessage.DefaultMessage; ////message.Speak = AdaptiveCardSpeakMessage.AdaptiveCardUserNotification; return message; }
var cardDataPath = "./Resources/MeetingDateTimeSelectionData.json"; var cardData = File.ReadAllText(cardDataPath);//JsonConvert.DeserializeObject(File.ReadAllText(cardDataPath)); //var cardTemplateData = JsonConvert.SerializeObject(cardData); var cardTemplatePath = "./Resources/MeetingDateTimeSelectionTemplate.json"; //await stepContext.Context.SendActivityAsync(GetActivityMessageForAdaptiveCard(cardTemplatePath, cardData), cancellationToken); await stepContext.Context.SendActivityAsync(GetActivityMessageForAdaptiveCard(cardTemplatePath, cardData), cancellationToken);
The text was updated successfully, but these errors were encountered:
Target Application
BotFramework WebChat
Application Operating System
Linux
Schema Version
1.5
Problem Description
We are using pre-built functions to round of time to next 15 mins Pre-built
The expression in JSON schema is
{
"type": "Input.Time",
"id": "fromDateTimeId",
"value": "${{if(empty(fromDateTime), convertFromUTC(formatTicks(mul(ceiling(div(int(ticks(addMinutes(utcNow(),15))),9000000000)),9000000000)), timeZone, 'HH:mm'), formatDateTime(fromDateTime, 'HH:mm'))}}"
}
Same JSON schema is working in Adaptive Card designer
Expected Outcome
Expecting the expression is evaluated and time is set in the field as in the designer
Actual Outcome
However the JSON schema is interpreted and parse as follows
{"type":"Input.Time","id":"fromDateTime","value":${${if(fromDateTime == null || fromDateTime == '', convertFromUTC(formatTicks(mul(ceiling(div(int(ticks(addMinutes(utcNow(),15))),9000000000)),9000000000)), timeZone, 'HH:mm'), formatDateTime(fromDateTime, 'HH:mm'))}}},{"type":"TextBlock","text":"End Time","wrap":true}
Card JSON
Repro Steps
Template JSON
{ "type": "AdaptiveCard", "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "version": "1.5", "body": [ { "type": "Container", "id": "plaintextbox", "items": [ { "type": "TextBlock", "text": "${summary}", "color": "Dark", "wrap": true } ] }, { "type": "Container", "id": "formfield", "items": [ { "type": "TextBlock", "text": "Add Title" }, { "type": "Input.Text", "id": "meetingTitle", "maxLength": 50, "value": "Team Meeting Created By Bot" }, { "type": "TextBlock", "text": "Date" }, { "type": "Input.Date", "id": "date", "value": "${if(fromDateTime == null || fromDateTime == '', convertFromUTC(utcNow(),timeZone,'yyyy-MM-dd'), formatDateTime(fromDateTime, 'yyyy-MM-dd'))}", "placeholder": "Enter a date" }, { "type": "TextBlock", "text": "Start Time", "wrap": true }, { "type": "Input.Time", "id": "fromDateTimeId", "value": "${{if(empty(fromDateTime), convertFromUTC(formatTicks(mul(ceiling(div(int(ticks(addMinutes(utcNow(),15))),9000000000)),9000000000)), timeZone, 'HH:mm'), formatDateTime(fromDateTime, 'HH:mm'))}}" }, { "type": "TextBlock", "text": "End Time", "wrap": true }, { "type": "Input.Time", "id": "toDateTime", "$data": "${data}", "value": "${if($root.toDateTime != null && $root.toDateTime != '', formatDateTime($root.toDateTime, 'HH:mm'), if($root.fromDateTime != null && $root.fromDateTime != '', formatDateTime(addMinutes($root.fromDateTime, defaultDurationMinute), 'HH:mm'), convertFromUTC(formatTicks(mul(ceiling(div(int(ticks(addMinutes(addMinutes(utcNow(),15),defaultDurationMinute))),9000000000)),9000000000)),$root.timeZone, 'HH:mm')))}" } ] }, { "type": "Container", "id": "SpaceFeedbackContainer", "items": [ { "type": "ColumnSet", "columns": [ { "type": "Column", "width": "auto", "items": [ { "type": "ActionSet", "actions": [ { "type": "Action.Submit", "title": "Confirm", "associatedInputs": "auto" } ] } ] }, { "type": "Column", "width": "auto", "items": [ { "type": "ActionSet", "id": "whiteBtn", "actions": [ { "type": "Action.Submit", "title": "Cancel", "associatedInputs": "none" } ] } ] } ] } ] } ] }
Data JSON
{ "summary": "Sure, Please select the title, date & time for the meeting.", "fromDateTime": "", "toDateTime": "2025-01-08T04:45:00.000Z", "isAllDayEvent": true, "timeZone": "India Standard Time", "data": [ { "defaultDurationMinute": 15, "maxARP": 0, "maxBookingDuration": 0, "spaceTypeId": 2, "subSpaceTypeIds": [ 2 ], "earlyCheckinMinute": 15, "spaceCheckIn": true, "notificationTimes": [ { "subSpaceTypeId": 2, "time": 15 } ] } ] }
using following method in .NET solution
private AdaptiveCard GenerateAdaptiveCard(string contentPath, string cardData) { if (string.IsNullOrWhiteSpace(contentPath)) throw new ArgumentNullException(nameof(contentPath)); /*if (!string.IsNullOrWhiteSpace(cardData)) throw new ArgumentNullException(nameof(cardData));*/ var cardTemplate = File.ReadAllText(contentPath); var template = new AdaptiveCardTemplate(cardTemplate); var cardJson = template.Expand(cardData); //return cardJson; //// Parse the JSON AdaptiveCardParseResult result = AdaptiveCard.FromJson(cardJson); //// Get card from result AdaptiveCard card = result.Card; //card.Version = new AdaptiveSchemaVersion("1.3"); return card; ////var cardJson = new AdaptiveTransformer().Transform(cardTemplate, cardData); ////return AdaptiveCard.FromJson(cardJson).Card; }
public Activity GetActivityMessageForAdaptiveCard(string contentPath, string cardData) { if (string.IsNullOrWhiteSpace(contentPath)) throw new ArgumentNullException(nameof(contentPath)); /*if (!string.IsNullOrWhiteSpace(cardData)) throw new ArgumentNullException(nameof(cardData));*/ var adaptiveCard = this.GenerateAdaptiveCard(contentPath, cardData); var attachment = new Microsoft.Bot.Schema.Attachment { ContentType = AdaptiveCard.ContentType, Content = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(adaptiveCard)) //JsonConvert.DeserializeObject(adaptiveCard) }; var message = MessageFactory.Text(string.Empty); message.Attachments = new List<Attachment> { attachment }; message.InputHint = InputHints.IgnoringInput; ////message.Text = AdaptiveCardSpeakMessage.DefaultMessage; ////message.Speak = AdaptiveCardSpeakMessage.AdaptiveCardUserNotification; return message; }
var cardDataPath = "./Resources/MeetingDateTimeSelectionData.json"; var cardData = File.ReadAllText(cardDataPath);//JsonConvert.DeserializeObject(File.ReadAllText(cardDataPath)); //var cardTemplateData = JsonConvert.SerializeObject(cardData); var cardTemplatePath = "./Resources/MeetingDateTimeSelectionTemplate.json"; //await stepContext.Context.SendActivityAsync(GetActivityMessageForAdaptiveCard(cardTemplatePath, cardData), cancellationToken); await stepContext.Context.SendActivityAsync(GetActivityMessageForAdaptiveCard(cardTemplatePath, cardData), cancellationToken);
The text was updated successfully, but these errors were encountered: