Skip to content
This repository has been archived by the owner on Sep 27, 2019. It is now read-only.

Submit pull requests here for new notification channels

License

Notifications You must be signed in to change notification settings

ftw-soft/intercom-notification-channel

 
 

Repository files navigation

Intercom notifications channel for Laravel

Latest Version on Packagist Software License Build Status StyleCI Quality Score Code Coverage Total Downloads

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

Abandoned

Current project is abandoned now. Please use official release now from laravel-notification-channels/intercom

How to migrate?

  • Update your composer.json: change "ftw-soft/intercom-notification-channel": "*" to "laravel-notification-channels/intercom": "^1.0"
  • Run $ composer update within your project directory
  • Replace all references of FtwSoft\NotificationChannels to NotificationChannels accross all of your project
  • ...
  • Profit!

Contents

Installation

You can install the package via composer:

composer require ftw-soft/intercom-notification-channel

Setting up the Intercom service

Once installed you need to register the service provider with the application. Open up config/app.php and find the providers key.

'providers' => [

    \FtwSoft\NotificationChannels\Intercom\IntercomServiceProvider::class,

]

Put the followings to your config/services.php

'intercom' => [
    'token' => env('INTERCOM_API_KEY')
]

Add your Intercom Token to .env

INTERCOM_API_KEY=xxx

Usage

Now you can use the channel in your via() method inside the notification:

use FtwSoft\NotificationChannels\Intercom\Contracts\IntercomNotification;
use FtwSoft\NotificationChannels\Intercom\IntercomChannel;
use FtwSoft\NotificationChannels\Intercom\IntercomMessage;
use Illuminate\Notifications\Notification;

class TestNotification extends Notification implements IntercomNotification
{
    public function via($notifiable)
    {
        return ["intercom"];
    }

    public function toIntercom($notifiable): IntercomMessage
    {
        return IntercomMessage::create("Hey User!")
            ->from(123)
            ->toUserId(321);
    }
}

Available methods

  • body(''): Accepts a string value for the Intercom message body
  • email(): Accepts a string value for the Intercom message type email
  • inapp(): Accepts a string value for the Intercom message type inapp (default)
  • subject(''): Accepts a string value for the Intercom message body (using with email type)
  • plain(): Accepts a string value for the Intercom message plain template
  • personal(): Accepts a string value for the Intercom message personal template
  • from('123'): Accepts a string value of the admin's id (sender)
  • to(['type' => 'user', 'id' => '321']): Accepts an array value for the recipient data
  • toUserId(''): Accepts a string value for the Intercom message user by id recipient
  • toUserEmail(''): Accepts a string value for the Intercom message user by email recipient
  • toContactId(''): Accepts a string value for the Intercom message contact by id recipient

More info about fields read in Intercom API Reference

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email android991@gmail.com instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

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