Skip to content

src/api.js - Client API verso il Sito

Axios client per comunicare con il Sito CRM (.154)

A cosa serve

  • syncMessage(data) - Invia messaggi al DB del sito
  • resolveContact(phone) - Identity Mapping: phone -> display_name
  • upsertContact(phone, pushname) - Aggiorna pushname nel DB
  • checkContact(phone) - Cerca contatto nel CRM
  • getProducts(query) - Cerca prodotti
  • createLead/createQuote/createTicket - Crea entita CRM
  • Cache in-memory 5 minuti per resolveContact

Chi lo chiama

  • index.js per identity mapping e sync messaggi
  • agents/*.js per operazioni CRM
  • watchdog.js per classificazione chat

Cosa NON toccare

  • Il BOT_SERVICE_TOKEN in .env (non hardcodare)
  • La cache identityCache con TTL 5 minuti
  • Gli interceptor axios per logging