From 38fd0e33ecd5b73a0c27ab21df8a5a8f2c4f5508 Mon Sep 17 00:00:00 2001 From: John Linhart Date: Thu, 10 Aug 2017 16:53:01 +0200 Subject: [PATCH 1/2] Webhook order described --- source/includes/_webhooks.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/includes/_webhooks.md b/source/includes/_webhooks.md index bf1e90ed15d..2bf95e52f08 100644 --- a/source/includes/_webhooks.md +++ b/source/includes/_webhooks.md @@ -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. From 99fab356990ce38cc7099b1539e1d42b01c891c1 Mon Sep 17 00:00:00 2001 From: John Linhart Date: Thu, 10 Aug 2017 16:53:18 +0200 Subject: [PATCH 2/2] Webhook API endpoints updated with order --- source/includes/_api_endpoint_webhooks.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/includes/_api_endpoint_webhooks.md b/source/includes/_api_endpoint_webhooks.md index 4567dea15fe..7b78cfe2ed0 100644 --- a/source/includes/_api_endpoint_webhooks.md +++ b/source/includes/_api_endpoint_webhooks.md @@ -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", @@ -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 @@ -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", @@ -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', @@ -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 @@ -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