Skip to main content

SDK Python para integrar aplicaciones externas con UTILIA OS

Project description

UTILIA OS SDK para Python

SDK Python para integrar aplicaciones externas con el sistema de soporte de UTILIA OS.

Instalacion

pip install utilia-sdk

Uso rapido

Asincrono (recomendado)

from utilia_sdk import UtiliaSDK, CreateTicketInput, CreateTicketUser, IdentifyUserInput

async with UtiliaSDK(base_url="https://os.utilia.ai/api", api_key="tu-api-key") as sdk:
    # Identificar usuario
    user = await sdk.users.identify(
        IdentifyUserInput(external_id="user-123", email="user@example.com")
    )

    # Crear ticket
    ticket = await sdk.tickets.create(
        CreateTicketInput(
            user=CreateTicketUser(external_id="user-123"),
            title="Problema con facturacion",
            description="No puedo ver mis facturas del mes pasado...",
        )
    )
    print(ticket.ticket_key)  # APP-0001

Sincrono

from utilia_sdk import UtiliaSDKSync, CreateTicketInput, CreateTicketUser

with UtiliaSDKSync(base_url="https://os.utilia.ai/api", api_key="tu-api-key") as sdk:
    ticket = sdk.tickets.create(
        CreateTicketInput(
            user=CreateTicketUser(external_id="user-123"),
            title="Problema con facturacion",
            description="No puedo ver mis facturas del mes pasado...",
        )
    )

Servicios disponibles

  • sdk.tickets - Tickets de soporte (crear, listar, mensajes, cerrar, reabrir)
  • sdk.users - Usuarios externos (identificar, listar)
  • sdk.files - Archivos adjuntos (subir, obtener URL, quota)
  • sdk.ai - IA (sugerencias, transcripcion)
  • sdk.errors - Errores del sistema (reportar, listar, estadisticas)

Actualizaciones en tiempo real (SSE)

Recibe notificaciones cuando un agente responde, cambia el estado, resuelve o cierra un ticket:

Asincrono

async with UtiliaSDK(base_url="https://os.utilia.ai/api", api_key="tu-api-key") as sdk:
    async for event in sdk.tickets.stream_updates(user_id="user-123"):
        print(f"Ticket {event['ticketKey']} actualizado: {event['type']}")
        # event['type']: 'comment-added' | 'status-changed'

Sincrono

with UtiliaSDKSync(base_url="https://os.utilia.ai/api", api_key="tu-api-key") as sdk:
    for event in sdk.tickets.stream_updates(user_id="user-123"):
        print(f"Ticket {event['ticketKey']} actualizado: {event['type']}")

Reportar errores del sistema

import traceback
from utilia_sdk import UtiliaSDK, ReportErrorInput

async with UtiliaSDK(base_url="https://os.utilia.ai/api", api_key="tu-api-key") as sdk:
    try:
        await procesar_pago(orden)
    except Exception as e:
        result = await sdk.errors.report(ReportErrorInput(
            message=str(e),
            module="pagos",
            severity="critical",
            stack=traceback.format_exc(),
            endpoint="/api/payments",
            method="POST",
        ))
        print(result.hash)         # Hash de deduplicacion
        print(result.deduplicated) # True si ya existia

Manejo de errores

from utilia_sdk import UtiliaSDKError, ErrorCode

try:
    ticket = await sdk.tickets.create(data)
except UtiliaSDKError as e:
    if e.is_unauthorized:
        print("API Key invalida")
    elif e.is_rate_limited:
        print("Demasiadas peticiones")
    elif e.is_retryable:
        print("Error temporal, reintentar")
    else:
        print(f"Error: {e.code} - {e.message}")

Licencia

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

utilia_sdk-0.4.0.tar.gz (33.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

utilia_sdk-0.4.0-py3-none-any.whl (32.2 kB view details)

Uploaded Python 3

File details

Details for the file utilia_sdk-0.4.0.tar.gz.

File metadata

  • Download URL: utilia_sdk-0.4.0.tar.gz
  • Upload date:
  • Size: 33.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for utilia_sdk-0.4.0.tar.gz
Algorithm Hash digest
SHA256 6995ef18182d6df9679232eb38f46f849fab605ac19f0050cb08626d0c756528
MD5 81fc40081b0a7c02933a5e03118d8180
BLAKE2b-256 704344b848376dfcc64103c13df4e1e178343387749475d951d4bb160e14fc2c

See more details on using hashes here.

File details

Details for the file utilia_sdk-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: utilia_sdk-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 32.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for utilia_sdk-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f471637df8e360f030cb554e66c4cf0cd3d505dd99d6f0c36bee0183cb327ac4
MD5 052cdac358999329807aeffb550efb51
BLAKE2b-256 acbf7ae5ddc12ffdf6cb675fbbe3adaf0a2b714ae5070e1ebfb7eec639057283

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page