Saltar al contenido
Verificada

Abrir un ticket de soporte

Crea un ticket en el servicio de tu plan desde código externo y consúltalo hasta que alguien responda.

ticket_api_submit abre un ticket en el servicio que posee el plan de tu clave de API, el mismo servicio que gestiona la pantalla Ticketing del dashboard. ticket_api_get lo vuelve a leer, incluidas las respuestas públicas, todo lo que necesitas para montar un formulario de "contacto" respaldado por un servicio real en lugar de un buzón.

Métodos

POST/cpi/ticket_api_submit
user

API: Submit Ticket

External service: opens a ticket on the desk owned by the API key. Requires a plan with full API access.

POST/cpi/ticket_api_get
user

API: Get Ticket

External service: one ticket with its public interactions. Internal notes are never returned.

Paso a paso

Envía el ticket

name, email y details son obligatorios. El correo hace además de búsqueda en la agenda de contactos: volver a enviar desde la misma dirección enlaza con el mismo contacto, igual que añadir un contacto.

curl -s https://xuda.ai/cpi/ticket_api_submit \
  -H 'content-type: application/json' \
  -d '{
    "api_key": "YOUR_API_KEY",
    "name": "Priya Shah",
    "email": "[email protected]",
    "subject": "Cannot export invoices",
    "details": "The export button on the invoices page does nothing.",
    "priority": 2
  }'
const res = await fetch('https://xuda.ai/cpi/ticket_api_submit', {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({
    api_key: 'YOUR_API_KEY',
    name: 'Priya Shah',
    email: '[email protected]',
    subject: 'Cannot export invoices',
    details: 'The export button on the invoices page does nothing.',
    priority: 2,
  }),
});
const { code, data } = await res.json();
if (code > 0) console.log(data.ticket_no, data.id);
import requests

res = requests.post(
    'https://xuda.ai/cpi/ticket_api_submit',
    json={
        'api_key': 'YOUR_API_KEY',
        'name': 'Priya Shah',
        'email': '[email protected]',
        'subject': 'Cannot export invoices',
        'details': 'The export button on the invoices page does nothing.',
        'priority': 2,
    },
)
body = res.json()
if body['code'] > 0:
    print(body['data']['ticket_no'], body['data']['id'])

2. Consúltalo hasta que haya respuesta

Guarda data.id de la llamada de envío y vuelve a leerlo con ticket_api_get cuando quieras comprobar si hay novedades; interactions solo lleva el hilo público, las notas internas del servicio se filtran antes de que este método responda.

curl -s https://xuda.ai/cpi/ticket_api_get \
  -H 'content-type: application/json' \
  -d '{"api_key":"YOUR_API_KEY","ticket_id":"tkt_3b7a10982341"}'
const res = await fetch('https://xuda.ai/cpi/ticket_api_get', {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({ api_key: 'YOUR_API_KEY', ticket_id: 'tkt_3b7a10982341' }),
});
const { code, data } = await res.json();
if (code > 0) console.log(data.status, data.interactions.length);
import requests

res = requests.post(
    'https://xuda.ai/cpi/ticket_api_get',
    json={'api_key': 'YOUR_API_KEY', 'ticket_id': 'tkt_3b7a10982341'},
)
body = res.json()
if body['code'] > 0:
    print(body['data']['status'], len(body['data']['interactions']))

La respuesta

Ambos métodos responden con la misma vista de ticket acotada y segura para uso externo, sin ids de propietario ni estado interno:

json
{
  "code": 1,
  "data": {
    "ticket_no": "TK-1042",
    "id": "tkt_3b7a10982341",
    "source": "api",
    "channel": "api",
    "status": "open",
    "status_stage": "new",
    "subject": "Cannot export invoices",
    "details": "The export button on the invoices page does nothing.",
    "topic": null,
    "subtopic": null,
    "requester": {
      "name": "Priya Shah",
      "email": "[email protected]",
      "phone": "",
      "company": ""
    },
    "reference_id": null,
    "priority": 2,
    "due_ts": null,
    "date_created_ts": 1737042311422,
    "last_activity_ts": 1737042311422,
    "status_ts": 1737042311422
  }
}

ticket_api_get añade una clave más, interactions, un array de { direction, from, channel, body, ts } en orden de hilo, vacío hasta que alguien del servicio (o el solicitante, por otro canal) responda.

Errores

Siguiente