1) The visitor writes their last message («thanks, it is sorted now») and your server receives mensaje-recibido. It replies with the survey and its reference:
Careful: the survey has to be launched from a mensaje-recibido. On mensaje-enviado your reply is not applied (see the events table), so it cannot be used to react to the agent closing the chat; for that there is the close with survey button in the panel, which sends it on its own.
{
"responder": "Please rate how we did<br/>[😍|5][🙂|4][😐|3][🙁|2][😞|1]",
"ref": "12345AB"
}
2) The visitor presses the first smiley and your server receives the encuesta-cierre event with your reference, the value pressed and the visitor's details:
{
"Evento": "encuesta", "idConversacion": 88, "idMensaje": 1420,
"Canal": "web", "Valor": "5", "Nota": 5,
"Ref": "12345AB", "idAgente": 7, "Fecha": "2026-08-01 12:40:11",
"Visitante": {
"idVisitante": 12, "Nombre": "Ana", "Email": "ana@customer.com", "Telefono": "",
"IP": "10.0.20.100", "UserAgent": "Mozilla/5.0...",
"Url": "https://yourshop.com/cart", "Idioma": "es", "Zona": "Europe/Madrid",
"Pais": "Spain", "Ciudad": "Madrid", "Operadora": "Movistar",
"Vars": { "order": "8812" },
"idSitio": 3, "Canal": "web", "RefCanal": ""
}
}
3) Your server can still answer something to that click and close:
{ "responder": "Thanks for your feedback!", "cerrar": true }