public static ReservationForm ReadFromWit(WitResult witResult) { var form = new ReservationForm(); if (witResult.TryFindEntity("restaurantname", out var restaurantNameEntity)) { form.RestaurantName = restaurantNameEntity.Value; } if (witResult.TryFindEntities("number", out var countEntities)) { var countEntity = countEntities.Skip(1).FirstOrDefault(); if (countEntity != null) { form.PeopleCount = int.Parse(countEntity.Value); } } if (witResult.TryFindEntity(WitBuiltinEntities.DateTime, out var dateTimeEntity) && DateTimeParser.TryParse(dateTimeEntity, out var range)) { form.ReservationDate = new DateTimeA(range.StartDate.DateTime); } return(form); }
public static OrderForm ReadFromWit(WitResult witResult) { var form = new OrderForm(); if (witResult.TryFindEntity("food", out var foodEntity)) { form.Item = foodEntity.Value; } if (witResult.TryFindEntity("number", out var itemCount)) { form.Count = int.Parse(itemCount.Value); } else { form.Count = 1; } if (witResult.TryFindEntity(WitBuiltinEntities.DateTime, out var dateTimeEntity) && DateTimeParser.TryParse(dateTimeEntity, out var range)) { form.DeliveryDate = range.StartDate.DateTime; } return(form); }
public async Task None(IDialogContext context, WitResult result) { var telemetryService = Conversation.Container.Resolve <ITelemetryService>(); var confidence = result.TryFindEntity("intent", out var intentEntity) ? intentEntity.Confidence : -1.0; telemetryService.UnrecognizedIntent(context.Activity.ChannelId, context.Activity.From.Id, context.Activity.AsMessageActivity().Text, confidence); await context.PostAsync("Je n'ai pas compris ce que vous avez dit."); }
public static ReservationForm ReadFromWit(WitResult witResult) { var form = new ReservationForm(); if (witResult.TryFindEntity("restaurantname", out var restaurantNameEntity)) { form.RestaurantName = restaurantNameEntity.Value; } if (witResult.TryFindEntity("people_count", out var countEntity)) { form.PeopleCount = int.Parse(countEntity.Value); } if (witResult.TryFindEntity(WitBuiltinEntities.DateTime, out var dateTimeEntity) && DateTimeParser.TryParse(dateTimeEntity, out var range)) { form.ReservationDate = range.StartDate.DateTime; } return(form); }
private void ReservationAskedTelemetry(IDialogContext context, WitResult result, ReservationForm form) { var telemetryService = Conversation.Container.Resolve <ITelemetryService>(); var confidence = result.TryFindEntity("intent", out var intentEntity) ? intentEntity.Confidence : -1; telemetryService.ReservationAsked(context.Activity.ChannelId, context.Activity.From.Id, context.Activity.AsMessageActivity().Text, confidence, form.PeopleCount.Value); }
private void OrderAskedTelemetry(IDialogContext context, WitResult result, OrderForm form) { var telemetryService = Conversation.Container.Resolve <ITelemetryService>(); var confidence = result.TryFindEntity("intent", out var intentEntity) ? intentEntity.Confidence : -1.0; telemetryService.OrderAsked(context.Activity.ChannelId, context.Activity.From.Id, context.Activity.AsMessageActivity().Text, confidence, form.Item, form.DeliveryDate.Value); }