When has new contact from mautic, add to Google Sheets!

Hi! Zapier has a zap when has new contact from mautic, add to Google Sheets like picture

Can n8n do the same thing like that?

We have a Mautic Trigger node which supports all events Mautic supports (we query the Mautic API itself to get the list). So if it is possible on Zapier I would say it is also possible in n8n.

Here is also the identical list on their website:

I am no Mautic expert in any way. So no idea what event they would send when a new contact gets created. Maybe it is either part of “Contact Identified Event” or “Contact Updated Event”. So would be a better question for the Mautic forum than ours. Additionally do I have to say that the events seems somehow very unreliable. Every time I test it seems very random if we actually get informed on an event or not.

I’ve tried Mautic Trigger as time I know awesome n8n and set like this

But when running with workflow below, there’s nothing data.

{
  "nodes": [
    {
      "parameters": {
        "events": [
          "mautic.lead_post_save_new",
          "mautic.lead_post_save_update"
        ]
      },
      "name": "Mautic Trigger",
      "type": "n8n-nodes-base.mauticTrigger",
      "typeVersion": 1,
      "position": [
        410,
        140
      ],
      "credentials": {
        "mauticApi": "Mindalife MT"
      }
    },
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        80,
        310
      ]
    },
    {
      "parameters": {
        "events": [
          "mautic.lead_post_save_new",
          "mautic.lead_post_save_update"
        ]
      },
      "name": "Mautic Trigger",
      "type": "n8n-nodes-base.mauticTrigger",
      "typeVersion": 1,
      "position": [
        410,
        140
      ],
      "credentials": {
        "mauticApi": "Mindalife MT"
      }
    },
    {
      "parameters": {
        "operation": "append",
        "sheetId": "1oXdGqzLl6p7hSrjzYBE5g5qd2ChBr17HzqwqCXJjmNw",
        "options": {}
      },
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        650,
        290
      ],
      "credentials": {
        "googleApi": "n8n API"
      }
    },
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "everyHour",
              "minute": 6
            }
          ]
        }
      },
      "name": "Cron",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [
        390,
        390
      ]
    }
  ],
  "connections": {
    "Mautic Trigger": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cron": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

@huuich I been trying to test it and it’s not working. The webhook is created in Mautic but for some reason never triggers the event. Not sure if it’s because I’m using a sandbox account. Are you testing on a sandbox account as well?

Yes that is exactly what I was talking about @RicardoE105 @huuich with the events being very unreliable. I tested also before multiple times and maybe 1 out of 10 worked. Anyway n8n does not seem to be the problem.

I’m using n8n on a real mautic site, this site always has new contact created. All n8n Mautic I’m using ok, excepted Mautic Trigger

I’ve send you an account on this production site via message, can you test Mautic trigger?

@RicardoE105 Thanks for testing, could you share the workflow when has new contact from mautic, added contact’s information to a Google Sheets row?

@huuich something like this should do it. However, I just realized the trigger can be improved by mapping the data to something easier to use. I had to use a function node in the example. I will add that to my list so that the function node it’s not needed. let me know if something.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "events": [
          "mautic.lead_post_save_new"
        ]
      },
      "name": "Mautic Trigger",
      "type": "n8n-nodes-base.mauticTrigger",
      "typeVersion": 1,
      "position": [
        500,
        310
      ],
      "credentials": {
        "mauticApi": "asasasas"
      }
    },
    {
      "parameters": {
        "functionCode": "const item = items[0];\n\nconst data = Object.assign({},item.json[\"mautic.lead_post_save_new\"][0].lead.fields.core, item.json[\"mautic.lead_post_save_new\"][0].lead.personal, item.json[\"mautic.lead_post_save_new\"][0].lead.social, item.json[\"mautic.lead_post_save_new\"][0].lead.profesional)\n\nconst response = {};\n\nfor (const key of Object.keys(data)) {\n    response[[key]] = data[key].value;\n}\n\nreturn [ { json: response } ]\n\n\n"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        730,
        310
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "sheetId": "yourid",
        "options": {}
      },
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        950,
        310
      ],
      "credentials": {
        "googleApi": "asas"
      }
    }
  ],
  "connections": {
    "Mautic Trigger": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

I’ve used your Workflow and active but there’s nothing new on Google Sheets when new contact added to mautic. I’ve tried to add cron set 1 minutes but nothing happens, too.

Did you active the workflow? You do not need a cron node.

Yes, I’ve actived workflow. Maybe this is the SSL Certificate like mautic report below. How can I check ssl on my website, where it is stored? I follow this manual to setup but still can not access via ssl on my website: https://docs.n8n.io/#/server-setup

@huuich yes SSL could be the issue. Guess if it complains then it does not actually send the data.

@huuich could you figure it out?

@jan @RicardoE105 I still don’t know how to install ssl on my n8n site. I need .crt and .key file to put in my Reverse Proxy. How can I install ssl on my n8n site and copy .crt and .key file?

I’ve made workflow work ok, but there’s nothing data in Google Sheets though trigger works ok.

Hey @huuich, can you share the workflow so that I can have a look? Probably you are sending the data in the wrong format to the google sheets node. Check the post below.

I’ve used workflow you’ve shared above.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "events": [
          "mautic.lead_post_save_new"
        ]
      },
      "name": "Mautic Trigger",
      "type": "n8n-nodes-base.mauticTrigger",
      "typeVersion": 1,
      "position": [
        500,
        310
      ],
      "credentials": {
        "mauticApi": "asasasas"
      }
    },
    {
      "parameters": {
        "functionCode": "const item = items[0];\n\nconst data = Object.assign({},item.json[\"mautic.lead_post_save_new\"][0].lead.fields.core, item.json[\"mautic.lead_post_save_new\"][0].lead.personal, item.json[\"mautic.lead_post_save_new\"][0].lead.social, item.json[\"mautic.lead_post_save_new\"][0].lead.profesional)\n\nconst response = {};\n\nfor (const key of Object.keys(data)) {\n    response[[key]] = data[key].value;\n}\n\nreturn [ { json: response } ]\n\n\n"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        730,
        310
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "sheetId": "yourid",
        "options": {}
      },
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        950,
        310
      ],
      "credentials": {
        "googleApi": "asas"
      }
    }
  ],
  "connections": {
    "Mautic Trigger": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

@huuich the only thing that comes to mind it’s that your google sheets have a different structure than the one I used to create the example. Can you share the structure so that I can have a look?

I only put to an empty google sheets, I don’t know how to make a google sheets structure to work. Can you share your structure working Google Sheets?

ok, what do you want to save on the spreadsheet?