Integrate WhatsApp Business Api to a project

Hello Everybody! I’m more of a wix front end developer and not too familiar with how to use a webhook to call an external api
whatsapp has just opened its api to customize templates and use them in our projects, we just have to have a developer account on facebook create a new app and ready we can use its api with a web hook, the following video at minute 4:40 shows how to use a webhook for an app external to facebook but how can it be integrated into wix?

https://youtu.be/UvE5G2oTjdM

I also found an npm that can be used to call the whatsapp api but I’m not sure how to integrate it

https://www.npmjs.com/package/whatsapp-business

any advice would be a great help :clap:

Try asking this question on the Discord server. I know that a couple of developers there did this already using velo and providers like Twilio and MessageBird.

@blink Innovations Did you find a solution to this? I’m looking for the same! :wink:

Hi @blinkco16,

Great question! Integrating the WhatsApp Business API into a Wix project can be a bit tricky since Wix has some limitations when working with server-side code and webhooks directly. Here’s how you can approach it:

  1. Using Wix Velo (Wix Code):
    Wix Velo allows you to work with APIs and webhooks. You can use the fetch function in the backend to call the WhatsApp Business API.
  • Set up your Facebook Developer account and WhatsApp Business API as explained in the video.
  • Use Wix Velo to create backend functions for sending and receiving messages via the API.
  • For handling webhooks, you’ll need to create an HTTP function in Wix Velo to process incoming requests. Here’s Wix’s guide on handling webhooks.
  1. Using NPM Package:
    Wix doesn’t directly support npm packages, but you can use external server environments like AWS Lambda, Firebase Functions, or a Node.js server to utilize the whatsapp-business npm package. After setting up the server, you can connect it to your Wix site via APIs or HTTP requests.

If you need a simple approach, I’d recommend starting with Wix Velo’s built-in fetch function to integrate the API without relying on external servers. For webhooks, ensure you have a clear endpoint that Wix can listen to.