{
  "name": "Track MPESA and Airtel mobile payments in a fundraising WhatsApp group",
  "nodes": [
    {
      "id": "6d3bfa00-655c-47e0-ae46-c2565b665e71",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1120,
        -288
      ]
    },
    {
      "id": "18d3f891-25e2-4032-a05b-b3e896d1cbc6",
      "name": "Fetch payments",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        352,
        240
      ]
    },
    {
      "id": "75370c0b-0ffb-494c-a346-007ce04cd02f",
      "name": "Save payment",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        128,
        312
      ]
    },
    {
      "id": "1e5cc38b-482c-4ff7-a113-1803e5b499b5",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -232,
        128
      ],
      "parameters": {
        "width": 528,
        "height": 416,
        "content": "## Log Payment \nLog each payment posted in the group chat.\n\n"
      }
    },
    {
      "id": "97684e1b-095b-4fc0-96d1-9e53573cab17",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        336,
        144
      ],
      "parameters": {
        "width": 352,
        "height": 256,
        "content": "## Summarize payments\nUsing group id or sender\n"
      }
    },
    {
      "id": "405bb9fc-7f9b-4748-8a4b-fb3125caf9e7",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        -896,
        -288
      ]
    },
    {
      "id": "a5bf7d85-3520-4425-ba9c-5012653754a3",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        800,
        -72
      ]
    },
    {
      "id": "b3cc1322-2c26-4687-b09c-4d77508d1da2",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        744,
        -168
      ],
      "parameters": {
        "width": 880,
        "height": 256,
        "content": "## Send to Whatsapp\nPrepare reply then send it to whatsapp"
      }
    },
    {
      "id": "c99fb8ff-ca29-4aa2-b60b-cf8c6054bf5f",
      "name": "Send a WhatsApp message",
      "type": "n8n-nodes-base.twilio",
      "position": [
        1696,
        -72
      ]
    },
    {
      "id": "f4c47eea-59c2-4847-9a06-360cac24119d",
      "name": "Build one object",
      "type": "n8n-nodes-base.code",
      "position": [
        1024,
        -72
      ]
    },
    {
      "id": "8ea24cf6-e363-4ab3-999c-f8f429bf0fad",
      "name": "Airtel Money",
      "type": "n8n-nodes-base.code",
      "position": [
        -160,
        384
      ]
    },
    {
      "id": "02509236-5924-46ce-b84b-2a0179456966",
      "name": "Mpesa",
      "type": "n8n-nodes-base.code",
      "position": [
        -160,
        192
      ]
    },
    {
      "id": "c3111194-8cbd-4c4c-9010-8b89a1a942ce",
      "name": "Classify Message",
      "type": "n8n-nodes-base.code",
      "position": [
        -672,
        -192
      ]
    },
    {
      "id": "f60482cf-ef25-4e01-acfc-af7a1d989f18",
      "name": "Route",
      "type": "n8n-nodes-base.switch",
      "position": [
        -448,
        0
      ]
    },
    {
      "id": "1eb578f0-f822-4a0b-a2c2-07d8c84c4dfc",
      "name": "Delete payments",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        336,
        0
      ]
    },
    {
      "id": "df0349cd-cc95-4dfe-9407-1cc1091a9a02",
      "name": "Create Message",
      "type": "n8n-nodes-base.function",
      "position": [
        560,
        0
      ]
    },
    {
      "id": "3e53a7dd-70eb-4b1a-a938-e285af7f462f",
      "name": "Create Summary",
      "type": "n8n-nodes-base.function",
      "position": [
        576,
        240
      ]
    },
    {
      "id": "05753ca1-574f-4e67-a212-fd41b6b4dc24",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1696,
        -400
      ],
      "parameters": {
        "width": 512,
        "height": 1008,
        "content": "## Try It Out!\n### This n8n templates assists with keeping track of mobile payments within a fundraising WhatsApp group.\n\nUse cases: We fundraise alot using whatsapp groups in East Africa, especially "
      }
    },
    {
      "id": "64117beb-31ee-493c-9d9b-3a481d1ccde8",
      "name": "Drop original message",
      "type": "n8n-nodes-base.set",
      "position": [
        576,
        -384
      ]
    },
    {
      "id": "11893f1c-607b-4d06-82d8-5c135bd94adf",
      "name": "Valid message ?",
      "type": "n8n-nodes-base.if",
      "position": [
        1248,
        -72
      ]
    },
    {
      "id": "52c44b9f-6ed3-48e5-a238-35a5e16006bc",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -896,
        -96
      ]
    },
    {
      "id": "b32b6585-57da-440a-bb5b-31a2362459eb",
      "name": "Respond to Chat",
      "type": "@n8n/n8n-nodes-langchain.chat",
      "position": [
        -1120,
        608
      ]
    },
    {
      "id": "2aca8c54-fcea-4aa9-bd9a-bc29a091abd0",
      "name": "If sender is a phone",
      "type": "n8n-nodes-base.if",
      "position": [
        1472,
        -72
      ]
    },
    {
      "id": "99853f83-c63e-4c9b-82e1-6fb8ee97c9d7",
      "name": "Message a model",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        -208,
        -128
      ]
    },
    {
      "id": "01b3abb9-5ccd-4b26-8592-aa3c3cfb3374",
      "name": "Code in JavaScript",
      "type": "n8n-nodes-base.code",
      "position": [
        256,
        -256
      ]
    }
  ],
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Build one object",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mpesa": {
      "main": [
        [
          {
            "node": "Save payment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Delete payments",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fetch payments",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Mpesa",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Airtel Money",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Classify Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtel Money": {
      "main": [
        [
          {
            "node": "Save payment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save payment": {
      "main": [
        [
          {
            "node": "Fetch payments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Message": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Create Summary": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Fetch payments": {
      "main": [
        [
          {
            "node": "Create Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete payments": {
      "main": [
        [
          {
            "node": "Create Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Valid message ?": {
      "main": [
        [
          {
            "node": "If sender is a phone",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Build one object": {
      "main": [
        [
          {
            "node": "Valid message ?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify Message": {
      "main": [
        [
          {
            "node": "Route",
            "type": "main",
            "index": 0
          },
          {
            "node": "Drop original message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "If sender is a phone": {
      "main": [
        [
          {
            "node": "Send a WhatsApp message",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Drop original message": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a WhatsApp message": {
      "main": [
        []
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Classify Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}