public async Task <TaskModuleContinueResponse> OnTeamsTaskModuleFetchAsync(ITurnContext context, CancellationToken cancellationToken) { var taskModuleMetadata = context.Activity.GetTaskModuleMetadata <TaskModuleMetadata>(); var id = taskModuleMetadata.FlowData != null? JsonConvert.DeserializeObject <Dictionary <string, object> >(JsonConvert.SerializeObject(taskModuleMetadata.FlowData)) .GetValueOrDefault("IncidentId") : null; // Convert JObject to Ticket string incidentId = JsonConvert.DeserializeObject <string>(id.ToString()); return(new TaskModuleContinueResponse() { Value = new TaskModuleTaskInfo() { Title = "DeleteIncident", Height = "medium", Width = 500, Card = new Attachment { ContentType = AdaptiveCard.ContentType, Content = TicketDialogHelper.GetDeleteConfirmationCard(incidentId, _settings.MicrosoftAppId) } } }); }
// Handle Fetch public async Task <TaskModuleContinueResponse> OnTeamsTaskModuleFetchAsync(ITurnContext context, CancellationToken cancellationToken) { return(new TaskModuleContinueResponse() { Value = new TaskModuleTaskInfo() { Title = "Create Incident", Height = "medium", Width = 500, Card = new Attachment { ContentType = AdaptiveCard.ContentType, Content = TicketDialogHelper.CreateIncidentAdaptiveCard(_settings.MicrosoftAppId) } } }); }
public static TaskEnvelope GetUserInput() { var response = new TaskEnvelope { Task = new TaskProperty() { Type = "continue", TaskInfo = new TaskInfo() { Title = "GetUserInput", Height = "medium", Width = 500, Card = new Attachment { ContentType = AdaptiveCard.ContentType, Content = TicketDialogHelper.CreateIncidentAdaptiveCard() } } } }; return(response); }
protected async Task <DialogTurnResult> CreateTicketTeamsTaskModuleAsync(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken)) { // Send Create Ticket TaskModule Card var reply = sc.Context.Activity.CreateReply(); reply.Attachments = new List <Attachment>() { new Microsoft.Bot.Schema.Attachment() { ContentType = AdaptiveCard.ContentType, Content = TicketDialogHelper.GetUserInputIncidentCard(_settings.MicrosoftAppId) } }; // Get ActivityId for purpose of mapping ResourceResponse resourceResponse = await sc.Context.SendActivityAsync(reply, cancellationToken); ActivityReferenceMap activityReferenceMap = await _activityReferenceMapAccessor.GetAsync( sc.Context, () => new ActivityReferenceMap(), cancellationToken) .ConfigureAwait(false); // Store Activity and Thread Id activityReferenceMap[sc.Context.Activity.Conversation.Id] = new ActivityReference { ActivityId = resourceResponse.Id, ThreadId = sc.Context.Activity.Conversation.Id, }; await _activityReferenceMapAccessor.SetAsync(sc.Context, activityReferenceMap).ConfigureAwait(false); // Save Conversation State await _conversationState .SaveChangesAsync(sc.Context); return(await sc.EndDialogAsync()); }