# Intercom notifications channel for Laravel

Latest Version on Packagist (opens new window) Software License (opens new window) Build Status (opens new window) StyleCI (opens new window) Quality Score (opens new window) Code Coverage (opens new window) Total Downloads (opens new window)

This package makes it easy to send notifications using Intercom (opens new window) with Laravel.

# Contents

# Installation

You can install the package via composer:

composer require laravel-notification-channels/intercom

# Setting up the Intercom service

Add 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 NotificationChannels\Intercom\IntercomChannel;
use NotificationChannels\Intercom\IntercomMessage;
use Illuminate\Notifications\Notification;

class TestNotification extends Notification
{
    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 (opens new window)

# Changelog

Please see CHANGELOG (opens new window) 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 (opens new window) for details.

# Credits

# License

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