Skip to content

Instantly share code, notes, and snippets.

@scorredoira
Last active July 26, 2025 18:28
Show Gist options
  • Save scorredoira/ac9f680e6cca690307ef28d7395722b1 to your computer and use it in GitHub Desktop.
Save scorredoira/ac9f680e6cca690307ef28d7395722b1 to your computer and use it in GitHub Desktop.

go run cmd/main.go

██╗   ██╗██████╗      █████╗  ██████╗ ███████╗███╗   ██╗████████╗
██║   ██║╚════██╗    ██╔══██╗██╔════╝ ██╔════╝████╗  ██║╚══██╔══╝
██║   ██║ █████╔╝    ███████║██║  ███╗█████╗  ██╔██╗ ██║   ██║   
╚██╗ ██╔╝ ╚═══██╗    ██╔══██║██║   ██║██╔══╝  ██║╚██╗██║   ██║   
 ╚████╔╝ ██████╔╝    ██║  ██║╚██████╔╝███████╗██║ ╚████║   ██║   
  ╚═══╝  ╚═════╝     ╚═╝  ╚═╝ ╚═════╝ ╚══════╝╚═╝  ╚═══╝   ╚═╝   
                                                                  
    🚀 Advanced AI Assistant with Semantic Search & Function Calling
       💬 Just start chatting or type 'help' for commands

You: como puedo leer clientes.
Agent: Según la documentación, puede obtener la lista de clientes usando el siguiente endpoint:

GET https://[host]/api/model/customer

Características importantes:

  1. Autenticación requerida:
  • Header "key": [su API key]
  • Header "tenant": [su tenant]
  1. Paginación:
  • Por defecto devuelve 20 resultados por página
  • Puede usar el parámetro "limit" para ajustar resultados (20-100)
  • Para obtener la siguiente página use "lastId"
  1. Filtrado (opcional):
  • Use el parámetro "search" para filtrar resultados
  • Ejemplo para buscar por nombre:
    GET https://[host]/api/model/customer?search=["name","=","valor"]
    
  1. Selección de campos (opcional):
  • Use el parámetro "fields" para especificar qué campos retornar
  • Ejemplo para obtener solo nombre y email:
    GET https://[host]/api/model/customer?fields=["name","email"]
    

Los campos principales disponibles incluyen:

  • id
  • name (nombre completo)
  • firstName (nombre)
  • lastName (apellido)
  • email
  • phone
  • taxNumber (número fiscal)
  • address (campos: street, city, zipCode, etc.)

¿Necesita información específica sobre algún aspecto de la API de clientes?

You: dame un ejemplo en curl para buscar clientes que se llamen pedro o juan o maría.
Agent: Basado en la documentación, aquí tienes un ejemplo de curl para buscar clientes que se llamen Pedro, Juan o María:

curl -H "key: [apiKey]" \
     -H "tenant: [tenant]" \
     "https://[host]/api/model/customer?search=[\"OR\",[\"firstName\",\"=\",\"Pedro\"],[\"firstName\",\"=\",\"Juan\"],[\"firstName\",\"=\",\"María\"]]"

Notas importantes:

  1. Necesitarás reemplazar [apiKey], [tenant] y [host] con tus credenciales reales
  2. El ejemplo usa el campo "firstName" que es el nombre de pila
  3. La búsqueda usa el operador "OR" para combinar las tres condiciones
  4. La URL debe estar correctamente codificada en una situación real

Si prefieres buscar en el nombre completo (que podría incluir apellidos), puedes usar el campo "name" en lugar de "firstName":

curl -H "key: [apiKey]" \
     -H "tenant: [tenant]" \
     "https://[host]/api/model/customer?search=[\"OR\",[\"name\",\"=\",\"Pedro\"],[\"name\",\"=\",\"Juan\"],[\"name\",\"=\",\"María\"]]"

You: y que su fecha de creación sea anterior al año pasado.
Agent: Here is the curl example modified to search for customers named Pedro, Juan or María AND whose creation date is before last year (2023):

curl -H "key: [apiKey]" \
     -H "tenant: [tenant]" \
     "https://[host]/api/model/customer?search=[\"AND\",
        [\"OR\",[\"firstName\",\"=\",\"Pedro\"],[\"firstName\",\"=\",\"Juan\"],[\"firstName\",\"=\",\"María\"]],
        [\"createdAt\",\"<\",\"2023-01-01T00:00:00Z\"]
     ]"

Important notes:

  1. I've added an "AND" operator to combine both conditions
  2. The date "2023-01-01T00:00:00Z" represents the beginning of last year
  3. The "<" operator means "less than" (before)
  4. The "createdAt" field is typically used for creation date
  5. The URL should be properly encoded in a real situation
  6. You'll need to replace [apiKey], [tenant] and [host] with your actual credentials

If you prefer to use the "name" field instead of "firstName" to search in the full name:

curl -H "key: [apiKey]" \
     -H "tenant: [tenant]" \
     "https://[host]/api/model/customer?search=[\"AND\",
        [\"OR\",[\"name\",\"=\",\"Pedro\"],[\"name\",\"=\",\"Juan\"],[\"name\",\"=\",\"María\"]],
        [\"createdAt\",\"<\",\"2023-01-01T00:00:00Z\"]
     ]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment