This package makes it easy to send notifications via AfricasTalking with Laravel

v2.4.1 2020-10-13 05:54 UTC

This package is auto-updated.

Last update: 2022-09-18 11:09:19 UTC


Latest Version on Packagist Software License StyleCI Quality Score Total Downloads

This package makes it easy to send notifications using AfricasTalking with Laravel.



This package is part of the Laravel Notification Channels project. It provides additional Laravel Notification channels to the ones given by Laravel itself.

The AfricasTalking channel makes it possible to send out Laravel notifications as a SMS using AfricasTalking API.


You can install this package via composer:

composer require laravel-notification-channels/africastalking

The service provider gets loaded automatically.

Setting up the AfricasTalking service

You will need to Register and then go to your sandbox app Go To SandBox App. Click on settings Within this page, you will generate your Username and key. Place them inside your .env file. Remember to add your Sender ID that you will be using to send the messages.


To load them, add this to your config/services.php . This will load the AfricasTalking data from the .env file.file:

'africastalking' => [
    'username'      => env('AT_USERNAME'),
    'key'           => env('AT_KEY'),
    'from'          => env('AT_FROM'),

Add the routeNotifcationForAfricasTalking method on your notifiable Model. If this is not added, the phone_number field will be automatically used.


namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
    use Notifiable;

     * Route notifications for the Africas Talking channel.
     * @param  \Illuminate\Notifications\Notification  $notification
     * @return string
    public function routeNotificationForAfricasTalking($notification)
        return $this->phone;


To use this package, you need to create a notification class, like NewsWasPublished from the example below, in your Laravel application. Make sure to check out Laravel's documentation for this process.


use NotificationChannels\AfricasTalking\AfricasTalkingChannel;
use NotificationChannels\AfricasTalking\AfricasTalkingMessage;

class NewsWasPublished extends Notification

     * Get the notification's delivery channels.
     * @param  mixed  $notifiable
     * @return array
    public function via($notifiable)
        return [AfricasTalkingChannel::class];

    public function toAfricasTalking($notifiable)
		return (new AfricasTalkingMessage())
                    ->content('Your SMS message content');



$ composer test


If you discover any security-related issues, please email instead of using the issue tracker.


Please see CONTRIBUTING for details.



The MIT License (MIT). Please see License File for more information.

How do I say Thank you?

Leave a star and follow me on Twitter .