Skip to content

Outbound — Agente responde desde Chatwoot

Caso: Juan trabaja hoy desde Chatwoot (prefiere la interfaz de conversaciones) y responde "Tu servicio ya está activo".

Secuencia

Loop prevention crítico

Sin el filtro source, este ciclo sería infinito:

  1. Chatwoot → CRM (webhook) → Kafka → gateway → Meta ✓
  2. Gateway → Kafka mirror → integration-api → Chatwoot (de nuevo) ❌

Dos candados previenen el loop:

En el gateway (outbound.go::ProcessJob):

go
if job.Source != "support_bridge" && conv.ChatwootConversationID != 0 {
    kafka.Produce("whatsapp-crm-outbound-mirror", evt)
}

En el CRM bridge (whatsapp_webhook_handler.go::ChatwootBridge):

go
if attrs["source"] == "crm_mirror" || attrs["source"] == "ai_response_mirror" {
    return 200 // echo nuestro, ignorar
}

Identidad

El payload de Chatwoot trae sender.type:

  • User → agente humano → sender_type="chatwoot_agent", sender_name=<nombre>.
  • AgentBot → si el sender.id == CHATWOOT_AI_BOT_ID → el CRM sabe que es IA pero normalmente la IA viene por su flujo propio (Outbound IA), no por este webhook.

Siguiente: IA auto-responde.

Impulse Tech · Documentación interna