How to Send WhatsApp Messages from Wix Forms Using Zaple.ai
A clean, secure, and production-ready guide using Wix Velo.
Are you looking for a reliable way to instantly engage with your website visitors the moment they reach out?
If you're using Wix Forms V2 and want to automatically send a WhatsApp template message after a successful form submission, you're in the right place. In this guide, we'll walk you through a clean, secure, and production-friendly setup using Zaple.ai and Wix Velo.
By connecting your Wix form to Zaple.ai's powerful API, you can instantly follow up with leads, confirm event registrations, or send rich media like images and documents directly to their WhatsApp.
Let's dive into how to build this seamless frontend-to-backend integration.
Why Connect Wix Forms to WhatsApp?
In today's fast-paced digital world, email follow-ups often get lost in spam folders. WhatsApp, boasting a 98% open rate, ensures your message is seen instantly.
With this integration, you achieve:
- Instant Lead Engagement: Strike while the iron is hot by messaging users right after they submit an inquiry.
- Secure Architecture: Keep your API keys hidden on the backend using Wix Secrets Manager.
- Rich Media Support: Zaple's v3 API allows you to send stunning templates with image headers and dynamic variables seamlessly.
What We Are Building: The Integration Flow
- A visitor submits your Wix Forms V2 form.
- The
onSubmitSuccess()event fires on your webpage. - The script extracts the submitted details using
getFieldValues(). - The page securely passes this data to a Wix backend web method.
- The backend safely retrieves your Zaple credentials from the Wix Secrets Manager.
- A POST request triggers Zapleโs v3 template-message API.
- Your visitor instantly receives a personalized WhatsApp template message!
Prerequisites
Before we write any code, ensure you have the following ready:
- A published Wix site with Velo (Dev Mode) enabled.
- A Wix Forms V2 form embedded on a page.
- An active Zaple.ai account.
- An approved WhatsApp template in your Zaple dashboard.
- Your Zaple Template ID.
- A public image URL (if your template features a media header).
Step 1: Securely Store Your Zaple API Secrets in Wix
Never hardcode API keys in your frontend code. Using Wix Secrets Manager ensures your credentials stay secure.
Go to your Wix Dashboard → Settings → Secrets Manager and create these two secrets:
Zaple_API_KeyZaple_API_Secret
Step 2: Configure Your Wix Page Code (Frontend)
Open your Wix Editor, turn on Dev Mode, and select your form page. We need to attach logic to the form element to capture data only after a successful submission.
Add the following code to your page:
Pro Tip: We use onSubmitSuccess() because it only runs after the server has completely and successfully received the submission.
Step 3: Create the Secure Backend Web Module
To execute the API call securely, we must create a backend Web Module.
In your Wix Velo sidebar, under Backend, create a new file named zaple.web.js and paste this code:
โ ๏ธ A Common Backend Mistake
A frequent error is exporting a plain async function instead of a proper webMethod(). Current Wix Velo standards require you to use webMethod(Permissions.Anyone, async () => { ... }) for frontend-callable backend functions. If you forget this, the frontend import will fail.
Step 4: Map Your Wix Form Field IDs Exactly
Your script relies entirely on the precise field keys returned by $w("#form2").getFieldValues().
If your output looks like this:
You must ensure that your variables in Step 2 (submissionFields.first_name and submissionFields.whatsapp_number_1) exactly match the IDs in your Wix Form settings.
Step 5: Handling Media in WhatsApp Templates
If your approved WhatsApp template in Zaple has an image or document header, you must include the media fields in your payload:
Note: Ensure the URL used is publicly accessible and does not require authentication to view.
Step 6: Testing and Troubleshooting
Publish or preview your site, submit a test form, and monitor your Site Logs in the Wix dashboard.
What You Should See:
- Frontend Logs:
Form submission detected!→Name to send: ... - Backend Logs:
sendThankYouMessage called→Zaple payload: ...→Zaple raw response: 200 - Your Phone: A successful WhatsApp ping! ๐ฑ
Quick Troubleshooting Guide:
- Frontend logs are appearing, but no backend logs?
You likely exported a plain function instead ofwebMethod(...), or your import path is incorrect. Ensure your file is saved precisely asbackend/zaple.web.js. - Backend is running, but no WhatsApp message is received?
Check for invalid API Keys / Secrets, using the wrongtemplate_id, or an invalid phone number format. If you are passingcountry_code: "91", make suresend_toonly contains the 10-digit local number (e.g.,9099039992, not919099039992). - Dynamic Template Variables are blank?
If your template says "Hi {{1}}, thank you...", you must passbody_text1: firstNamein your Zaple payload. Check Zaple's template setup for exact variable indexing.
Final Thoughts
Integrating Wix Forms V2 with Zaple.ai is one of the most practical and impactful automations you can build for lead generation, event registration, and customer inquiries.
By leveraging Wix's backend capabilities and onSubmitSuccess(), you ensure your API credentials remain untouchable while delivering a rapid, personalized experience to your customers via WhatsApp.
Ready to Turbocharge Your WhatsApp Messaging?
Start building seamless customer journeys with WhatsApp Business API.
Frequently Asked Questions
Can I run this code without Wix Dev Mode (Velo)?
No. You need to enable Dev Mode in Wix to add custom Javascript and create the required backend Web Modules.
Why shouldn't I just make the API call from the page code?
Making the API call from the frontend exposes your private Zaple_API_Key and Zaple_API_Secret to the public. Anyone viewing your site's source code could steal your credentials and send messages on your behalf.
Do I need a paid Zaple account to do this?
You will need an active Zaple account configured with the WhatsApp Business API. Check Zaple.ai pricing for tier limits on template messages.
What if the user submits a messy phone number format?
The provided frontend code (String(rawPhone).replace(/\D/g, "")) automatically strips out spaces, dashes, and parentheses, leaving only clean digits before sending them to the backend.