// [START dialogflow_create_session_entity_type]
        public static int Create(string projectId,
                                 string sessionId,
                                 string entityTypeDisplayName,
                                 string[] entityValues)
        {
            var client = SessionEntityTypesClient.Create();

            var sessionEntityType = new SessionEntityType();

            sessionEntityType.SessionEntityTypeName = new SessionEntityTypeName(projectId, sessionId, entityTypeDisplayName);
            sessionEntityType.EntityOverrideMode    = SessionEntityType.Types.EntityOverrideMode.Override;
            foreach (var entityValue in entityValues)
            {
                var entity = new EntityType.Types.Entity()
                {
                    Value = entityValue
                };
                entity.Synonyms.Add(entityValue);
                sessionEntityType.Entities.Add(entity);
            }

            var createdSessionEntityType = client.CreateSessionEntityType(
                parent: new SessionName(projectId, sessionId),
                sessionEntityType: sessionEntityType
                );

            Console.WriteLine($"Created SessionEntityType: {createdSessionEntityType.Name}");

            return(0);
        }
        // [START dialogflow_create_entity]
        public static int Create(string projectId,
                                 string entityTypeId,
                                 string entityValue,
                                 string[] synonyms)
        {
            var client = EntityTypesClient.Create();

            var entity = new EntityType.Types.Entity()
            {
                Value = entityValue
            };

            entity.Synonyms.AddRange(synonyms);

            var operation = client.BatchCreateEntities(
                parent: new EntityTypeName(projectId, entityTypeId),
                entities: new[] { entity }
                );

            Console.WriteLine("Waiting for the entity creation operation to complete.");
            operation.PollUntilCompleted();

            Console.WriteLine($"Entity creation completed.");

            return(0);
        }
        public ActionResult CriarEntidade()
        {
            //usa credencias

            Google.Cloud.Dialogflow.V2.EntityTypesClient c = EntityTypesClient.Create();

            EntityType entidade = new EntityType();

            entidade.DisplayName = "Cursos";
            entidade.Kind        = EntityType.Types.Kind.Map;

            DAL.CursoDAL dal = new DAL.CursoDAL();

            foreach (var curso in dal.ObterTodos())
            {
                var item = new EntityType.Types.Entity();
                item.Value = curso.Nome;

                foreach (var s in curso.Sinonimos)
                {
                    item.Synonyms.Add(s);
                }

                entidade.Entities.Add(new EntityType.Types.Entity(item));
            }

            var request = new Google.Cloud.Dialogflow.V2.CreateEntityTypeRequest();

            request.EntityType = entidade;
            request.ParentAsProjectAgentName = new ProjectAgentName(_agentName);

            c.CreateEntityType(request);


            return(Ok("Entidade criada."));
        }