Laravel 12 WhatsApp Twilio Integration Example


In this tutorial Laravel 12 How to Send WhatsApp message using Twilio, I will show you how to send whatsapp messages using twilio api in laravel 12 application. In this example, I’m only showing how to send a simple text message with emojis using WhatsApp. But you can also use the same method to send pictures, documents, or other media if needed.
Twilio is a cloud-based communication platform that enables developers to integrate video, messaging, voice, and email capabilities into their applications. With support for multiple programming languages and a highly scalable infrastructure, Twilio simplifies the process of building real-time communication features such as SMS, phone calls, and two-factor authentication.
To begin integrating WhatsApp messaging in Laravel, you’ll first need to have a Laravel 12 project set up. Once your application is ready, the next step is to create a Twilio account, which will provide the necessary credentials for WhatsApp API access.
Steps for WhatsApp API integration in Laravel 12
Step 1: Set Up a New Laravel 12 Project
Step 2: Register Twilio Account
Step 3: Install the Twilio SDK via Composer
Step 4: Create a Controller
Step 5: Define a Route
Step 6: Create a Blade
Step 7: Run the Laravel Application
Step 1: Set Up a New Laravel 12 Project
If your project is already in place, you may skip this step. Use the command below to create a new Laravel project:
composer create-project laravel/laravel laravel-send-whatsapp-message-using-twilio
Step 2: Register Twilio Account
Create an account on Twilio.com. After registering, you’ll be able to access your Account SID, Auth Token, and Twilio WhatsApp-enabled number. Refer to the images below for guidance.
Follow These Steps to Set Up Your Twilio Account:
Create an Account inside Twilio
Credentials
From your Twilio Console Dashboard, you will get the following details:
Account SID
Auth Token
Twilio Phone Number
Step 3: Install the Twilio SDK via Composer
Now, switch to your Laravel project directory and install the Twilio SDK:
cd laravel-send-whatsapp-message-using-twilio
composer require twilio/sdk
Copy the necessary credentials—Account SID, Auth Token, and WhatsApp number from your Twilio dashboard, and add them to your .env file as demonstrated in the code snippet below.
Step 4: Create a Controller
Now, let’s create a controller to handle the WhatsApp message sending logic using Twilio's API. This controller will include a method to send messages based on user input from the form.
TWILIO_SID="INSERT YOUR TWILIO SID HERE"
TWILIO_AUTH_TOKEN="INSERT YOUR TWILIO TOKEN HERE"
TWILIO_WHATSAPP_NUMBER="INSERT YOUR TWILIO WHATSAPP NUMBER IN [E.164] FORMAT eg.+14
We’ll also configure everything to make the process smooth and beginner-friendly.
📖 For complete code and detailed instructions, read the full blog post on my website:👉 https://itstuffsolutiotions.io/laravel-12-how-to-send-whatsapp-message-using-twilio/
Subscribe to my newsletter
Read articles from itstuffsolutiotions directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

itstuffsolutiotions
itstuffsolutiotions
Experienced Web Developer | Laravel | PHP | jQuery | HTML | CSS I’m a skilled web developer with extensive experience building dynamic and responsive web applications using Laravel, PHP, jQuery, HTML, and CSS. I specialize in creating clean, scalable, and maintainable code, with a focus on performance and user experience. Whether it's developing RESTful APIs, building custom CMS features, or crafting responsive front-ends, I bring a problem-solving mindset and a passion for quality to every project.