{ "name": "🔗 Krayin CRM → Slack | Notificações de Leads", "nodes": [ { "parameters": { "httpMethod": "POST", "path": "krayin-webhook", "responseMode": "responseNode", "options": {} }, "id": "webhook-krayin", "name": "Webhook Krayin", "type": "n8n-nodes-base.webhook", "typeVersion": 1, "position": [240, 300], "webhookId": "krayin-leads-webhook" }, { "parameters": { "conditions": { "string": [ { "value1": "={{$node[\"Webhook Krayin\"].json[\"event_type\"]}}", "operation": "equal", "value2": "lead_created" } ] } }, "id": "filter-lead-created", "name": "Filtro: Novo Lead", "type": "n8n-nodes-base.if", "typeVersion": 1, "position": [460, 300] }, { "parameters": { "jsCode": "// Processar dados do lead do Krayin\nconst leadData = $node[\"Webhook Krayin\"].json;\n\n// Extrair informações principais\nconst lead = {\n id: leadData.lead?.id || 'N/A',\n name: leadData.lead?.person?.name || 'Nome não informado',\n email: leadData.lead?.person?.emails?.[0]?.value || 'Email não informado',\n phone: leadData.lead?.person?.phone || leadData.lead?.person?.contact_numbers?.[0]?.value || 'Telefone não informado',\n company: leadData.lead?.person?.organization?.name || 'Empresa não informada',\n source: leadData.lead?.source?.name || 'Fonte não identificada',\n value: leadData.lead?.lead_value || 0,\n currency: leadData.lead?.currency || 'BRL',\n stage: leadData.lead?.stage?.name || 'Inicial',\n created_at: leadData.lead?.created_at || new Date().toISOString(),\n assigned_to: leadData.lead?.user?.name || 'Não atribuído',\n notes: leadData.lead?.description || 'Sem observações'\n};\n\n// Formatação monetária\nconst formatCurrency = (value, currency) => {\n if (!value || value === 0) return 'Valor não informado';\n return new Intl.NumberFormat('pt-BR', {\n style: 'currency',\n currency: currency\n }).format(value);\n};\n\n// Emoji baseado no valor do lead\nconst getValueEmoji = (value) => {\n if (value >= 10000) return '🔥💰'; // Lead alto valor\n if (value >= 5000) return '⭐💵'; // Lead médio valor\n if (value > 0) return '💡💰'; // Lead com valor\n return '📝✨'; // Lead sem valor definido\n};\n\n// Determinar cor da notificação baseada no valor\nconst getNotificationColor = (value) => {\n if (value >= 10000) return '#FF0000'; // Vermelho para alto valor\n if (value >= 5000) return '#FFA500'; // Laranja para médio valor\n if (value > 0) return '#00AA00'; // Verde para com valor\n return '#5B49A0'; // Roxo MeMude para sem valor\n};\n\n// URL do lead no Krayin (ajustar conforme sua instalação)\nconst leadUrl = `https://crm.memudecore.com.br/admin/leads/view/${lead.id}`;\n\n// Formatação de timestamp\nconst formatDate = (dateString) => {\n const date = new Date(dateString);\n return date.toLocaleString('pt-BR', {\n timeZone: 'America/Sao_Paulo',\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit'\n });\n};\n\nreturn {\n leadData: lead,\n formattedValue: formatCurrency(lead.value, lead.currency),\n valueEmoji: getValueEmoji(lead.value),\n notificationColor: getNotificationColor(lead.value),\n leadUrl: leadUrl,\n formattedDate: formatDate(lead.created_at),\n urgencyLevel: lead.value >= 10000 ? 'ALTA' : lead.value >= 5000 ? 'MÉDIA' : 'NORMAL'\n};" }, "id": "process-lead-data", "name": "Processar Dados Lead", "type": "n8n-nodes-base.code", "typeVersion": 1, "position": [680, 300] }, { "parameters": { "channel": "#vendas", "text": "🎯 **NOVO LEAD RECEBIDO** {{$node[\"Processar Dados Lead\"].json[\"valueEmoji\"]}}", "attachments": [ { "color": "{{$node[\"Processar Dados Lead\"].json[\"notificationColor\"]}}", "fields": [ { "title": "👤 Cliente", "value": "{{$node[\"Processar Dados Lead\"].json[\"leadData\"][\"name\"]}}", "short": true }, { "title": "📧 Email", "value": "{{$node[\"Processar Dados Lead\"].json[\"leadData\"][\"email\"]}}", "short": true }, { "title": "📱 Telefone", "value": "{{$node[\"Processar Dados Lead\"].json[\"leadData\"][\"phone\"]}}", "short": true }, { "title": "🏢 Empresa", "value": "{{$node[\"Processar Dados Lead\"].json[\"leadData\"][\"company\"]}}", "short": true }, { "title": "💰 Valor Estimado", "value": "{{$node[\"Processar Dados Lead\"].json[\"formattedValue\"]}}", "short": true }, { "title": "📊 Estágio", "value": "{{$node[\"Processar Dados Lead\"].json[\"leadData\"][\"stage\"]}}", "short": true }, { "title": "🎯 Fonte", "value": "{{$node[\"Processar Dados Lead\"].json[\"leadData\"][\"source\"]}}", "short": true }, { "title": "👨‍💼 Responsável", "value": "{{$node[\"Processar Dados Lead\"].json[\"leadData\"][\"assigned_to\"]}}", "short": true }, { "title": "📅 Recebido", "value": "{{$node[\"Processar Dados Lead\"].json[\"formattedDate\"]}}", "short": false }, { "title": "📝 Observações", "value": "{{$node[\"Processar Dados Lead\"].json[\"leadData\"][\"notes\"]}}", "short": false } ], "actions": [ { "type": "button", "text": "🔗 Ver no CRM", "url": "{{$node[\"Processar Dados Lead\"].json[\"leadUrl\"]}}" } ], "footer": "MeMude Core CRM | Urgência: {{$node[\"Processar Dados Lead\"].json[\"urgencyLevel\"]}}", "ts": "{{Math.floor(Date.now() / 1000)}}" } ], "otherOptions": { "username": "Krayin CRM Bot", "icon_emoji": ":rocket:" } }, "id": "slack-notification", "name": "Notificação Slack", "type": "n8n-nodes-base.slack", "typeVersion": 1, "position": [900, 300], "credentials": { "slackApi": { "id": "slack-memude-workspace", "name": "Slack MeMude Workspace" } } }, { "parameters": { "conditions": { "number": [ { "value1": "={{$node[\"Processar Dados Lead\"].json[\"leadData\"][\"value\"]}}", "operation": "largerEqual", "value2": 10000 } ] } }, "id": "check-high-value", "name": "Lead Alto Valor?", "type": "n8n-nodes-base.if", "typeVersion": 1, "position": [680, 480] }, { "parameters": { "channel": "#vendas-urgente", "text": "🚨 **LEAD ALTO VALOR DETECTADO** 🔥💰", "attachments": [ { "color": "#FF0000", "title": "⚡ AÇÃO IMEDIATA NECESSÁRIA", "text": "Lead de **{{$node[\"Processar Dados Lead\"].json[\"formattedValue\"]}}** recebido de **{{$node[\"Processar Dados Lead\"].json[\"leadData\"][\"name\"]}}**", "fields": [ { "title": "📱 Contato Imediato", "value": "{{$node[\"Processar Dados Lead\"].json[\"leadData\"][\"phone\"]}}", "short": false } ], "actions": [ { "type": "button", "text": "🚀 ATENDER AGORA", "url": "{{$node[\"Processar Dados Lead\"].json[\"leadUrl\"]}}", "style": "danger" } ] } ], "otherOptions": { "username": "🚨 ALERTA CRM", "icon_emoji": ":warning:" } }, "id": "urgent-notification", "name": "Notificação Urgente", "type": "n8n-nodes-base.slack", "typeVersion": 1, "position": [900, 480], "credentials": { "slackApi": { "id": "slack-memude-workspace", "name": "Slack MeMude Workspace" } } }, { "parameters": { "respondWith": "json", "responseBody": "{\n \"status\": \"success\",\n \"message\": \"Lead processado e notificação enviada\",\n \"lead_id\": \"{{$node[\"Processar Dados Lead\"].json[\"leadData\"][\"id\"]}}\",\n \"timestamp\": \"{{new Date().toISOString()}}\"\n}" }, "id": "webhook-response", "name": "Resposta Webhook", "type": "n8n-nodes-base.respondToWebhook", "typeVersion": 1, "position": [1120, 300] } ], "connections": { "Webhook Krayin": { "main": [ [ { "node": "Filtro: Novo Lead", "type": "main", "index": 0 } ] ] }, "Filtro: Novo Lead": { "main": [ [ { "node": "Processar Dados Lead", "type": "main", "index": 0 } ] ] }, "Processar Dados Lead": { "main": [ [ { "node": "Notificação Slack", "type": "main", "index": 0 }, { "node": "Lead Alto Valor?", "type": "main", "index": 0 } ] ] }, "Notificação Slack": { "main": [ [ { "node": "Resposta Webhook", "type": "main", "index": 0 } ] ] }, "Lead Alto Valor?": { "main": [ [ { "node": "Notificação Urgente", "type": "main", "index": 0 } ] ] }, "Notificação Urgente": { "main": [ [ { "node": "Resposta Webhook", "type": "main", "index": 0 } ] ] } }, "active": true, "settings": { "timezone": "America/Sao_Paulo" }, "createdAt": "2026-01-21T19:00:00.000Z", "updatedAt": "2026-01-21T19:00:00.000Z", "id": "krayin-slack-integration", "tags": [ { "id": "crm", "name": "CRM" }, { "id": "notifications", "name": "Notificações" }, { "id": "sales", "name": "Vendas" } ] }