private async Task MessageReceived(IDialogContext context, IAwaitable <IMessageActivity> result) { var message = await result; if (await _userToAgent.IsWantToTalkWithHuman(message as Activity, default(CancellationToken))) { var agent = await _userToAgent.IntitiateConversationWithAgentAsync(message as Activity, default(CancellationToken)); if (agent == null) { await context.PostAsync(ConversationText.AllAgentAreBusy); } } else if (!string.IsNullOrEmpty(message.Text)) { var qnaSubscriptionKey = ConfigurationManager.AppSettings["QnASubscriptionKey"]; var qnaKBId = ConfigurationManager.AppSettings["QnAKnowledgebaseId"]; // QnA Subscription Key and KnowledgeBase Id null verification if (!string.IsNullOrEmpty(qnaSubscriptionKey) && !string.IsNullOrEmpty(qnaKBId)) { await context.Forward(new BasicQnAMakerDialog(), AfterAnswerAsync, message, CancellationToken.None); } else { await context.PostAsync(ConversationText.NeedQnAMakerSetting); } } else { await context.PostAsync(message.Text); } context.Done(true); }
public async Task AgentTransfer(IDialogContext context, IAwaitable <IMessageActivity> message, LuisResult luisResult) { var activity = await message; var agent = await _userToAgent.IntitiateConversationWithAgentAsync(activity as Activity, default(CancellationToken)); if (agent == null) { await context.PostAsync("All our customer care representatives are busy at the moment. Please try after some time."); } context.Done <object>(null); }
private async Task MessageReceived(IDialogContext context, IAwaitable <IMessageActivity> result) { var message = await result; if (message.Text.StartsWith("a")) { var agent = await _userToAgent.IntitiateConversationWithAgentAsync(message as Activity, default(CancellationToken)); if (agent == null) { await context.PostAsync("All our customer care representatives are busy at the moment. Please try after some time."); } } else { await context.PostAsync(message.Text); } context.Done(true); }
private async Task <IMessageActivity> GetMessageFromText(IDialogContext context, Activity activity, string text) { IMessageActivity nextMessage = null; if (text == "reset" || text == "start over" || text == "restart") { context.PrivateConversationData.Clear(); nextMessage = await GetCard(activity, "Welcome", context); } else if (text == "connect with agent") { Attachment cardAttachment = null; var msg = ""; var agent = await _userToAgent.IntitiateConversationWithAgentAsync(activity, default(CancellationToken)); if (agent == null) { //await context.PostAsync("All our customer care representatives are busy at the moment. Please try after some time."); msg = "All our customer care representatives are busy at the moment. Please try after some time."; } else { msg = "Hello, how can I help you?"; } cardAttachment = await CardService.GetCardAttachment("NormalMessage", new object[] { msg, context }); nextMessage = GetCardReply(activity, cardAttachment); } else { //TODO: help } return(nextMessage); }