{
    "name": "FoodSnap - Switch (Food & Coach)",
    "nodes": [
        {
            "parameters": {
                "httpMethod": "POST",
                "path": "wa/inbound",
                "options": {}
            },
            "type": "n8n-nodes-base.webhook",
            "typeVersion": 2.1,
            "position": [
                -740,
                -940
            ],
            "id": "f33b8fb6-babb-4beb-ab36-ec6a25f14eb2",
            "name": "Requisicao - Whatsapp",
            "webhookId": "2179d0c4-aaf5-4ce4-9463-332f09919612"
        },
        {
            "parameters": {
                "jsCode": "const body = $json.body ?? $json;\nconst data = body.data ?? {};\n\nconst remoteJid = data?.key?.remoteJid?.includes('@s.whatsapp.net') ? data.key.remoteJid : data?.key?.remoteJidAlt || '';\nconst number = remoteJid.replace(/\\D/g, '');\nconst message_id = data?.key?.id || '';\n\n// Texto (incluindo legenda de imagem)\nconst text = data?.message?.conversation || data?.message?.extendedTextMessage?.text || data?.message?.imageMessage?.caption || '';\n\nconst imageMessage = data?.message?.imageMessage || data?.message?.extendedTextMessage?.contextInfo?.quotedMessage?.imageMessage || null;\n\nreturn [{\n  number,\n  remoteJid,\n  message_id,\n  text,\n  hasImage: !!imageMessage,\n  imageMessage,\n  pushName: data?.pushName || 'Usuário',\n  timestamp: new Date().toISOString(),\n  raw: body\n}];"
            },
            "type": "n8n-nodes-base.code",
            "typeVersion": 2,
            "position": [
                -520,
                -940
            ],
            "id": "32f29e03-c120-4425-b8da-5f9984503e63",
            "name": "NormalizeInbound"
        },
        {
            "parameters": {
                "dataType": "string",
                "value1": "={{ $json.text }}",
                "rules": {
                    "rules": [
                        {
                            "operation": "contains",
                            "value2": "coach",
                            "output": 1
                        },
                        {
                            "operation": "contains",
                            "value2": "treino",
                            "output": 1
                        },
                        {
                            "operation": "contains",
                            "value2": "biotipo",
                            "output": 1
                        },
                        {
                            "operation": "contains",
                            "value2": "shape",
                            "output": 1
                        }
                    ]
                },
                "fallbackOutput": 0
            },
            "type": "n8n-nodes-base.switch",
            "typeVersion": 1,
            "position": [
                -300,
                -940
            ],
            "id": "switch-router",
            "name": "Roteador (Food/Coach)"
        },
        {
            "parameters": {
                "operation": "executeQuery",
                "query": "with u as ( select id from public.profiles where phone_e164 = cast({{ $('NormalizeInbound').item.json.number }} as text) limit 1 ), ent as ( select ue.user_id, ue.is_active, ue.entitlement_code, ue.valid_until from public.user_entitlements ue where ue.user_id = (select id from u) order by ue.valid_until desc nulls last limit 1 ), usage as ( select (select id from u) as user_id, count(*) filter (where fa.used_free_quota = true) as free_used from public.food_analyses fa where fa.user_id = (select id from u) ) select (select id from u) is not null as exists, (select id from u) as user_id, coalesce((select free_used from usage), 0)::int as free_used, greatest(0, 5 - coalesce((select free_used from usage), 0))::int as free_remaining, coalesce((select is_active from ent), false) as plan_active, ( (select id from u) is not null and ( ( coalesce((select is_active from ent), false) and ( (select valid_until from ent) is null or (select valid_until from ent) > now() ) ) or greatest(0, 5 - coalesce((select free_used from usage), 0)) > 0 ) ) as can_process;",
                "options": {}
            },
            "type": "n8n-nodes-base.postgres",
            "typeVersion": 2.6,
            "position": [
                -60,
                -1040
            ],
            "id": "a329a262-e03c-41f2-9d96-5d37ed5f6159",
            "name": "Validar Usuario (Food)",
            "credentials": {
                "postgres": {
                    "id": "2JDD2OJz4cAsWb0J",
                    "name": "foodsnap_supabase"
                }
            }
        },
        {
            "parameters": {
                "operation": "executeQuery",
                "query": "with u as ( select id from public.profiles where phone_e164 = cast({{ $('NormalizeInbound').item.json.number }} as text) limit 1 ), ent as ( select ue.is_active, ue.entitlement_code, ue.valid_until from public.user_entitlements ue where ue.user_id = (select id from u) order by ue.valid_until desc nulls last limit 1 ), usage as ( select count(*) as used_count from public.coach_analyses fa where fa.user_id = (select id from u) and fa.used_free_quota = true ) select (select id from u) as user_id, (select id from u) is not null as exists, coalesce((select used_count from usage), 0)::int as free_used, greatest(0, 3 - coalesce((select used_count from usage), 0))::int as free_remaining, coalesce((select is_active from ent), false) as plan_active, (coalesce((select is_active from ent), false) = true OR greatest(0, 3 - coalesce((select used_count from usage), 0)) > 0) as can_process",
                "options": {}
            },
            "type": "n8n-nodes-base.postgres",
            "typeVersion": 2.6,
            "position": [
                -60,
                -700
            ],
            "id": "validate-coach",
            "name": "Validar Coach",
            "credentials": {
                "postgres": {
                    "id": "2JDD2OJz4cAsWb0J",
                    "name": "foodsnap_supabase"
                }
            }
        },
        {
            "parameters": {
                "conditions": {
                    "options": {
                        "caseSensitive": true,
                        "leftValue": "",
                        "typeValidation": "strict",
                        "version": 3
                    },
                    "conditions": [
                        {
                            "id": "check-process-coach",
                            "leftValue": "={{ $json.can_process }}",
                            "rightValue": "",
                            "operator": {
                                "type": "boolean",
                                "operation": "true",
                                "singleValue": true
                            }
                        }
                    ],
                    "combinator": "and"
                },
                "options": {}
            },
            "type": "n8n-nodes-base.if",
            "typeVersion": 2.3,
            "position": [
                180,
                -700
            ],
            "id": "if-coach-quota",
            "name": "Pode usar Coach?"
        },
        {
            "parameters": {
                "resource": "messages-api",
                "instanceName": "FoodSnap",
                "remoteJid": "={{ $('NormalizeInbound').item.json.number }}",
                "messageText": "🏋️ *Coach AI*: Analisando seu físico... Aguarde!",
                "options_message": {}
            },
            "type": "n8n-nodes-evolution-api.evolutionApi",
            "typeVersion": 1,
            "position": [
                420,
                -700
            ],
            "id": "msg-ack-coach",
            "name": "Ack Coach",
            "credentials": {
                "evolutionApi": {
                    "id": "nGWBERcZoQWgdxgk",
                    "name": "FoodSnap"
                }
            }
        },
        {
            "parameters": {
                "resource": "chat-api",
                "operation": "get-media-base64",
                "instanceName": "FoodSnap",
                "messageId": "={{ $('NormalizeInbound').item.json.message_id }}"
            },
            "type": "n8n-nodes-evolution-api.evolutionApi",
            "typeVersion": 1,
            "position": [
                640,
                -700
            ],
            "id": "get-img-coach",
            "name": "Baixar IMG Coach",
            "credentials": {
                "evolutionApi": {
                    "id": "nGWBERcZoQWgdxgk",
                    "name": "FoodSnap"
                }
            }
        },
        {
            "parameters": {
                "operation": "toBinary",
                "sourceProperty": "data.base64",
                "options": {}
            },
            "type": "n8n-nodes-base.convertToFile",
            "typeVersion": 1.1,
            "position": [
                860,
                -700
            ],
            "id": "bin-coach",
            "name": "Binary Coach"
        },
        {
            "parameters": {
                "resource": "image",
                "operation": "analyze",
                "modelId": {
                    "__rl": true,
                    "value": "models/gemini-2.5-flash",
                    "mode": "list",
                    "cachedResultName": "models/gemini-2.5-flash"
                },
                "text": "=Você é um Treinador Físico de Elite e Nutricionista Esportivo.\nAnalise a imagem fornecida (foto de corpo inteiro/físico).\n\n1. Verifique se é uma foto de corpo humano válida para análise fitness. Se não, retorne \"valid_body\": false.\n2. Se for válida, estime:\n   - Biótipo Predominante (Ectomorfo, Mesomorfo, Endomorfo)\n   - Percentual de Gordura (BF% aproximado)\n   - Nível de Massa Muscular (Baixo, Médio, Alto)\n3. Sugira:\n   - Objetivo Principal (Cutting, Bulking, Manutenção)\n   - Divisão de Treino Recomendada (ex: ABC, ABCDE, Upper/Lower)\n   - Foco Dietético (ex: Carb Cycling, Alto Carbo, Keto)\n   - Dica de Ouro (uma frase curta de impacto)\n\nResponda APENAS em JSON estrito (sem markdown):\n{\n  \"valid_body\": true,\n  \"biotype\": \"...\",\n  \"estimated_body_fat\": 15,\n  \"muscle_mass\": \"Médio\",\n  \"goal\": \"Bulking\",\n  \"workout\": \"...\",\n  \"diet\": \"...\",\n  \"tip\": \"...\"\n}",
                "inputType": "binary",
                "simplify": false,
                "options": {}
            },
            "type": "@n8n/n8n-nodes-langchain.googleGemini",
            "typeVersion": 1,
            "position": [
                1080,
                -700
            ],
            "id": "gemini-coach",
            "name": "Gemini Coach",
            "credentials": {
                "googlePalmApi": {
                    "id": "T2uIVBcjJ9h8BFCC",
                    "name": "Backup APIKEY"
                }
            }
        },
        {
            "parameters": {
                "jsCode": "const raw = $json?.candidates?.[0]?.content?.parts?.[0]?.text || '{}';\nconst clean = raw.replace(/```json/g, '').replace(/```/g, '').trim();\nlet data = {};\ntry { \n  data = JSON.parse(clean); \n} catch(e) {\n  data = { valid_body: false, error: 'Failed to parse AI' };\n}\n\nreturn [{ ...data }];"
            },
            "type": "n8n-nodes-base.code",
            "typeVersion": 2,
            "position": [
                1300,
                -700
            ],
            "id": "parse-coach",
            "name": "Parse Coach"
        },
        {
            "parameters": {
                "operation": "executeQuery",
                "query": "insert into public.coach_analyses\n(\n  user_id,\n  source,\n  image_url,\n  ai_raw_response,\n  ai_structured,\n  biotype,\n  estimated_body_fat,\n  goal_suggestion,\n  muscle_mass_level,\n  used_free_quota\n)\nvalues\n(\n  cast('{{ $(\"Validar Coach\").item.json.user_id }}' as uuid),\n  'whatsapp',\n  null,\n  '{{ JSON.stringify($json) }}',\n  '{{ JSON.stringify($json) }}',\n  '{{ $json.biotype }}',\n  cast({{ $json.estimated_body_fat || 0 }} as numeric),\n  '{{ $json.goal }}',\n  '{{ $json.muscle_mass }}',\n  CASE\n    WHEN {{ $(\"Validar Coach\").item.json.plan_active }} = true THEN false\n    ELSE true\n  END\n)\nreturning id as analysis_id;",
                "options": {}
            },
            "type": "n8n-nodes-base.postgres",
            "typeVersion": 2.6,
            "position": [
                1520,
                -700
            ],
            "id": "save-coach",
            "name": "Salvar Coach DB",
            "credentials": {
                "postgres": {
                    "id": "2JDD2OJz4cAsWb0J",
                    "name": "foodsnap_supabase"
                }
            }
        },
        {
            "parameters": {
                "resource": "messages-api",
                "instanceName": "FoodSnap",
                "remoteJid": "={{ $('NormalizeInbound').item.json.number }}",
                "messageText": "=⚡ *Coach AI*\n\n🧬 *Biótipo*: {{$json.biotype}}\n⚖️ *BF*: ~{{$json.estimated_body_fat}}%\n💪 *Massa*: {{$json.muscle_mass}}\n\n🎯 *Foco*: {{$json.goal}}\n🏋️ *Treino*: {{$json.workout}}\n\n💡 *Dica*: {{$json.tip}}\n\n_Veja mais no App!_",
                "options_message": {}
            },
            "type": "n8n-nodes-evolution-api.evolutionApi",
            "typeVersion": 1,
            "position": [
                1740,
                -700
            ],
            "id": "reply-coach",
            "name": "Responder Coach",
            "credentials": {
                "evolutionApi": {
                    "id": "nGWBERcZoQWgdxgk",
                    "name": "FoodSnap"
                }
            }
        },
        {
            "parameters": {
                "conditions": {
                    "options": {
                        "caseSensitive": true,
                        "leftValue": "",
                        "typeValidation": "strict",
                        "version": 3
                    },
                    "conditions": [
                        {
                            "id": "70a7760f-4a83-4a80-bbbc-9eaf93a06a33",
                            "leftValue": "={{$json.exists}}",
                            "rightValue": "",
                            "operator": {
                                "type": "boolean",
                                "operation": "true",
                                "singleValue": true
                            }
                        }
                    ],
                    "combinator": "and"
                },
                "options": {}
            },
            "type": "n8n-nodes-base.if",
            "typeVersion": 2.3,
            "position": [
                160,
                -1040
            ],
            "id": "9e1ea558-2466-4426-9c9f-f5051e76da4f",
            "name": "Usuário existe?"
        },
        {
            "parameters": {
                "conditions": {
                    "options": {
                        "caseSensitive": true,
                        "leftValue": "",
                        "typeValidation": "strict",
                        "version": 3
                    },
                    "conditions": [
                        {
                            "id": "873dc279-9223-464a-b632-bf019f20c030",
                            "leftValue": "={{ $json.can_process }}",
                            "rightValue": "",
                            "operator": {
                                "type": "boolean",
                                "operation": "true",
                                "singleValue": true
                            }
                        }
                    ],
                    "combinator": "and"
                },
                "options": {}
            },
            "type": "n8n-nodes-base.if",
            "typeVersion": 2.3,
            "position": [
                380,
                -1120
            ],
            "id": "63ea8c4f-ebe3-4c0b-95bb-51dc0c64d639",
            "name": "Pode usar Food?"
        },
        {
            "parameters": {
                "conditions": {
                    "options": {
                        "caseSensitive": true,
                        "leftValue": "",
                        "typeValidation": "strict",
                        "version": 3
                    },
                    "conditions": [
                        {
                            "id": "a5e5b4e5-ce26-4b2b-90e6-ba96e55006a8",
                            "leftValue": "={{$node[\"NormalizeInbound\"].json.hasImage}}",
                            "rightValue": "",
                            "operator": {
                                "type": "boolean",
                                "operation": "true",
                                "singleValue": true
                            }
                        }
                    ],
                    "combinator": "and"
                },
                "options": {}
            },
            "type": "n8n-nodes-base.if",
            "typeVersion": 2.3,
            "position": [
                600,
                -1020
            ],
            "id": "7130f3dd-fc60-4cba-b064-d7d98e846b86",
            "name": "If texto? imagem?"
        },
        {
            "parameters": {
                "resource": "messages-api",
                "instanceName": "FoodSnap",
                "remoteJid": "={{ $('NormalizeInbound').item.json.number }}",
                "messageText": "👋 Olá! Envie uma *foto do prato* para calorias ou escreva *'Coach'* e envie uma foto do corpo para análise física.",
                "options_message": {}
            },
            "type": "n8n-nodes-evolution-api.evolutionApi",
            "typeVersion": 1,
            "position": [
                820,
                -920
            ],
            "id": "5f897b38-e120-4f68-8870-6d793d22a3ff",
            "name": "Enviar texto help",
            "credentials": {
                "evolutionApi": {
                    "id": "nGWBERcZoQWgdxgk",
                    "name": "FoodSnap"
                }
            }
        },
        {
            "parameters": {
                "resource": "messages-api",
                "instanceName": "FoodSnap",
                "remoteJid": "={{ $('NormalizeInbound').item.json.number }}",
                "messageText": "📸 Recebi sua foto! Analisando o prato... ⏳",
                "options_message": {}
            },
            "type": "n8n-nodes-evolution-api.evolutionApi",
            "typeVersion": 1,
            "position": [
                820,
                -1120
            ],
            "id": "704eec2f-2f98-4872-b414-c805f0642ef3",
            "name": "Ack_Recebi_Foto",
            "credentials": {
                "evolutionApi": {
                    "id": "nGWBERcZoQWgdxgk",
                    "name": "FoodSnap"
                }
            }
        },
        {
            "parameters": {
                "resource": "chat-api",
                "operation": "get-media-base64",
                "instanceName": "FoodSnap",
                "messageId": "={{ $('Requisicao - Whatsapp').item.json.body.data.key.id }}"
            },
            "type": "n8n-nodes-evolution-api.evolutionApi",
            "typeVersion": 1,
            "position": [
                1040,
                -1120
            ],
            "id": "200672ed-2daf-46ee-9853-08bff8b55c86",
            "name": "Imagem Base64",
            "credentials": {
                "evolutionApi": {
                    "id": "nGWBERcZoQWgdxgk",
                    "name": "FoodSnap"
                }
            }
        },
        {
            "parameters": {
                "operation": "toBinary",
                "sourceProperty": "data.base64",
                "options": {}
            },
            "type": "n8n-nodes-base.convertToFile",
            "typeVersion": 1.1,
            "position": [
                1260,
                -1120
            ],
            "id": "0076759b-6f96-4f58-a828-bd329a803054",
            "name": "Converter Base64/Binario"
        },
        {
            "parameters": {
                "resource": "image",
                "operation": "analyze",
                "modelId": {
                    "__rl": true,
                    "value": "models/gemini-2.5-flash",
                    "mode": "list",
                    "cachedResultName": "models/gemini-2.5-flash"
                },
                "text": "=Você é um assistente nutricional... (Prompt Original de Comida)... Retorne SOMENTE JSON.",
                "inputType": "binary",
                "simplify": false,
                "options": {}
            },
            "type": "@n8n/n8n-nodes-langchain.googleGemini",
            "typeVersion": 1,
            "position": [
                1480,
                -1120
            ],
            "id": "629515c5-8021-4162-9a5f-aac2c5f4cb82",
            "name": "Analyze an image Food",
            "credentials": {
                "googlePalmApi": {
                    "id": "T2uIVBcjJ9h8BFCC",
                    "name": "Backup APIKEY"
                }
            }
        },
        {
            "parameters": {
                "jsCode": "// Código original de limpeza do Food\nconst raw = $json?.candidates?.[0]?.content?.parts?.[0]?.text || '{}';\n// ... continuação do código original ...\nconst clean = raw.replace(/```json/gi, \"\").replace(/```/g, \"\").trim();\nlet parsed = JSON.parse(clean);\n// ... normalizações ...\nreturn [parsed];"
            },
            "type": "n8n-nodes-base.code",
            "typeVersion": 2,
            "position": [
                1700,
                -1120
            ],
            "id": "6c7ed1f5-61d5-4911-b518-6bb3ff1205b5",
            "name": "Limpar Resultado Food"
        },
        {
            "parameters": {
                "jsCode": "const payload = Array.isArray($json) ? $json[0] : $json;\nconst sender = payload?.sender || $node[\"NormalizeInbound\"]?.json?.number || \"\";\nconst analysis_json = payload && typeof payload === \"object\" ? payload : {};\nconst updated_at = new Date().toISOString();\nreturn [{ sender, analysis_json, updated_at }];"
            },
            "type": "n8n-nodes-base.code",
            "typeVersion": 2,
            "position": [
                1920,
                -1120
            ],
            "id": "b6f194fa-71ba-4b05-b448-fdb67957ae1b",
            "name": "Salvar Analise Prep"
        },
        {
            "parameters": {
                "operation": "executeQuery",
                "query": "insert into public.food_analyses (user_id, source, ai_raw_response, ai_structured, total_calories) values (cast('{{ $(\"Validar Usuario (Food)\").item.json.user_id }}' as uuid), 'whatsapp', cast('{{ $node[\"Analyze an image Food\"].json.candidates[0].content.parts[0].text }}' as text), cast('{{ JSON.stringify($node[\"Limpar Resultado Food\"].json) }}' as jsonb), cast({{ $node[\"Limpar Resultado Food\"].json.total.calories }} as int)) returning id as analysis_id;",
                "options": {}
            },
            "type": "n8n-nodes-base.postgres",
            "typeVersion": 2.6,
            "position": [
                2140,
                -1120
            ],
            "id": "556c631a-4a54-4cc1-b6f1-dd0473135a0f",
            "name": "Salvar historico Food",
            "credentials": {
                "postgres": {
                    "id": "2JDD2OJz4cAsWb0J",
                    "name": "foodsnap_supabase"
                }
            }
        },
        {
            "parameters": {
                "jsCode": "const items = $json.analysis_json?.items || [];\nconst total = $json.analysis_json?.total || {};\nconst lines = [\"🥗 *RELATÓRIO PRATOFIT*\"];\n// ... lógica original de formatação ...\nreturn [{ text: lines.join(\"\\n\") }];"
            },
            "type": "n8n-nodes-base.code",
            "typeVersion": 2,
            "position": [
                2360,
                -1120
            ],
            "id": "e3bdb17a-fb9c-4178-b751-3c80ee616bd7",
            "name": "Formatar Resposta Food"
        },
        {
            "parameters": {
                "resource": "messages-api",
                "instanceName": "FoodSnap",
                "remoteJid": "={{$node[\"NormalizeInbound\"].json.number}}",
                "messageText": "={{$json.text}}",
                "options_message": {}
            },
            "type": "n8n-nodes-evolution-api.evolutionApi",
            "typeVersion": 1,
            "position": [
                2580,
                -1120
            ],
            "id": "e887d0a0-9bcb-4820-95dc-9c115a9b2a48",
            "name": "Resposta WPP Food",
            "credentials": {
                "evolutionApi": {
                    "id": "nGWBERcZoQWgdxgk",
                    "name": "FoodSnap"
                }
            }
        },
        {
            "parameters": {
                "resource": "messages-api",
                "instanceName": "FoodSnap",
                "remoteJid": "={{ $('NormalizeInbound').item.json.number }}",
                "messageText": "🚫 *Acesso restrito* Seu número não está cadastrado. Cadastre-se em: https://foodsnap.com.br",
                "options_message": {}
            },
            "type": "n8n-nodes-evolution-api.evolutionApi",
            "typeVersion": 1,
            "position": [
                400,
                -880
            ],
            "id": "c9352ebc-63bc-421a-9e79-a98492ec996a",
            "name": "Nao Cadastrado"
        },
        {
            "parameters": {
                "resource": "messages-api",
                "instanceName": "FoodSnap",
                "remoteJid": "={{ $('NormalizeInbound').item.json.number }}",
                "messageText": "🚫 Limite gratuito atingido. Assine um plano em foodsnap.com.br",
                "options_message": {}
            },
            "type": "n8n-nodes-evolution-api.evolutionApi",
            "typeVersion": 1,
            "position": [
                600,
                -1220
            ],
            "id": "baea905c-add5-48a8-9c9e-81441c6c56d9",
            "name": "Sem Plano Food",
            "credentials": {
                "evolutionApi": {
                    "id": "nGWBERcZoQWgdxgk",
                    "name": "FoodSnap"
                }
            }
        }
    ],
    "connections": {
        "Requisicao - Whatsapp": {
            "main": [
                [
                    {
                        "node": "NormalizeInbound",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "NormalizeInbound": {
            "main": [
                [
                    {
                        "node": "Roteador (Food/Coach)",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Roteador (Food/Coach)": {
            "main": [
                [
                    {
                        "node": "Validar Usuario (Food)",
                        "type": "main",
                        "index": 0
                    }
                ],
                [
                    {
                        "node": "Validar Coach",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Validar Usuario (Food)": {
            "main": [
                [
                    {
                        "node": "Usuário existe?",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Usuário existe?": {
            "main": [
                [
                    {
                        "node": "Pode usar Food?",
                        "type": "main",
                        "index": 0
                    }
                ],
                [
                    {
                        "node": "Nao Cadastrado",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Pode usar Food?": {
            "main": [
                [
                    {
                        "node": "If texto? imagem?",
                        "type": "main",
                        "index": 0
                    }
                ],
                [
                    {
                        "node": "Sem Plano Food",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "If texto? imagem?": {
            "main": [
                [
                    {
                        "node": "Ack_Recebi_Foto",
                        "type": "main",
                        "index": 0
                    }
                ],
                [
                    {
                        "node": "Enviar texto help",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Ack_Recebi_Foto": {
            "main": [
                [
                    {
                        "node": "Imagem Base64",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Imagem Base64": {
            "main": [
                [
                    {
                        "node": "Converter Base64/Binario",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Converter Base64/Binario": {
            "main": [
                [
                    {
                        "node": "Analyze an image Food",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Analyze an image Food": {
            "main": [
                [
                    {
                        "node": "Limpar Resultado Food",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Limpar Resultado Food": {
            "main": [
                [
                    {
                        "node": "Salvar Analise Prep",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Salvar Analise Prep": {
            "main": [
                [
                    {
                        "node": "Salvar historico Food",
                        "type": "main",
                        "index": 0
                    },
                    {
                        "node": "Formatar Resposta Food",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Formatar Resposta Food": {
            "main": [
                [
                    {
                        "node": "Resposta WPP Food",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Validar Coach": {
            "main": [
                [
                    {
                        "node": "Pode usar Coach?",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Pode usar Coach?": {
            "main": [
                [
                    {
                        "node": "Ack Coach",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Ack Coach": {
            "main": [
                [
                    {
                        "node": "Baixar IMG Coach",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Baixar IMG Coach": {
            "main": [
                [
                    {
                        "node": "Binary Coach",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Binary Coach": {
            "main": [
                [
                    {
                        "node": "Gemini Coach",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Gemini Coach": {
            "main": [
                [
                    {
                        "node": "Parse Coach",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Parse Coach": {
            "main": [
                [
                    {
                        "node": "Salvar Coach DB",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Salvar Coach DB": {
            "main": [
                [
                    {
                        "node": "Responder Coach",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        }
    }
}