PHPackages                             ankurk91/laravel-vonage-inbound-sms - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ankurk91/laravel-vonage-inbound-sms

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

ankurk91/laravel-vonage-inbound-sms
===================================

Handle Vonage Inbound SMS webhooks in Laravel php framework

1.3.0(1y ago)21.9k↓50%1MITPHPPHP ^8.2CI passing

Since May 20Pushed 10mo ago2 watchersCompare

[ Source](https://github.com/ankurk91/laravel-vonage-inbound-sms)[ Packagist](https://packagist.org/packages/ankurk91/laravel-vonage-inbound-sms)[ Docs](https://github.com/ankurk91/laravel-vonage-inbound-sms)[ RSS](/packages/ankurk91-laravel-vonage-inbound-sms/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (7)Versions (6)Used By (0)

Vonage Inbound SMS Webhooks Client for Laravel
==============================================

[](#vonage-inbound-sms-webhooks-client-for-laravel)

[![Packagist](https://camo.githubusercontent.com/3cb4aa0a2f24286bcbf83be168f8efe66daa8b7bf24e7e775d35bf6f90b34c0d/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f616e6b75726b39312f6c61726176656c2d766f6e6167652d696e626f756e642d736d73)](https://packagist.org/packages/ankurk91/laravel-vonage-inbound-sms)[![GitHub-tag](https://camo.githubusercontent.com/7f694d0be0343a5d265187ab50133ccfd8cef5d87a33fa7e271428eb31fb8926/68747470733a2f2f62616467656e2e6e65742f6769746875622f7461672f616e6b75726b39312f6c61726176656c2d766f6e6167652d696e626f756e642d736d73)](https://github.com/ankurk91/laravel-vonage-inbound-sms/tags)[![License](https://camo.githubusercontent.com/b2212d45c9d4919144c6d8b5aac4171b422e8fe9827a17b6b5d3bcbafdbcad7f/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f6c6963656e73652f616e6b75726b39312f6c61726176656c2d766f6e6167652d696e626f756e642d736d73)](LICENSE.txt)[![Downloads](https://camo.githubusercontent.com/f2f07075572ccf04e943dd9569811ca108c39d33f72e940e7bab173caab60286/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f64742f616e6b75726b39312f6c61726176656c2d766f6e6167652d696e626f756e642d736d73)](https://packagist.org/packages/ankurk91/laravel-vonage-inbound-sms/stats)[![GH-Actions](https://github.com/ankurk91/laravel-vonage-inbound-sms/workflows/tests/badge.svg)](https://github.com/ankurk91/laravel-vonage-inbound-sms/actions)[![codecov](https://camo.githubusercontent.com/17cfd8ebacb4072816bf714ba5d08f1d15464bcca4d91362787ca64966257167/68747470733a2f2f636f6465636f762e696f2f67682f616e6b75726b39312f6c61726176656c2d766f6e6167652d696e626f756e642d736d732f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/ankurk91/laravel-vonage-inbound-sms)

Handle [Vonage](https://developer.vonage.com/en/messaging/sms/guides/inbound-sms) inbound SMS webhooks in Laravel php framework.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require "ankurk91/laravel-vonage-inbound-sms"
```

The service provider will automatically register itself.

You must publish the config file with:

```
php artisan vendor:publish --provider="Ankurk91\Vonage\SMS\Inbound\VonageWebhooksServiceProvider"
```

Next, you must publish the migration with:

```
php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider" --tag="webhook-client-migrations"
```

After the migration has been published you can create the `webhook_calls` table by running the migrations:

```
php artisan migrate
```

Next, for routing, add this route (guest) to your `routes/web.php`

```
Route::vonageInboundSMS('webhooks/vonage/sms/inbound');
```

Behind the scenes this will register a `POST` route to a controller provided by this package. Next, you must add that route to the `except` array of your `VerifyCsrfToken` middleware:

```
protected $except = [
    '/webhooks/*',
];
```

It is recommended to set up a queue worker to precess the incoming webhooks.

Setup Vonage account
--------------------

[](#setup-vonage-account)

- Login to Vonage developer [dashboard](https://dashboard.nexmo.com/settings)
- Enter your webhook URL under "Inbound SMS webhooks".
- 💡 You can use [ngrok](https://ngrok.com/) for local development
- Copy the "Signature secret" and specify in your `.env` file like

```
VONAGE_WEBHOOK_SECRET=secret-key-here
```

- Select `HASH_MD5` as your Signature method
- Select `POST_JSON` as your Webhook format

> **Note**You may need to contact Vonage support in-order to make Message Signing work on your account.

### Troubleshoot

[](#troubleshoot)

When using ngrok during development, you must update your `APP_URL` to match with ngrok vanity URL, for example:

```
APP_URL=https://af59-111-93-41-42.ngrok-free.app
```

You must verify that your webhook URL is publicly accessible by visiting the URL on your terminal

```
curl -X POST https://af59-111-93-41-42.ngrok-free.app/webhooks/vonage/sms/inbound
```

Usage
-----

[](#usage)

There are 2 ways to handle incoming webhooks via this package.

### 1 - Handling webhook requests using jobs

[](#1---handling-webhook-requests-using-jobs)

If you want to do something when a specific event type comes in; you can define a job for that event. Here's an example of such job:

```
