How to send the contact.id to a webhook?

Your software
My Mautic version is: 5.0.4
My PHP version is: 8.1.28
My Database type and version is: 10.11.8-MariaDB-0ubuntu0.24.04.1

It’s not really a problem but rather a question. I’d like to have my mautic issue a request back to my website when users are added to a segment and use the information returned by the webhook to update a contact’s custom property.

Is this possible?

The use case is the following:

I’ve created a launch sequence for an upcoming product I’m launching. The sequence ends with a discount code only valid for 48hs.

What I’d like to do is to re-use the emails in this campaign to automate the sales beyond the launch.

I put together a webhook on my website which allows me to programmatically create new discount codes with a pre-established activation window set to the end of the email sequence.

What I’d like to do is take this unique code per user and add it to a custom property that I can later write in the email campaign so that each person will have their own 48hs to complete the purchase.

I’m looking at the possibility of using the Mautic API to fill the custom field with the discount code created at my website.

The only thing I’m not sure how to achieve currently is how to send the contact id to my webhook.

Is there any way I can use a contact property to fill the value sent here:

Thanks!

Unsure if you’re looking for the API endpoint or the webhook. So there goes both;

Webhook
https://devdocs.mautic.org/en/5.x/webhooks/events/lead_post_save_new.html

API
https://devdocs.mautic.org/en/5.x/rest_api/fields.html

I got confused there:

I’m looking at the possibility of using the Mautic API to fill the custom field with the discount code created at my website. The only thing I’m not sure how to achieve currently is how to send the contact id to my webhook.

API can only be reached out. And will never reach out.
A webhook won’t listen to anything (there’s no endpoint). It can only be used to react to an event.

If you prefer;
A webhook can query an API. But an API will never query a webhook.

Anyways, yes, totally possible and quickly doable (depending on how comfortable you are with an interpreter like php/bash/python/node/perl and many more).

From my understanding, you need to access both websites API periodically (and webhooks aren’t really required since real-time isn’t a thing).

From there, depending on a certain field value (null/not/other) of a contact (that is Mautic) or customer (that would be your e-comm), it would update one or both websites (unsure about that bit too - I would love to see your idea on a flow chart).

Hey @marcus42! Sorry if I wasn’t clear enough.

I actually achieved most of what I was looking for but you gave me a good idea about how to solve the issue I’m currently facing.

Here’s a diagram I hope makes things clearer:

The two actors here are my WP site and my Mautic instance.

The discount code will be applied later on when the visitor to the WP site wants to buy a product but I need it in the Mautic db to send it to them through a drip campaign.

So basically, what I’d like to do is add a parameter to the URL of the webhook Mautic will be calling as an event in the campaign:

The idea is that, as soon as a contact is added to a certain segment, they should receive their discount code.

Make sense?

Missed a detail in your description…

Bad post - sorry

1 Like