This package makes it easy to log notifications to Hubspot Engagement with Laravel 5.5+, 6.x, 7.x and 8.x
You can install the package via composer:
composer require laravel-notification-channels/hubspot-engagement
Generate API Key from Hubspot.
Configure your Hubspot API on .env
HUBSPOT_API_KEY=XXXXXXXX
To publish the config file to config/newsletter.php run:
php artisan vendor:publish --provider="NotificationChannels\HubspotEngagement\HubspotEngagementServiceProvider"
This will publish a file hubspot.php in your config directory with the following contents:
// config/services.php
return [
'api_key' => env('HUBSPOT_API_KEY'),
/*
* Guzzle options
*/
'CLIENT_OPTIONS' => [
'HTTP_ERRORS' => true,
]
];
By setting http_errors to false, you will not receive any exceptions at all, but pure responses. For possible options, see here.
You can now use the channel in your via()
method inside the Notification class.
Currently is only supported Email type of Engagement.
Your Notification class must have toMail method. The package accepts: MailMessage lines notifications, MailMessage view notifications and Markdown mail notifications.
Data stored on Hubspot:
- Hubspot Contact Id => The Notifiable Model must have getHubspotContactId() function
- Send at timestamp
- from email
- from name
- subject
- html body
- to email
- cc emails
- bcc emails
use NotificationChannels\HubspotEngagement\HubspotEngagementChannel;
use Illuminate\Notifications\Notification;
class OrderConfirmation extends Notification
{
...
public function via($notifiable)
{
return ['mail', HubspotEngagementChannel::class]];
}
public function toMail($notifiable)
{
$message = (new MailMessage)
->subject(__('order.order_confirm', ['code' => $this->order->code]));
return $message->view(
'emails.order', [
'title' => __('order.order_confirm', ['code' => $this->order->code]),
'order' => $this->order
]
);
}
...
}
namespace App\Models;
class User extends Authenticatable{
...
public function getHubspotContactId(){
return $this->hubspot_contact_id;
}
...
}
Please see CHANGELOG for more information what has changed recently.
$ composer test
If you discover any security related issues, please email info@albertoperipolli.com instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.