Hertz::Courier::Intercom
THIS GEM HAS BEEN DEPRECATED. YOU SHOULD NOT REALLY USE INTERCOM TO SEND OUT EMAIL NOTIFICATIONS LIKE THIS.
This is a Hertz courier for sending notifications to your users as Intercom conversations.
Installation
Add this line to your application's Gemfile:
gem 'hertz-courier-intercom'
And then execute:
$ bundle
Or install it yourself as:
$ gem install hertz-courier-intercom
Then, run the installer generator:
$ rails g hertz:courier:intercom:install
You will also need to expose the hertz_intercom_id
method in your receiver
class:
class User < ActiveRecord::Base
include Hertz::Notifiable
def hertz_intercom_id
id
end
end
If #hertz_intercom_id
returns an empty value (i.e. false
, nil
or an
empty string) at the time the job is executed, the notification will not be
delivered. This allows you to programmatically enable/disable email
notifications for a user:
class User
include Hertz::Notifiable
def hertz_intercom_id
id if send_through_intercom?
end
end
Usage
In order to use this courier, add :intercom
to deliver_by
in the
notification model(s):
class CommentNotification < Hertz::Notification
deliver_by :intercom
end
Now, add the intercom_subject
and intercom_body
methods in your notification
class:
class CommentNotification < Hertz::Notification
def intercom_subject
'You have a new comment!'
end
def intercom_body
'Hey man, you got a new comment waiting for you!'
end
end
NOTE: This courier uses the deliveries API to prevent double deliveries.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/alessandro1997/hertz-courier-intercom.
License
The gem is available as open source under the terms of the MIT License.
To do
- Allow changing the job's queue