private async Task PizzaFormComplete(IDialogContext context, IAwaitable <PizzaOrder> result) { PizzaOrder order = null; try { order = await result; } catch (OperationCanceledException) { await context.PostAsync("You canceled the form!"); return; } if (order != null) { await context.PostAsync("Your Pizza Order: " + order.ToString()); } else { await context.PostAsync("Form returned empty response!"); } context.Wait(MessageReceived); }
/// <summary> /// Helper method that sends an `endOfConversation` activity. /// </summary> /// <param name="incomingActivity">The incoming user activity for this turn.</param> /// <param name="order">Optional. The completed order.</param> /// <param name="endOfConversationCode">Optional. The EndOfConversationCode to send to the parent bot. /// Defaults to EndOfConversationCodes.CompletedSuccessfully.</param> /// <remarks>Sending the `endOfConversation` activity when the conversation completes allows /// the bot to be consumed as a skill.</remarks> internal static async Task EndConversation(Activity incomingActivity, PizzaOrder order = null, string endOfConversationCode = EndOfConversationCodes.CompletedSuccessfully) { var connectorClient = _connectorClientCache.GetOrAdd(incomingActivity.ServiceUrl, key => { var appId = ConfigurationManager.AppSettings[MicrosoftAppCredentials.MicrosoftAppIdKey]; var appPassword = ConfigurationManager.AppSettings[MicrosoftAppCredentials.MicrosoftAppPasswordKey]; return(new ConnectorClient(new Uri(incomingActivity.ServiceUrl), appId, appPassword)); }); // Send End of conversation as reply. await connectorClient.Conversations.SendToConversationAsync(incomingActivity.CreateReply("Ending conversation from the skill...")); var endOfConversation = incomingActivity.CreateReply(); if (order != null) { endOfConversation.Value = JsonConvert.SerializeObject(order); } endOfConversation.Type = ActivityTypes.EndOfConversation; endOfConversation.Code = endOfConversationCode; await connectorClient.Conversations.SendToConversationAsync(endOfConversation); }