I need help with a webhook to Zapier

Hi guys,
I am a little frustrated here and need some help. I have been trying to figure out how to write webhooks as I want to send database information via a webhook to Zapier and use the data for other services.

Is there anyone in the community who would want to help me out? I am based in New Zealand.

Thanks!
Mark

Hey
What kind of webhook are you looking for? You can see usage of that on wixshow.com in some courses or you can write here what you want to do.

  1. Send form submitted data to Zapier?

  2. Send already saved data from data collections to Zapier?

When data is submitted into a database via a custom form on wix i want to send that data via a webhook to zapier

Ok, set the import statement on top of your code

import {fetch} from 'wix-fetch';

and then if you have a button or whatever try this code and modify for your project, it’s working to send whatever you want to Zapier.

function sendButton_click(event,$w){
 //When the send button has been clicked we need to post the forms data to Zapier
 consturl="yourzapierwebhookaddresshere/";
 letfrom=$w("#from").value;
 letto=$w("#to").value;
 letsubject=$w("#subject").value;
 letmessage=$w("#message").value;
 letdata={"from":from,"to":to,"subject":subject,"message":message};
 console.log(data);
 varbodyData=JSON.stringify(data);
 
 fetch(url,{method:'post',body:bodyData})
    .then((httpResponse)=>{
 if(httpResponse.ok){
 returnhttpResponse.json();
        }else{
 returnPromise.reject("Fetchdidnotsucceed");
        }
    })
    .then(json=>{
 console.log(JSON.stringify(json));
 $w("#sendButton").disable();
 $w("#sendButton").label="Thanks for submitting the data!";
    })
    .catch(err=>console.log(err));
}

Hmmmmmm I really don’t know what I am doing…I dont know what to edit or where to place the code haha. Wix should give you a comission for every time you help someone though!

Hi Andreas, I did your ‘send data to google sheets course’ and wrote the below code:

//In this codesample we will post data from Wix Code to a Google Sheet

import {fetch} from ‘wix-fetch’;
//We need this to use the fetch command

export function button1_click(event,$w){
//When the send button has been clicked we need to post the forms data to Zapier
const url = “https://hooks.zapier.com/hooks/catch/2560455/ady1ss/”;

let firstName = $w(“#firstName”).value;
let lastName = $w(“#lastName”).value;
let contactEmail = $w(“#contactEmail”).value;
let contactCompany =$w (“#contactCompany”).value;
let contactNumber = $w(“#contactNumber”).value;
let contactStaffN = $w(“#contactStaffN”).value;
let contactComments = $w(“#contactComments”).value;
let data = {
“firstName”:firstName,
“lastName”:lastName,
“contactEmail”:contactEmail,
“contactCompany”:contactCompany,
“contactNumber”:contactNumber,
“contactStaffN”:contactStaffN,
“contactComments”:contactComments
};
console.log(data);
varbodyData=JSON.stringify(data);

fetch (url,{method:'post',body:bodyData}) 
.then((httpResponse)=>{ 
    if(httpResponse.ok){ 
        returnhttpResponse.json(); 
    }else{ 
        returnPromise.reject("Fetchdidnotsucceed"); 
    } 
}) 
.then(json=>{ 
    console.log(JSON.stringify(json)); 
    $w("#button1").disable(); 
    $w("#button1").label="Thanks for submitting the data!"; 
}) 
.catch(err=>console.log(err)); 

}

I keep getting error messages from Wix though so could you or someone else be able to point out what I am doing wrong! Thanks :slight_smile:

My bad here, typo varbodyData=JSON.stringify(data); needs to be var bodyData=JSON.stringify(data);

Wow two replies on your course and here! Wix, take note of Andreas’s customer service.

I am the same guy who wrote on your ‘send data to google sheets’ course :slight_smile: so maybe we just stick to one source on your course comment thread otherwise we might get confused!

Hey Andreas,
I tried using the above code for my custom form. But zapier cannot find the hook from my website.
Can you help me?