new_ticket.json 3.4 KB

123456789
  1. {
  2. "name": "new_ticket",
  3. "description": "CRITICAL: conversationId is ALWAYS taken automatically from the Chatwoot session — NEVER ask the user for it, NEVER use the order number or any user-provided number as the conversation ID. The conversation ID is an internal system value that the customer has no access to.\n\nIMPORTANT: Always reply to the customer in their own language — the exact language they write in. Never switch to Polish unless the customer writes in Polish.\n\nIMPORTANT: Before creating a ticket for an order-related complaint, call get_order_data first to verify that the customer's email matches the order. Only create a ticket after order ownership is confirmed, or when the customer explicitly requests human support for a non-order issue.\n\nUtwórz ticket supportowy i przekieruj rozmowę do obsługi sklepu. Używaj gdy:\n- klient wyraźnie prosi o kontakt z człowiekiem\n- nie jesteś w stanie rozwiązać problemu samodzielnie\n- baza wiedzy wskazuje że sprawa wymaga kontaktu z supportem\n- minęło dużo czasu od realizacji zamówienia, a paczka nie dotarła\n\nWAŻNE: gdy get_order_data zwróci '[ORDER EMAIL MISMATCH]' — NIE zakładaj od razu ticketu i NIE sugeruj że numer zamówienia jest zły. Zapytaj klienta (w jego języku) o adres email użyty przy składaniu zamówienia. Następnie wywołaj get_order_data ponownie z tym emailem i tym samym numerem zamówienia. Ticket zakładaj dopiero gdy tożsamość klienta zostanie zweryfikowana.\n\nZa każdym razem gdy tworzysz ticket, poinformuj klienta i poproś o cierpliwość — osoba z obsługi skontaktuje się w najbliższym czasie. Przekaż klientowi numer otrzymanego zgłoszenia.",
  4. "color": "linear-gradient(rgb(148,32,101), rgb(120,188,81))",
  5. "iconSrc": "",
  6. "schema": "[{\"id\":0,\"property\":\"summary\",\"description\":\"Krótkie podsumowanie problemu klienta\",\"type\":\"string\",\"required\":false}]",
  7. "func": "const fetch = require('node-fetch')\n\nconst base = String(($vars && ($vars.relay_base || $vars.webhook_base)) || 'http://localhost:8080').replace(/\\/$/,'')\nconst secret = String(($vars && $vars.relay_shared_secret) || '')\n\n// CRITICAL: conversationId MUST always come from the Flowise session (chatwoot:<id>).\n// The LLM-provided conversationId parameter is intentionally removed from the schema\n// to prevent the LLM from confusing the order number with the conversation ID.\nconst conversationId = Number(($flow && $flow.sessionId || '').replace('chatwoot:',''))\nconst summary = typeof $summary !== 'undefined' ? String($summary) : ''\n\nif (!conversationId || conversationId <= 0) return 'Error: could not determine Chatwoot conversation ID from session. This is a system error — do not ask the customer for a conversation ID.'\nif (!secret) return 'Error: missing $vars.relay_shared_secret'\n\ntry {\n const res = await fetch(`${base}/tools/new_ticket`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${secret}`\n },\n body: JSON.stringify({ conversationId, summary })\n })\n const data = await res.json()\n if (data.ok) {\n return `Ticket created: ${data.ticketNumber} (status: ${data.status})`\n }\n return `Error creating ticket: ${data.message || JSON.stringify(data)}`\n} catch (error) {\n return `Connection error: ${error?.message || String(error)}`\n}\n",
  8. "workspaceId": "048a397e-3529-48c7-9f65-ae59eb7bd783"
  9. }