@lionchat/mcp-server 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,362 @@
1
+ # FlowBuilder — Templates Prontos
2
+
3
+ 10 padrões testados para você adaptar em vez de criar do zero. Cada um já vem com layout válido, handles certos e campos no formato esperado. **Copie o `flow_data`, ajuste só o que o cliente pediu, e chame `flows_create`.**
4
+
5
+ ---
6
+
7
+ ## 1. Boas-vindas com triagem
8
+
9
+ **Caso:** lead nova chega no WhatsApp, oferece menu (vendas/suporte/financeiro), atribui ao time certo.
10
+
11
+ ```json
12
+ {
13
+ "nodes": [
14
+ { "id": "n1", "type": "start", "position": { "x": 50, "y": 300 }, "data": { "label": "Início", "triggers": [{ "type": "conversation_created" }] } },
15
+ { "id": "n2", "type": "send_message", "position": { "x": 370, "y": 300 }, "data": { "label": "Saudação", "messageItems": [
16
+ { "id": "m1", "type": "text", "content": "Oi {{contact.name|default:'tudo bem?'}} 👋 Como posso ajudar hoje?\n\n1️⃣ Vendas\n2️⃣ Suporte\n3️⃣ Financeiro" }
17
+ ] } },
18
+ { "id": "n3", "type": "wait_response", "position": { "x": 690, "y": 300 }, "data": {
19
+ "label": "Aguarda escolha", "waitTime": 30, "waitUnit": "minutes", "validation": "options",
20
+ "acceptedOptions": ["1","2","3"], "invalidMessage": "Por favor responda 1, 2 ou 3", "maxRetries": 2, "saveTo": ""
21
+ } },
22
+ { "id": "n4", "type": "action", "position": { "x": 1010, "y": 120 }, "data": { "label": "→ Vendas", "items": [
23
+ { "key": "assign_team", "config": { "team_id": 1 } },
24
+ { "key": "add_label", "config": { "labels": ["vendas"] } }
25
+ ] } },
26
+ { "id": "n5", "type": "action", "position": { "x": 1010, "y": 300 }, "data": { "label": "→ Suporte", "items": [
27
+ { "key": "assign_team", "config": { "team_id": 2 } },
28
+ { "key": "add_label", "config": { "labels": ["suporte"] } }
29
+ ] } },
30
+ { "id": "n6", "type": "action", "position": { "x": 1010, "y": 480 }, "data": { "label": "→ Financeiro", "items": [
31
+ { "key": "assign_team", "config": { "team_id": 3 } },
32
+ { "key": "add_label", "config": { "labels": ["financeiro"] } }
33
+ ] } },
34
+ { "id": "n7", "type": "send_message", "position": { "x": 1330, "y": 660 }, "data": { "label": "Timeout msg", "messageItems": [
35
+ { "id": "m2", "type": "text", "content": "Não recebi sua resposta. Vou encaminhar pra equipe geral." }
36
+ ] } }
37
+ ],
38
+ "edges": [
39
+ { "id": "e1", "source": "n1", "target": "n2", "sourceHandle": "success", "type": "deletable", "animated": true },
40
+ { "id": "e2", "source": "n2", "target": "n3", "sourceHandle": "success", "type": "deletable", "animated": true },
41
+ { "id": "e3", "source": "n3", "target": "n4", "sourceHandle": "option_1", "type": "deletable", "animated": true },
42
+ { "id": "e4", "source": "n3", "target": "n5", "sourceHandle": "option_2", "type": "deletable", "animated": true },
43
+ { "id": "e5", "source": "n3", "target": "n6", "sourceHandle": "option_3", "type": "deletable", "animated": true },
44
+ { "id": "e6", "source": "n3", "target": "n7", "sourceHandle": "timeout", "type": "deletable", "animated": true }
45
+ ]
46
+ }
47
+ ```
48
+
49
+ ---
50
+
51
+ ## 2. Captura de lead simples
52
+
53
+ **Caso:** pega nome + email + interesse, cria card no funil "Novos Leads".
54
+
55
+ ```json
56
+ {
57
+ "nodes": [
58
+ { "id": "n1", "type": "start", "position": { "x": 50, "y": 300 }, "data": { "label": "Início", "triggers": [{ "type": "conversation_created" }] } },
59
+ { "id": "n2", "type": "send_message", "position": { "x": 370, "y": 300 }, "data": { "label": "Pede nome", "messageItems": [
60
+ { "id": "m1", "type": "text", "content": "Olá! Antes de continuar, qual seu nome completo?" }
61
+ ] } },
62
+ { "id": "n3", "type": "wait_response", "position": { "x": 690, "y": 300 }, "data": {
63
+ "label": "Aguarda nome", "waitTime": 15, "waitUnit": "minutes", "validation": "any",
64
+ "saveTo": "contact_attribute", "saveAttrKey": "nome_completo"
65
+ } },
66
+ { "id": "n4", "type": "send_message", "position": { "x": 1010, "y": 300 }, "data": { "label": "Pede email", "messageItems": [
67
+ { "id": "m2", "type": "text", "content": "Perfeito, {{contact.custom_attributes.nome_completo}}. Qual seu melhor email?" }
68
+ ] } },
69
+ { "id": "n5", "type": "wait_response", "position": { "x": 1330, "y": 300 }, "data": {
70
+ "label": "Aguarda email", "waitTime": 15, "waitUnit": "minutes", "validation": "regex",
71
+ "regexPattern": "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$", "invalidMessage": "Esse não parece um email válido. Tenta de novo?", "maxRetries": 2,
72
+ "saveTo": "contact_attribute", "saveAttrKey": "email"
73
+ } },
74
+ { "id": "n6", "type": "action", "position": { "x": 1650, "y": 300 }, "data": { "label": "Cria card", "items": [
75
+ { "key": "create_kanban_item", "config": { "funnel_id": 1, "funnel_stage": "novo_lead" } },
76
+ { "key": "add_label", "config": { "labels": ["lead-capturado"] } }
77
+ ] } },
78
+ { "id": "n7", "type": "send_message", "position": { "x": 1970, "y": 300 }, "data": { "label": "Confirma", "messageItems": [
79
+ { "id": "m3", "type": "text", "content": "Tudo certo! Em breve um consultor vai te chamar." }
80
+ ] } }
81
+ ],
82
+ "edges": [
83
+ { "id": "e1", "source": "n1", "target": "n2", "sourceHandle": "success", "type": "deletable", "animated": true },
84
+ { "id": "e2", "source": "n2", "target": "n3", "sourceHandle": "success", "type": "deletable", "animated": true },
85
+ { "id": "e3", "source": "n3", "target": "n4", "sourceHandle": "success", "type": "deletable", "animated": true },
86
+ { "id": "e4", "source": "n4", "target": "n5", "sourceHandle": "success", "type": "deletable", "animated": true },
87
+ { "id": "e5", "source": "n5", "target": "n6", "sourceHandle": "success", "type": "deletable", "animated": true },
88
+ { "id": "e6", "source": "n6", "target": "n7", "sourceHandle": "success", "type": "deletable", "animated": true }
89
+ ]
90
+ }
91
+ ```
92
+
93
+ ---
94
+
95
+ ## 3. Qualificação BANT (Budget / Authority / Need / Timing)
96
+
97
+ **Caso:** 4 perguntas pra qualificar lead B2B. Ramifica em "quente" vs "frio".
98
+
99
+ ```json
100
+ {
101
+ "nodes": [
102
+ { "id": "n1", "type": "start", "position": { "x": 50, "y": 300 }, "data": { "label": "Início", "triggers": [{ "type": "message_received", "keywords": ["proposta","orçamento"], "match_mode": "contains" }] } },
103
+ { "id": "n2", "type": "send_message", "position": { "x": 370, "y": 300 }, "data": { "label": "B - Budget", "messageItems": [{ "id": "m1", "type": "text", "content": "Pra te ajudar melhor, qual a faixa de investimento que vocês têm em mente?\n\n1️⃣ Até R$ 5k\n2️⃣ R$ 5k a R$ 20k\n3️⃣ Acima de R$ 20k" }] } },
104
+ { "id": "n3", "type": "wait_response", "position": { "x": 690, "y": 300 }, "data": { "label": "Budget", "waitTime": 60, "waitUnit": "minutes", "validation": "options", "acceptedOptions": ["1","2","3"], "saveTo": "contact_attribute", "saveAttrKey": "budget_tier" } },
105
+ { "id": "n4", "type": "send_message", "position": { "x": 1010, "y": 300 }, "data": { "label": "A - Authority", "messageItems": [{ "id": "m2", "type": "text", "content": "Você é o decisor ou tem outras pessoas envolvidas?" }] } },
106
+ { "id": "n5", "type": "wait_response", "position": { "x": 1330, "y": 300 }, "data": { "label": "Autoridade", "waitTime": 60, "waitUnit": "minutes", "validation": "any", "saveTo": "contact_attribute", "saveAttrKey": "authority" } },
107
+ { "id": "n6", "type": "send_message", "position": { "x": 1650, "y": 300 }, "data": { "label": "N - Need", "messageItems": [{ "id": "m3", "type": "text", "content": "Conta um pouco: o que vocês precisam resolver hoje?" }] } },
108
+ { "id": "n7", "type": "wait_response", "position": { "x": 1970, "y": 300 }, "data": { "label": "Necessidade", "waitTime": 60, "waitUnit": "minutes", "validation": "any", "saveTo": "contact_attribute", "saveAttrKey": "need" } },
109
+ { "id": "n8", "type": "send_message", "position": { "x": 2290, "y": 300 }, "data": { "label": "T - Timing", "messageItems": [{ "id": "m4", "type": "text", "content": "Em quanto tempo precisam ter a solução rodando?\n\n1️⃣ Esse mês\n2️⃣ Próximos 3 meses\n3️⃣ Sem pressa" }] } },
110
+ { "id": "n9", "type": "wait_response", "position": { "x": 2610, "y": 300 }, "data": { "label": "Prazo", "waitTime": 60, "waitUnit": "minutes", "validation": "options", "acceptedOptions": ["1","2","3"], "saveTo": "contact_attribute", "saveAttrKey": "timing_tier" } },
111
+ { "id": "n10", "type": "condition", "position": { "x": 2930, "y": 300 }, "data": { "label": "Quente?", "conditions": [
112
+ { "id": "c1", "label": "Lead quente", "field": "contact.custom_attributes.budget_tier", "operator": "not_equal", "value": "1" }
113
+ ] } },
114
+ { "id": "n11", "type": "action", "position": { "x": 3250, "y": 180 }, "data": { "label": "Quente", "items": [
115
+ { "key": "assign_team", "config": { "team_id": 1 } },
116
+ { "key": "add_label", "config": { "labels": ["lead-quente"] } },
117
+ { "key": "create_kanban_item", "config": { "funnel_id": 1, "funnel_stage": "qualificado" } }
118
+ ] } },
119
+ { "id": "n12", "type": "action", "position": { "x": 3250, "y": 420 }, "data": { "label": "Frio", "items": [
120
+ { "key": "add_label", "config": { "labels": ["lead-frio"] } },
121
+ { "key": "create_kanban_item", "config": { "funnel_id": 1, "funnel_stage": "nutrir" } }
122
+ ] } }
123
+ ],
124
+ "edges": [
125
+ { "id": "e1", "source": "n1", "target": "n2", "sourceHandle": "success", "type": "deletable", "animated": true },
126
+ { "id": "e2", "source": "n2", "target": "n3", "sourceHandle": "success", "type": "deletable", "animated": true },
127
+ { "id": "e3", "source": "n3", "target": "n4", "sourceHandle": "option_1", "type": "deletable", "animated": true },
128
+ { "id": "e4", "source": "n3", "target": "n4", "sourceHandle": "option_2", "type": "deletable", "animated": true },
129
+ { "id": "e5", "source": "n3", "target": "n4", "sourceHandle": "option_3", "type": "deletable", "animated": true },
130
+ { "id": "e6", "source": "n4", "target": "n5", "sourceHandle": "success", "type": "deletable", "animated": true },
131
+ { "id": "e7", "source": "n5", "target": "n6", "sourceHandle": "success", "type": "deletable", "animated": true },
132
+ { "id": "e8", "source": "n6", "target": "n7", "sourceHandle": "success", "type": "deletable", "animated": true },
133
+ { "id": "e9", "source": "n7", "target": "n8", "sourceHandle": "success", "type": "deletable", "animated": true },
134
+ { "id": "e10", "source": "n8", "target": "n9", "sourceHandle": "success", "type": "deletable", "animated": true },
135
+ { "id": "e11", "source": "n9", "target": "n10", "sourceHandle": "option_1", "type": "deletable", "animated": true },
136
+ { "id": "e12", "source": "n9", "target": "n10", "sourceHandle": "option_2", "type": "deletable", "animated": true },
137
+ { "id": "e13", "source": "n9", "target": "n10", "sourceHandle": "option_3", "type": "deletable", "animated": true },
138
+ { "id": "e14", "source": "n10", "target": "n11", "sourceHandle": "cond_0", "type": "deletable", "animated": true },
139
+ { "id": "e15", "source": "n10", "target": "n12", "sourceHandle": "default", "type": "deletable", "animated": true }
140
+ ]
141
+ }
142
+ ```
143
+
144
+ ---
145
+
146
+ ## 4. Pesquisa CSAT pós-atendimento
147
+
148
+ **Caso:** ao resolver conversa, pede nota de 1 a 5 e comentário.
149
+
150
+ ```json
151
+ {
152
+ "nodes": [
153
+ { "id": "n1", "type": "start", "position": { "x": 50, "y": 300 }, "data": { "label": "Início", "triggers": [{ "type": "conversation_resolved" }] } },
154
+ { "id": "n2", "type": "wait", "position": { "x": 370, "y": 300 }, "data": { "label": "Aguarda 5 min", "waitTime": 5, "waitUnit": "minutes" } },
155
+ { "id": "n3", "type": "send_message", "position": { "x": 690, "y": 300 }, "data": { "label": "Pede nota", "messageItems": [{ "id": "m1", "type": "text", "content": "Antes de fechar: de 1 a 5, como foi seu atendimento?\n\n5 = excelente\n1 = ruim" }] } },
156
+ { "id": "n4", "type": "wait_response", "position": { "x": 1010, "y": 300 }, "data": { "label": "Nota", "waitTime": 60, "waitUnit": "minutes", "validation": "options", "acceptedOptions": ["1","2","3","4","5"], "saveTo": "attribute", "saveAttrKey": "csat_score" } },
157
+ { "id": "n5", "type": "send_message", "position": { "x": 1330, "y": 300 }, "data": { "label": "Pede comentário", "messageItems": [{ "id": "m2", "type": "text", "content": "Obrigado pela nota! Quer deixar algum comentário?" }] } },
158
+ { "id": "n6", "type": "wait_response", "position": { "x": 1650, "y": 300 }, "data": { "label": "Comentário", "waitTime": 30, "waitUnit": "minutes", "validation": "any", "saveTo": "attribute", "saveAttrKey": "csat_comment" } },
159
+ { "id": "n7", "type": "send_message", "position": { "x": 1970, "y": 300 }, "data": { "label": "Encerra", "messageItems": [{ "id": "m3", "type": "text", "content": "Valeu pelo feedback! 🙏" }] } }
160
+ ],
161
+ "edges": [
162
+ { "id": "e1", "source": "n1", "target": "n2", "sourceHandle": "success", "type": "deletable", "animated": true },
163
+ { "id": "e2", "source": "n2", "target": "n3", "sourceHandle": "success", "type": "deletable", "animated": true },
164
+ { "id": "e3", "source": "n3", "target": "n4", "sourceHandle": "success", "type": "deletable", "animated": true },
165
+ { "id": "e4", "source": "n4", "target": "n5", "sourceHandle": "option_1", "type": "deletable", "animated": true },
166
+ { "id": "e5", "source": "n4", "target": "n5", "sourceHandle": "option_2", "type": "deletable", "animated": true },
167
+ { "id": "e6", "source": "n4", "target": "n5", "sourceHandle": "option_3", "type": "deletable", "animated": true },
168
+ { "id": "e7", "source": "n4", "target": "n5", "sourceHandle": "option_4", "type": "deletable", "animated": true },
169
+ { "id": "e8", "source": "n4", "target": "n5", "sourceHandle": "option_5", "type": "deletable", "animated": true },
170
+ { "id": "e9", "source": "n5", "target": "n6", "sourceHandle": "success", "type": "deletable", "animated": true },
171
+ { "id": "e10", "source": "n6", "target": "n7", "sourceHandle": "success", "type": "deletable", "animated": true }
172
+ ]
173
+ }
174
+ ```
175
+
176
+ ---
177
+
178
+ ## 5. Roteamento por horário comercial
179
+
180
+ **Caso:** se dentro do expediente, atribui agente. Se fora, manda ausência.
181
+
182
+ ```json
183
+ {
184
+ "nodes": [
185
+ { "id": "n1", "type": "start", "position": { "x": 50, "y": 300 }, "data": { "label": "Início", "triggers": [{ "type": "conversation_created" }] } },
186
+ { "id": "n2", "type": "condition", "position": { "x": 370, "y": 300 }, "data": { "label": "Horário comercial?", "conditions": [
187
+ { "id": "c1", "label": "Dentro do horário", "field": "now.hour", "operator": "greater_than", "value": "8" }
188
+ ] } },
189
+ { "id": "n3", "type": "action", "position": { "x": 690, "y": 180 }, "data": { "label": "Atribui agente", "items": [
190
+ { "key": "assign_team", "config": { "team_id": 1 } }
191
+ ] } },
192
+ { "id": "n4", "type": "send_message", "position": { "x": 690, "y": 420 }, "data": { "label": "Ausência", "messageItems": [
193
+ { "id": "m1", "type": "text", "content": "Recebemos sua mensagem! Nosso horário é das 9h às 18h, dias úteis. Retornamos assim que possível." }
194
+ ] } }
195
+ ],
196
+ "edges": [
197
+ { "id": "e1", "source": "n1", "target": "n2", "sourceHandle": "success", "type": "deletable", "animated": true },
198
+ { "id": "e2", "source": "n2", "target": "n3", "sourceHandle": "cond_0", "type": "deletable", "animated": true },
199
+ { "id": "e3", "source": "n2", "target": "n4", "sourceHandle": "default", "type": "deletable", "animated": true }
200
+ ]
201
+ }
202
+ ```
203
+
204
+ ---
205
+
206
+ ## 6. Triagem com IA (classificação de intenção)
207
+
208
+ **Caso:** usa IA pra ler a primeira mensagem e classificar como compra/suporte/reclamação/dúvida.
209
+
210
+ ```json
211
+ {
212
+ "nodes": [
213
+ { "id": "n1", "type": "start", "position": { "x": 50, "y": 300 }, "data": { "label": "Início", "triggers": [{ "type": "message_received" }] } },
214
+ { "id": "n2", "type": "ai", "position": { "x": 370, "y": 300 }, "data": {
215
+ "label": "Classifica", "aiMode": "intent",
216
+ "aiPrompt": "Classifique a intenção da última mensagem do cliente",
217
+ "aiIntentOptions": ["compra", "suporte", "reclamacao", "duvida"],
218
+ "aiResponseVar": "intent"
219
+ } },
220
+ { "id": "n3", "type": "action", "position": { "x": 690, "y": 60 }, "data": { "label": "→ Compra", "items": [{ "key": "assign_team", "config": { "team_id": 1 } }, { "key": "add_label", "config": { "labels": ["intent-compra"] } }] } },
221
+ { "id": "n4", "type": "action", "position": { "x": 690, "y": 240 }, "data": { "label": "→ Suporte", "items": [{ "key": "assign_team", "config": { "team_id": 2 } }, { "key": "add_label", "config": { "labels": ["intent-suporte"] } }] } },
222
+ { "id": "n5", "type": "action", "position": { "x": 690, "y": 420 }, "data": { "label": "→ Reclamação", "items": [{ "key": "assign_team", "config": { "team_id": 3 } }, { "key": "change_priority", "config": { "priority": "high" } }, { "key": "add_label", "config": { "labels": ["intent-reclamacao"] } }] } },
223
+ { "id": "n6", "type": "action", "position": { "x": 690, "y": 600 }, "data": { "label": "→ Dúvida", "items": [{ "key": "assign_captain", "config": { "assistant_id": 1 } }] } }
224
+ ],
225
+ "edges": [
226
+ { "id": "e1", "source": "n1", "target": "n2", "sourceHandle": "success", "type": "deletable", "animated": true },
227
+ { "id": "e2", "source": "n2", "target": "n3", "sourceHandle": "intent_compra", "type": "deletable", "animated": true },
228
+ { "id": "e3", "source": "n2", "target": "n4", "sourceHandle": "intent_suporte", "type": "deletable", "animated": true },
229
+ { "id": "e4", "source": "n2", "target": "n5", "sourceHandle": "intent_reclamacao", "type": "deletable", "animated": true },
230
+ { "id": "e5", "source": "n2", "target": "n6", "sourceHandle": "intent_duvida", "type": "deletable", "animated": true }
231
+ ]
232
+ }
233
+ ```
234
+
235
+ ---
236
+
237
+ ## 7. Re-engajamento de lead frio
238
+
239
+ **Caso:** após 7 dias sem resposta, manda template aprovado e marca label.
240
+
241
+ ```json
242
+ {
243
+ "nodes": [
244
+ { "id": "n1", "type": "start", "position": { "x": 50, "y": 300 }, "data": { "label": "Início", "triggers": [{ "type": "label_added", "label": "follow-up" }] } },
245
+ { "id": "n2", "type": "wait", "position": { "x": 370, "y": 300 }, "data": { "label": "Espera 7 dias", "waitTime": 7, "waitUnit": "days" } },
246
+ { "id": "n3", "type": "send_message", "position": { "x": 690, "y": 300 }, "data": { "label": "Template re-engajamento", "messageItems": [
247
+ { "id": "m1", "type": "whatsapp_template", "templateId": 42, "params": ["{{contact.name}}"] }
248
+ ] } },
249
+ { "id": "n4", "type": "action", "position": { "x": 1010, "y": 300 }, "data": { "label": "Marca tentativa", "items": [
250
+ { "key": "add_label", "config": { "labels": ["reengajamento-enviado"] } },
251
+ { "key": "remove_label", "config": { "labels": ["follow-up"] } }
252
+ ] } }
253
+ ],
254
+ "edges": [
255
+ { "id": "e1", "source": "n1", "target": "n2", "sourceHandle": "success", "type": "deletable", "animated": true },
256
+ { "id": "e2", "source": "n2", "target": "n3", "sourceHandle": "success", "type": "deletable", "animated": true },
257
+ { "id": "e3", "source": "n3", "target": "n4", "sourceHandle": "success", "type": "deletable", "animated": true }
258
+ ]
259
+ }
260
+ ```
261
+
262
+ ---
263
+
264
+ ## 8. Suporte com escalation pra humano
265
+
266
+ **Caso:** tenta resolver com IA. Se cliente pedir "atendente humano" ou IA não souber, escala.
267
+
268
+ ```json
269
+ {
270
+ "nodes": [
271
+ { "id": "n1", "type": "start", "position": { "x": 50, "y": 300 }, "data": { "label": "Início", "triggers": [{ "type": "message_received" }] } },
272
+ { "id": "n2", "type": "condition", "position": { "x": 370, "y": 300 }, "data": { "label": "Pede humano?", "conditions": [
273
+ { "id": "c1", "label": "Sim", "field": "last_message.content", "operator": "contains", "value": "humano" }
274
+ ] } },
275
+ { "id": "n3", "type": "action", "position": { "x": 690, "y": 120 }, "data": { "label": "→ Humano", "items": [
276
+ { "key": "deactivate_captain", "config": {} },
277
+ { "key": "assign_team", "config": { "team_id": 2 } },
278
+ { "key": "add_label", "config": { "labels": ["escalado-humano"] } }
279
+ ] } },
280
+ { "id": "n4", "type": "action", "position": { "x": 690, "y": 480 }, "data": { "label": "→ IA atende", "items": [
281
+ { "key": "assign_captain", "config": { "assistant_id": 1 } }
282
+ ] } }
283
+ ],
284
+ "edges": [
285
+ { "id": "e1", "source": "n1", "target": "n2", "sourceHandle": "success", "type": "deletable", "animated": true },
286
+ { "id": "e2", "source": "n2", "target": "n3", "sourceHandle": "cond_0", "type": "deletable", "animated": true },
287
+ { "id": "e3", "source": "n2", "target": "n4", "sourceHandle": "default", "type": "deletable", "animated": true }
288
+ ]
289
+ }
290
+ ```
291
+
292
+ ---
293
+
294
+ ## 9. Agendamento via API externa
295
+
296
+ **Caso:** cliente quer marcar reunião — fluxo chama API de booking, salva ID, confirma.
297
+
298
+ ```json
299
+ {
300
+ "nodes": [
301
+ { "id": "n1", "type": "start", "position": { "x": 50, "y": 300 }, "data": { "label": "Início", "triggers": [{ "type": "message_received", "keywords": ["agendar","reunião"], "match_mode": "contains" }] } },
302
+ { "id": "n2", "type": "send_message", "position": { "x": 370, "y": 300 }, "data": { "label": "Pede data", "messageItems": [{ "id": "m1", "type": "text", "content": "Em que data você prefere? (formato DD/MM)" }] } },
303
+ { "id": "n3", "type": "wait_response", "position": { "x": 690, "y": 300 }, "data": { "label": "Data", "waitTime": 30, "waitUnit": "minutes", "validation": "regex", "regexPattern": "^\\d{2}/\\d{2}$", "invalidMessage": "Formato inválido. Use DD/MM (ex: 25/05)", "maxRetries": 2, "saveTo": "variable", "saveVariable": "data_pref" } },
304
+ { "id": "n4", "type": "api", "position": { "x": 1010, "y": 300 }, "data": {
305
+ "label": "Cria booking", "method": "POST",
306
+ "url": "https://api.example.com/bookings",
307
+ "headers": [{ "key": "Authorization", "value": "Bearer {{env.BOOKING_TOKEN}}" }, { "key": "Content-Type", "value": "application/json" }],
308
+ "body": "{\"contact_id\":\"{{contact.id}}\",\"date\":\"{{data_pref}}\"}",
309
+ "apiResponseVar": "booking_result"
310
+ } },
311
+ { "id": "n5", "type": "send_message", "position": { "x": 1330, "y": 180 }, "data": { "label": "Confirma", "messageItems": [{ "id": "m2", "type": "text", "content": "Reunião agendada! ID {{booking_result.id}}. Te mando lembrete 1h antes." }] } },
312
+ { "id": "n6", "type": "send_message", "position": { "x": 1330, "y": 420 }, "data": { "label": "Erro", "messageItems": [{ "id": "m3", "type": "text", "content": "Não consegui agendar agora. Um atendente vai te ajudar." }] } },
313
+ { "id": "n7", "type": "action", "position": { "x": 1650, "y": 420 }, "data": { "label": "Escala", "items": [{ "key": "assign_team", "config": { "team_id": 1 } }] } }
314
+ ],
315
+ "edges": [
316
+ { "id": "e1", "source": "n1", "target": "n2", "sourceHandle": "success", "type": "deletable", "animated": true },
317
+ { "id": "e2", "source": "n2", "target": "n3", "sourceHandle": "success", "type": "deletable", "animated": true },
318
+ { "id": "e3", "source": "n3", "target": "n4", "sourceHandle": "success", "type": "deletable", "animated": true },
319
+ { "id": "e4", "source": "n4", "target": "n5", "sourceHandle": "success", "type": "deletable", "animated": true },
320
+ { "id": "e5", "source": "n4", "target": "n6", "sourceHandle": "error", "type": "deletable", "animated": true },
321
+ { "id": "e6", "source": "n6", "target": "n7", "sourceHandle": "success", "type": "deletable", "animated": true }
322
+ ]
323
+ }
324
+ ```
325
+
326
+ ---
327
+
328
+ ## 10. Notificação interna por webhook (label aplicada)
329
+
330
+ **Caso:** quando label "urgente" é aplicada, dispara webhook pro n8n/Slack.
331
+
332
+ ```json
333
+ {
334
+ "nodes": [
335
+ { "id": "n1", "type": "start", "position": { "x": 50, "y": 300 }, "data": { "label": "Início", "triggers": [{ "type": "label_added", "label": "urgente" }] } },
336
+ { "id": "n2", "type": "action", "position": { "x": 370, "y": 300 }, "data": { "label": "Dispara webhook", "items": [
337
+ { "key": "send_webhook", "config": {
338
+ "url": "https://hooks.slack.com/services/XXX/YYY/ZZZ",
339
+ "headers": [{ "key": "Content-Type", "value": "application/json" }],
340
+ "body": "{\"text\":\"🚨 Conversa urgente: {{conversation.id}} — cliente {{contact.name}}\"}"
341
+ } },
342
+ { "key": "change_priority", "config": { "priority": "urgent" } }
343
+ ] } }
344
+ ],
345
+ "edges": [
346
+ { "id": "e1", "source": "n1", "target": "n2", "sourceHandle": "success", "type": "deletable", "animated": true }
347
+ ]
348
+ }
349
+ ```
350
+
351
+ ---
352
+
353
+ ## Como usar este catálogo
354
+
355
+ 1. **Identifique o pattern mais próximo** do que o cliente pediu
356
+ 2. **Copie o `flow_data` inteiro**
357
+ 3. **Substitua os IDs e valores reais** (team_id, funnel_id, assistant_id, templateId, URLs, etc) — confira antes via `teams_list`, `funnels_list`, `captain_assistants_list`, `inboxes_whatsapp_templates_list`
358
+ 4. **Adicione campos do flow**: `name`, `description`, `channel_type` (`Channel::Waha` etc), `inbox_ids`
359
+ 5. **Chame `flows_create`** com o payload completo
360
+ 6. Após criar, **ative** com `flows_toggle` se o cliente quiser que rode já
361
+
362
+ Se a necessidade não bate com nenhum pattern, monte do zero seguindo o **`flowbuilder-design-guide`** — mas use estes templates como referência de layout/handle/schema válidos.