verbb / formie

The most user-friendly forms plugin for Craft CMS.
Other
94 stars 72 forks source link

Integromat webhook fails #147

Closed rickbergmans closed 3 years ago

rickbergmans commented 3 years ago

When adding an Integromat integration to a form and sending a test payload, I'm getting an erorr with status code 500. It appears to by a JSON syntax error. I already tried multiple fields, as well as only one text field.

Craft version: 3.5.11.1 Formie version: 1.2.19

Schermafbeelding 2020-09-30 om 09 31 03
engram-design commented 3 years ago

I'm not familiar with Integromat, but it looks like the response from them is not valid JSON. Is there any more information in the logs?

rickbergmans commented 3 years ago

This is the only information I get:

2020-09-30 09:30:37 [-][1][-][error][formie] integromat contact: API error: “Syntax error.” /Users/rickbergmans/Sites/frissewind/vendor/yiisoft/yii2/helpers/BaseJson.php:133
2020-09-30 09:30:36 [-][1][-][info][application] $_GET = [
    'p' => 'admin/actions/formie/integrations/form-settings'
]

$_POST = [
    'formId' => '736'
    'integration' => 'integromatContact'
]
engram-design commented 3 years ago

By the way, is this a custom webhook integration, as your screenshot seems like that's the case, and not just using the provided "Webhook" integration?

Dahlhaus commented 3 years ago

When I make a direct post to the webhook using Postman I get a regular "success" message. Pasting the URL in de address bar in Chrome, does give the same result.

Postman

Dahlhaus commented 3 years ago

By the way, is this a custom webhook integration, as your screenshot seems like that's the case, and not just using the provided "Webhook" integration?

What is the difference between a regular and custom webhook?

I do receive the test information on the webhook in Integromat. And I am able to process the JSON received. That works well. However the test feature gives and 500 error.

When posting a message directly from the form it does not arrive on the webhook.

engram-design commented 3 years ago

@Dahlhaus Is the raw response JSON, or just text? I'm just trying to setup something in Integromat to test, but it's a bit tricky to figure out compared to Zapier. But it looks like the response from them isn't valid JSON, which Formie expects.

And what I meant is, is this a custom integration you're creating (an in, you're registering your own class), but don't worry about this, I think you're just using the generic Webhook. My mistake.

I might have to modify the logging behaviour to include the raw response so we can diagnose further. Can you try this by changing your verbb/formie requirement in `composer.json to:

"require": {
  "verbb/formie": "dev-craft-3 as 1.2.19",
  "...": "..."
}

Then run composer update.

This should produce more information in the logs to diagnose. But I have a pretty good feeling your service is returning just a string, and not JSON.

Dahlhaus commented 3 years ago

@rickbergmans see the response from @engram-design. This is on your side I guess. :)

To be clear, I am end user of the website and do not control the web server.

Dahlhaus commented 3 years ago

@engram-design yes I just use a generic webhook. I you create a scenario, with just the generic webhook you will get the same result. FYI you can also add a webhook response to the webhook, maybe that will help.

rickbergmans commented 3 years ago

@engram-design the response in the formie logs:

2020-09-30 15:39:48 [-][1][-][error][formie] integromat: API error: “Syntax error.” /Users/rickbergmans/Sites/frissewind/vendor/yiisoft/yii2/helpers/BaseJson.php:133. Payload: “{"json":{"submission":{"id":null,"formId":736,"statusId":null,"userId":null,"ipAddress":null,"isIncomplete":false,"isSpam":false,"spamReason":null,"notification":null,"validateCurrentPageOnly":null,"tempId":null,"draftId":null,"revisionId":null,"uid":null,"siteSettingsId":null,"fieldLayoutId":null,"contentId":null,"enabled":true,"archived":false,"siteId":1,"title":null,"slug":null,"uri":null,"dateCreated":null,"dateUpdated":null,"dateDeleted":null,"trashed":false,"propagateAll":false,"newSiteIds":[],"resaving":false,"duplicateOf":null,"previewing":false,"hardDelete":false,"ref":null,"status":null,"structureId":null,"url":null,"voorEnAchternaam":"Dr. Georgianna Goyette","achternaam":"Debitis enim dolores mollitia tempore cumque est officia. Molestiae quam veniam cupiditate aut rerum perspiciatis nesciunt. Quia id odit quam.","eMailadres":"christelle.koepp@larkin.info","telefoonnummer1":"Velit assumenda iste dolorum et. Eos adipisci error animi non. Neque explicabo et molestias qui.","jouwBericht":"But she waited for some way of settling all difficulties, great or small. 'Off with her head!' about once in her pocket) till she shook the house, and the other side will make you grow taller, and.","bijlagenUploaden":[]},"form":{"settings":{"displayFormTitle":"","displayPageTabs":"","displayCurrentPageTitle":"","displayPageProgress":"","submitMethod":"page-reload","submitAction":"message","submitActionTab":null,"submitActionUrl":"","submitActionFormHide":"","submitActionMessage":"[{\"type\":\"paragraph\",\"content\":[{\"type\":\"text\",\"text\":\"Je bericht is verstuurd.\"}]}]","submitActionMessageTimeout":"","errorMessage":"[{\"type\":\"paragraph\",\"content\":[{\"type\":\"text\",\"text\":\"Controleer of alle velden juist zijn ingevuld.\"}]}]","loadingIndicator":"","loadingIndicatorText":"","validationOnSubmit":"1","validationOnFocus":"","submissionTitleFormat":"{timestamp}","collectIp":"","collectUser":"","storeData":null,"availabilityMessage":null,"availabilityMessageDate":null,"availabilityMessageSubmissions":null,"defaultLabelPosition":"verbb\\formie\\positions\\AboveInput","defaultInstructionsPosition":"verbb\\formie\\positions\\BelowInput","progressPosition":"end","defaultEmailTemplateId":""},"handle":"contact","oldHandle":null,"fieldContentTable":"{{%fmc_contact}}","templateId":null,"submitActionEntryId":null,"requireUser":"0","availability":"always","availabilityFrom":null,"availabilityTo":null,"availabilitySubmissions":null,"defaultStatusId":"1","dataRetention":"forever","dataRetentionValue":null,"userDeletedAction":"retain","fieldLayoutId":20,"id":736,"tempId":null,"draftId":null,"revisionId":null,"uid":"47e8fdf2-3a7e-4302-8476-cf4af4581c1e","siteSettingsId":736,"contentId":224,"enabled":true,"archived":false,"siteId":1,"title":"Contact","slug":null,"uri":null,"dateCreated":{"date":"2020-09-24 11:16:52.000000","timezone_type":3,"timezone":"Europe/Amsterdam"},"dateUpdated":{"date":"2020-09-30 14:03:47.000000","timezone_type":3,"timezone":"Europe/Amsterdam"},"dateDeleted":null,"trashed":false,"propagateAll":false,"newSiteIds":[],"resaving":false,"duplicateOf":null,"previewing":false,"hardDelete":false,"ref":null,"status":"enabled","structureId":null,"url":null}}}”. Response: “Success”
2020-09-30 15:39:48 [-][1][-][error][formie] integromat: API error: “Syntax error.” /Users/rickbergmans/Sites/frissewind/vendor/yiisoft/yii2/helpers/BaseJson.php:133
2020-09-30 15:39:46 [-][1][-][info][application] $_GET = [
    'p' => 'admin/actions/formie/integrations/form-settings'
]

$_POST = [
    'formId' => '736'
    'integration' => 'integromat'
]
Dahlhaus commented 3 years ago

@engram-design I added a webhook response to the webhook in Integromat and had the response send a JSON message back to Formie.

Now a get a correct message.

Contact_-_Frisse_Wind

Dahlhaus commented 3 years ago

Now the error 500 message is gone, but I still do not get anything on the webhook when using the form itself. Still only the test payload works.

Dahlhaus commented 3 years ago

Integration_Webhooks___Integromat

Dahlhaus commented 3 years ago

FYI when sending the data through the form on the front end of website itself, the webhook does not receive any data at all. Not even an incorrect payload.

engram-design commented 3 years ago

Also tested this out, and can confirm Integromat returns a string "Success" - but as it's not a JSON response, Formie's webhook will throw an error. But it does work correctly, as I get the Successfuly determined notice, that's its registered the payload in Integromat. Looks like your "Webhook Response" event can solve that.

Everything seems to be working correctly for me. I've setup a Webhook and connected it to an email, which emails me the submission ID. Once I hit "Run" and submit the form, the payload reaches the endpoint and sends me an email.

Screen Shot 2020-10-01 at 11 04 39 am

I imagine somewhere in Integromat you can have it so it's always listening, rather than having to hit "Run Once".

Dahlhaus commented 3 years ago

I still do not get it to run directly from the form. When I submit the form from Chrome, I cannot see any HTTP request (type XHR) in the network console. Can it be caused by something else? This is the URL. You can see for yourself. https://test-frissewind.mockus.nl/contact

engram-design commented 3 years ago

The webhook isn't triggered by JS, it's instead triggered by PHP in a queue job. You won't see anything on the front-end as a network request. I also can't see that URL, probably because I'm not allowed to?

For troubleshooting, I'd recommend disabling the queue handling, so you can see any potential errors as they appear. See https://verbb.io/craft-plugins/formie/docs/get-started/configuration and the useQueueForIntegrations setting

Dahlhaus commented 3 years ago

@rickbergmans is this something that can be done in the test environment of FW?

Dahlhaus commented 3 years ago

@engram-design thanks for the help!