0

I encountered a “date” issue with Bot in TEAMS, The date value cannot render at LeaveRequest() properly. However, the same bot works fine in Bot Emulator.

Following is my sample code. How to fix (or workaround) this issue?

Select a date from date picker and submit enter image description here

System does not render the first field value. enter image description here

    public class EchoBot
    {
        public static Attachment LeaveRequest()
        {
            AdaptiveSchemaVersion schemaVersion = new AdaptiveSchemaVersion(1, 0);
            AdaptiveCard card = new AdaptiveCard(schemaVersion);
            card.Body.Add(new AdaptiveTextBlock()
            {
                Text = "Enter new Date",
                Size = AdaptiveTextSize.Large,
                Weight = AdaptiveTextWeight.Bolder
            });
            AdaptiveDateInput fromDate = new AdaptiveDateInput()
            {
                Id = "FromDate",
                Placeholder = "From Date"
            };
            card.Body.Add(fromDate);
            AdaptiveTextInput toDate = new AdaptiveTextInput()
            {
                Id = "ToDate",
                Placeholder = "To Date",
                Value = DateTime.Today.ToUniversalTime().ToString("u")
            };
            card.Body.Add(toDate);
            card.Actions.Add(new AdaptiveSubmitAction()
            {
                Title = "Submit"
            });
            Attachment cardAttachment = new Attachment()
            {
                ContentType = AdaptiveCard.ContentType,
                Content = card
            };
            return cardAttachment;
        }
    }

    public class RootDialog : IDialog<object>
    {
        public async Task StartAsync(IDialogContext context)
        {
            context.Wait(MessageReceivedAsync);
        }
        public virtual async Task MessageReceivedAsync(IDialogContext context, 
        IAwaitable<IMessageActivity> result)
        {
            var activity = await result as Activity;
            Boolean first = true;
            if (activity.Value != null)
            {
                var jObjectValue = activity.Value as JObject;
                var fromDateString = jObjectValue.Value<string>("FromDate");
                var toDateString = jObjectValue.Value<string>("ToDate");

                await context.PostAsync($"from Date Entered: {fromDateString}");
                await context.PostAsync($"to Date Entered: {toDateString}");
                first = false;
            }
            if (first)
            {
                var reply = activity.CreateReply();
                var card = EchoBot.LeaveRequest();
                var msg = context.MakeMessage();
                msg.Attachments.Add(card);
                await context.PostAsync(msg);
            }
        }
    }

1 Answer 1

1

Thanks for reaching out!! This is a known issue. We have a bug on this and we are working on getting this fixed.

Not the answer you're looking for? Browse other questions tagged or ask your own question.