Example #1
0
        public static VmIntentResponse FromIntentResponse(IntentResponse intentResponse)
        {
            var response = new VmIntentResponse
            {
                Action = intentResponse.Action
            };

            response.AffectedContexts = intentResponse.Contexts.Select(ctx => ctx.ToObject <VmIntentResponseContext>()).ToList();

            response.Parameters = intentResponse.Parameters.Select(p => VmIntentResponseParameter.FromIntentResponseParameter(p)).ToList();

            response.Messages = intentResponse.Messages.Select(msg => {
                if (msg.Speech == null)
                {
                    return(new VmIntentResponseMessage());
                }

                return(new VmIntentResponseMessage
                {
                    Payload = msg.Payload,
                    Type = msg.Type,
                    Speeches = JsonConvert.DeserializeObject <List <String> >(msg.Speech)
                });
            }).ToList();

            return(response);
        }
        public static VmIntentResponseParameter FromIntentResponseParameter(IntentResponseParameter parameter)
        {
            var p = new VmIntentResponseParameter
            {
                DataType     = parameter.DataType,
                DefaultValue = parameter.DefaultValue,
                IsList       = parameter.IsList,
                Name         = parameter.Name,
                Required     = parameter.Required,
                Value        = parameter.Value,
                Prompts      = parameter.Prompts.Select(x => x.Prompt).ToList()
            };

            return(p);
        }