private static KinesisLogEvent CreateTagEvent(SessionData sessionData, string tag, IDictionary <string, object> properties) { if (properties == null) { properties = new Dictionary <string, object>(); } AddStandardProperties(sessionData, properties); var indexName = (properties != null && properties.ContainsKey("partner")) ? "tag_events_" + ((string)properties["partner"]).ToLower() : "tag_events"; var indexType = (properties != null && properties.ContainsKey("partner")) ? "tag_events_" + ((string)properties["partner"]).ToLower() : "claims_tag_events"; KinesisLogEvent logEvent = new KinesisLogEvent { Session_id = sessionData.SessionId, Logger_info = "flow_engine:tag_events", Application_info = sessionData.PartnerContext, Data = "", Log = "", To_index = true, Index_type = indexType, Index_name = indexName, Index_content = new { chat_id = sessionData.ChatId, session_id = sessionData.SessionId, // Can't use standard "o" format, since it provides 6 digit milliseconds, which causes errors when its saved to Dynamo timestamp = AWSDynamoService.ToDynamoDateString(DateTime.UtcNow), tag, properties } }; return(logEvent); }
public async Task SendTranscriptEvent(ChatModel chat, string userInput, Stopwatch sw, ChatStepId[] currentSteps) { if (String.IsNullOrEmpty(StreamName)) { return; } var lastStep = currentSteps.LastOrDefault(); if (lastStep == null) { lastStep = new ChatStepId("none", "0"); } var data = new KinesisTranscriptData() { ProcessTime = sw.ElapsedMilliseconds, DetectedIntent = chat?.CurrentState.LastClassification?.GetBestResult()?.Intent, StepsTaken = currentSteps, Channel = chat?.CurrentState?.GlobalAnswers.GetFieldAnswer(ChatStandardField.Channel) }; if (chat?.CurrentState?.LastClassification?.GetBestResult() != null) { data.Probability = chat.CurrentState.LastClassification.GetBestResult().Probability; } KinesisLogEvent logEvent = new KinesisLogEvent { Session_id = chat?.ChatId ?? "00000000000000000000000000000000", Logger_info = String.Format("flow_engine:{0}:{1}", lastStep.FlowName, lastStep.StepId), Application_info = chat?.CurrentState.SessionData.PartnerContext, Data = JsonConvert.SerializeObject(data), Log = JsonConvert.SerializeObject(new KinesisLogMessage() { User = filterService.FilterHighRiskPII(chat?.CurrentState, userInput), Ava = chat?.CurrentState.GetLastMessage().BotQuestionsText } ) }; await PutRecordInternalAsync(logEvent); }
public async Task SendFailToUnderstandEvent(ChatModel chat, ChatFlowStep flowStep) { if (chat == null) { return; } var lastMessage = chat.CurrentState.GetLastMessage(); var properties = new Dictionary <string, object>(); AddStandardProperties(chat.CurrentState.SessionData, properties); KinesisLogEvent logEvent = new KinesisLogEvent { Session_id = chat.SessionLogId, Logger_info = String.Format("flow_engine:{0}:{1}", flowStep.Flow, flowStep.Id), Application_info = chat.CurrentState.SessionData.PartnerContext, Data = "", Log = "", To_index = true, Index_type = "engine_flowfailure", Index_name = "flow_failures", Index_content = new { chat_id = chat.ChatId, session_id = chat.SessionLogId, // Can't use standard "o" format, since it provides 6 digit milliseconds, which causes errors when its saved to Dynamo timestamp = AWSDynamoService.ToDynamoDateString(DateTime.UtcNow), step = new ChatStepId(flowStep), chat_text = filterService.FilterUserData(chat.CurrentState, lastMessage.UserInput), chat_corrected_text = filterService.FilterUserData(chat.CurrentState, lastMessage.CorrectedUserInput), bot_text = filterService.FilterUserData(chat.CurrentState, lastMessage.BotQuestionsText), properties } }; await PutRecordInternalAsync(logEvent); }
async Task InternalSendKinesisParseEvent(string parseType, string indexType, ChatModel chat, dynamic content) { var indexName = "classifier_data"; if (!String.IsNullOrEmpty(chat.CurrentState.SessionData.Partner)) { indexName = String.Format("classifier_data_{0}_{1}", chat.CurrentState.SessionData.Context, chat.CurrentState.SessionData.Partner).ToLower(); } KinesisLogEvent logEvent = new KinesisLogEvent { Session_id = chat.ChatId ?? "00000000000000000000000000000000", Logger_info = $"flow_engine:{parseType}", Application_info = chat.CurrentState.SessionData.PartnerContext, Data = "", Log = "", To_index = true, Index_type = indexType, Index_name = indexName, Index_content = content }; await PutRecordInternalAsync(logEvent); }
public async Task SendTagEventAsync(SessionData sessionData, string tagName, IDictionary <string, object> properties) { KinesisLogEvent logEvent = CreateTagEvent(sessionData, tagName, properties); await PutRecordInternalAsync(logEvent); }
public void SendTagEvent(SessionData sessionData, string tagName, IDictionary <string, object> properties) { KinesisLogEvent logEvent = CreateTagEvent(sessionData, tagName, properties); PutRecordInternal(logEvent); }