public async Task <object> Handle(Activity activity) { var data = ((JObject)activity.Value).GetValue("data"); var editForm = JsonSerializer.Deserialize <CompetitionEditForm>(Newtonsoft.Json.JsonConvert.SerializeObject(data)); var plannedDrawTime = editForm.GetPlannedDrawTime(activity.GetOffset(), _dateTimeService.UtcNow.AddHours(2)); var localPlannedDrawTime = plannedDrawTime.ToOffset(activity.GetOffset()); var errorMessage = CanPreviewCompetition(editForm.Gift, int.Parse(editForm.WinnerCount), plannedDrawTime, editForm.GiftImageUrl, activity.Locale); if (string.IsNullOrEmpty(errorMessage)) { var card = _activityBuilder.CreatePreviewCard(editForm, localPlannedDrawTime, activity.Locale); var preview = MessageFactory.Attachment(card) as Activity; preview.Value = editForm; var response = new MessagingExtensionActionResponse { ComposeExtension = new MessagingExtensionResult { Type = "botMessagePreview", ActivityPreview = preview } }; return(await Task.FromResult(response)); } else { var card = _activityBuilder.CreateComposeEditForm(editForm.Gift, int.Parse(editForm.WinnerCount), editForm.GiftImageUrl, localPlannedDrawTime, errorMessage, activity.Locale); var taskInfo = new TaskModuleContinueResponse { Type = "continue", Value = new TaskModuleTaskInfo { Title = string.Empty, Width = "medium", Card = card } }; var response = new MessagingExtensionActionResponse { Task = taskInfo }; return(await Task.FromResult(response)); } }