Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #68 from escopecz/webhook-event-order
Browse files Browse the repository at this point in the history
Webhook event order
  • Loading branch information
escopecz authored Sep 8, 2017
2 parents bbeb8a7 + 99fab35 commit 1a68bff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions source/includes/_api_endpoint_webhooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ $webhook = $webhookApi->get($id);
"name": "test",
"description": "Created via API",
"webhookUrl": "https:\/\/johndoe.com",
"eventsOrderbyDir": "DESC",
"category": {
"createdByUser": "John Doe",
"modifiedByUser": "John Doe",
Expand Down Expand Up @@ -74,6 +75,7 @@ id|int|ID of the webhook
name|string|Title of the webhook
description|string|Description of the webhook
webhookUrl|string|Url to send the webhook payload to
eventsOrderbyDir| Order direction for queued events in one webhook. Can be "DESC" or "ASC"
isPublished|bool|Published state
publishUp|datetime/null|Date/time when the webhook should be published
publishDown|datetime/null|Date/time the webhook should be un published
Expand Down Expand Up @@ -109,6 +111,7 @@ $webhooks = $webhookApi->getList($searchFilter, $start, $limit, $orderBy, $order
"name": "Deleted contact",
"description": "Notify me when a contact is deleted",
"webhookUrl": "https:\/\/johndoe.com",
"eventsOrderbyDir": "DESC",
"category": null,
"triggers": [
"mautic.lead_post_delete",
Expand Down Expand Up @@ -151,6 +154,7 @@ $data = array(
'name' => 'test',
'description' => 'Created via API',
'webhookUrl' => 'http://some.url',
'eventsOrderbyDir' => "ASC",
'triggers' => array(
'mautic.lead_post_save_update',
'mautic.lead_post_save_new',
Expand All @@ -173,6 +177,7 @@ id|int|ID of the webhook
name|string|Title of the webhook
description|string|Description of the webhook
webhookUrl|string|URL to send the webhook payload to
eventsOrderbyDir| Order direction for queued events in one webhook. Can be "DESC" or "ASC"
isPublished|bool|Published state

#### Response
Expand Down Expand Up @@ -220,6 +225,7 @@ id|int|ID of the webhook
name|string|Title of the webhook
description|string|Description of the webhook
webhookUrl|string|Url to send the webhook payload to
eventsOrderbyDir| Order direction for queued events in one webhook. Can be "DESC" or "ASC"
isPublished|bool|Published state

#### Response
Expand Down
4 changes: 4 additions & 0 deletions source/includes/_webhooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ This lag can be more visible when you do a CSV import. It may be slow when it is

If you want to avoid this lag, configure the webhook queue in the configuration and add this command to your cron tab: `app/console mautic:webhooks:process`. This way every time the webhook is triggered, the action is queued as a new row into database, so it is much faster and then the command will make the requests which may take some time. The caveat to this optimisation is that the webhooks are not fired every time the action happens, but every time the command runs.

## Queued event order

Mautic will send several events in one webhook if they happen before the queue trigger command runs. Mautic's default order of those events is chronological. But Zapier integration which use webhooks havily requires reverse chronological order. Thereofore the new option to configure the order was added to webhooks as well as to the global configuration. Webhook configuration overwrites the global configuration, but if not set, the global configuration order value is applied.

## Example webhook script

If you need an idea about how to receive Mautic webhook data in your app, this script can be used as a starting point. The script will log the request and return a PHP object of the payload. Place this script on a publicly accessible URL (i.e. `http://yourwebsite.com/webhookTest.php), then fill in the Mautic *Webhook POST Url* to this script.
Expand Down

0 comments on commit 1a68bff

Please sign in to comment.