private async Task UpdateOrderingState(WitResult witResult, ITurnContext turnContext)
        {
            var orderingState = await _orderingStateAccessor.GetAsync(turnContext, () => new OrderingState());

            var entities = GetWitEntities(witResult);

            // Wit Entities
            string[] pizzaNameEntities   = { "pizza_name" };
            string[] pizzaPiecesEntities = { "number" };

            foreach (var name in pizzaNameEntities)
            {
                if (entities.ContainsKey(name) && entities[name] != null)
                {
                    orderingState.PizzaName = entities[name][0];
                    break;
                }
            }

            foreach (var pieces in pizzaPiecesEntities)
            {
                if (entities.ContainsKey(pieces) && entities[pieces] != null)
                {
                    if (int.TryParse(entities[pieces][0], out int num))
                    {
                        orderingState.PizzaPieces = num;
                        break;
                    }
                }
            }

            await _orderingStateAccessor.SetAsync(turnContext, orderingState);
        }
        private string GetWitIntent(WitResult witResult)
        {
            if (witResult.entities != null && witResult.entities.intent != null && witResult.entities.intent.Length > 0 &&
                !string.IsNullOrEmpty(witResult.entities.intent[0].value))
            {
                return(witResult.entities.intent[0].value);
            }

            return(NoneIntent);
        }
        private IDictionary <string, string[]> GetWitEntities(WitResult witResult)
        {
            var entities = new Dictionary <string, string[]>();

            if (witResult.entities != null)
            {
                if (witResult.entities.pizza_name != null && witResult.entities.pizza_name.Length > 0 &&
                    !string.IsNullOrEmpty(witResult.entities.pizza_name[0].value))
                {
                    entities.Add("pizza_name", new string[] { witResult.entities.pizza_name[0].value });
                }

                if (witResult.entities.number != null && witResult.entities.number.Length > 0)
                {
                    entities.Add("number", new string[] { witResult.entities.number[0].value.ToString() });
                }
            }

            return(entities);
        }