A simple Laravel web application that shows how to send and receive SMS using Nexmo.
A simple Laravel web application that shows how to send and receive SMS using Nexmo.
For a more up-to-date version with WhatsApp and Laravel 7, try this: https://github.com/nexmo-community/laravel-messages
Clone the repo:
git clone [email protected]:nexmo-community/laravel-sms.git
cd laravel-sms
Add configuration information to .env
:
...
NEXMO_API_KEY=YOUR_KEY
NEXMO_API_SECRET=YOUR_SECRET
NEXMO_NUMBER=YOUR_NUMBER
Set your application key to a random string:
php artisan key:generate
Start the Laravel application:
php artisan serve
Start ngrok:
ngrok http 8000
Link your Nexmo phone number to the /sms/receive
webhook endpoint. Replace YOUR_NUMBER
with your Nexmo registered number and NGROK_SUBDOMAIN
with the subdomain assigned to you by ngrok in the previous command:
nexmo link:sms YOUR_NUMBER https://NGROK_SUBDOMAIN.ngrok.io/sms/receive
Navigate to http://localhost:8000/sms/send/NUMBER
replacing NUMBER
with a real number in order to send an SMS to that number.
Send an SMS to the Nexmo registered YOUR_NUMBER
in order to send a message to the Laravel application and get an auto-reply.
For detailed instructions please see the tutorial.
Published on Laravel News: https://laravel-news.com/sending-receiving-sms-laravel-nexmo