Laravel Messages is a very simple demo app to show a Messages API integration with Laravel 7. It receives and responds to WhatsApp messages, sends Messages to a whitelisted number, and logs the incoming status events.
If you're new to Vonage, you can sign up for an account and get some free credit to get you started.
We've tried to keep things short and sweet!
- Clone this repo and run
composer install
(requires PHP 7.3+). - Copy
.env.example
to.env
, add your credentials to theNEXMO_*
fields at the bottom. - Run your application with
php artisan serve
. - If you're working locally, run ngrok to expose the port locally; copy the URL.
- On the Dashboard, go to the Messages API Sandbox, and whitelist your phone for WhatsApp.
- On the same page, configure the webhook URLs for incoming messages and status events:
- incoming messages should be
[url you copied earlier]/webhooks/inbound
- status webhooks should go to
[url you copied earlier]/webhooks/status
- incoming messages should be
You're all set!
Visit [url of project]/messages
and enter the number of the whitelisted phone (in E163 format, e.g. 447770007777. You should get a WhatsApp message.
We love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either:
- Open an issue on this repository.
- Before you start contributing, check out the Code of Conduct.
- Tweet at us! We're @VonageDev on Twitter
- Or join the Nexmo Community Slack
For Laravel users using the Vonage Laravel facades (laravel/nexmo-notification-channel
& nexmo/laravel
for SMS notifications and setting up laravel Whatsapp API
- Use
env
values stored inconfig/nexmo.php
and- Replace
NEXMO_API_KEY
,NEMXO_API_SECRET
inroutes/web.php
withNEXMO_KEY
,NEXMO_SECRET
referenced inconfig/nexmo.php
or you can customize
- Replace
- Check out the Developer Documentation at https://developer.nexmo.com