Hi,
I’m looking to automatically forward new Wix Form submissions to a Discord webhook. How could I do that?
Thanks
Hi,
I’m looking to automatically forward new Wix Form submissions to a Discord webhook. How could I do that?
Thanks
You can access third-part services using Fetch API as it is instructed here: https://support.wix.com/en/article/corvid-accessing-third-party-services-with-the-fetch-api
You may also use information from this forum post with a similar question: https://www.wix.com/corvid/forum/community-discussion/send-form-input-to-external-crm
Like Angelina said, use Fetch to send the data to the external API.
If your Wix Form is storing data and is linked to a database then you can use the After Insert Hook to push the data.
https://www.wix.com/corvid/reference/wix-data.Hooks.html#afterInsert
@anhelinak Thanks! I don’t really know how that works though.
Discord gives me a webhook URL that needs a post in the form of application/json.
How can I make that work?
@webmasterq Can you give us the link of Discord’s Documentation? I can take a look at it and suggest the structure of the code.
@webmasterq Using the above documentation I was able to create a webhook to send a message to a channel in Discord.
First of all I had to create a webhook for the channel as shown in the screenshot below.
Doing this gives me the Webhook endpoint which I have to use in my code.
I created a .jsw file on my site’s backend called discordApi.jsw with the following code
import {fetch} from 'wix-fetch';
export async function retrieve(actualContent) {
let cart = JSON.stringify(actualContent);
const response = await fetch("https://discordapp.com/api/webhooks/{webhook.id}/{token}", {
method: 'post',
headers: {
"Content-Type": "application/json"
},
body: cart
});
return response.json();
}
Notice that in the above code I am sending the body from the frontend.
On my page I call this function using the below code.
import {retrieve} from 'backend/discordApi.jsw';
$w.onReady(function () {
let actualContent = {
content: 'Sending this message from a webhook! Woop Woop!'
};
retrieve(actualContent)
.then( (response) => {
console.log(response);
});
});
I got the body parameters from the documentation link that you posted. You will need to study it in order to make it work the way you want it to.
When I opened the page, the following message was posted on my channel using the webhook.
Now this is an example of how you can use the webhook and also the structure of the code.
I’ve been dealing with a peculiar issue on the After InserthHook, I have a form that seems to be linked to the database (submissions from the form add data to the database) but the hook only fires when I insert directly to the database from the Wix Editor. Bit more info here:
"Integrating Wix Forms with a webhook is a smart move! It adds versatility and automation to your website
hi webmasterq
You can use Wix Automations for that. You can easily create an automation which triggers once a form ist submitted. Then you can add a webhook as the reaction to the trigger, as shown in the image below. You can even decide which Fields of the form are sent to the webhook.
Sorry it’s in German, but I think you’ll get it.
My problem is that with the above send via webhook. it doesn’t send any of the fields in the payload. Just a blank request
I agree with you, have been dealing with this over the past month. I have set up the Discord Webhook using this Wix automation tool, and it still does not work. WHY WIX? WHY??
I have resorted to use Zapier to help me get this done. But why do I need to spend extra money for what Wix is telling me is included in what I am already paying Wix for?
Am very frustrated with this Wix Automation WebHook Tool not working at all.
Have too been dealing with this over the past month. I have set up the Discord Webhook using this Wix automation tool, and it still does not work. WHY WIX? WHY??
I have resorted to use Zapier to help me get this done. But why do I need to spend extra money for what Wix is telling me is included in what I am already paying Wix for?
Am very frustrated with this Wix Automation WebHook Tool not working at all.