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.6.0.tar.gz (41.4 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.6.0-py3-none-any.whl (41.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: utilia_sdk-0.6.0.tar.gz
  • Upload date:
  • Size: 41.4 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.6.0.tar.gz
Algorithm Hash digest
SHA256 c3aa915331f3be50e42480f2c44522bd225e2218d1af3772a14fa690cebbc39a
MD5 9925a4a3e9908df894229803e76f3476
BLAKE2b-256 43f5b36bac737db78ddb97f4fa3274707052824c7303db15f9d92fe4422cc319

See more details on using hashes here.

File details

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

File metadata

  • Download URL: utilia_sdk-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 41.8 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.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c576980894ed274def3a545f821141f2f24b39631f60fd5be845e62b3307f88
MD5 ca8751afc17c8c1c3272bc460038a3ba
BLAKE2b-256 861ea5b4b5e226a9e460f14511d40b4caf91772505e2e3c20483eb59180c315d

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