If you use ActionMailer in your Ruby on Rails application and want to send emails through OneSignal's messaging platform, your life just got easier!  We are excited to announce our new Ruby on Rails plugin to ease the burden of integrating OneSignal in order to drive email engagement for transactional and marketing purposes.

The Ruby on Rails plugin provides a new ActionMailer custom delivery method  :onesignal that converts any new or existing mailers in your application to send emails through OneSignal.  The plugin also provides optional extensions that allow you to take full advantage of the OneSignal platform, such as specific audience targeting through segments, easier email composition using email templates, and delivery preference options.

Getting Started

Configure your OneSignal Application for Email Messaging

In order to send emails through OneSignal, you must create a OneSignal application and configure it for email messaging.  If you haven't done so, take a look at our quickstart guide to get through this process.

Add the OneSignal Plugin to Your Rails Application

Add the OneSignal Rails plugin to your application. Typically, you can achieve this by adding the gem into your Gemfile:

gem 'onesignal-rails-plugin', '~> 1.0.0'

and then executing bundle install to make the gem available for use.

Configure the OneSignal ActionMailer Delivery Method

In addition to specifying your :onesignal delivery method, you'll need to indicate which OneSignal application the OneSignal Rails plugin should target.  The plugin will also need authorization that's typically required to send emails via the REST API.

Edit config/application.app or config/environments/$ENVIRONMENT.rb and add or change the following to your ActionMailer configuration. Please visit our documentation to figure out your app ID and REST API key.

config.action_mailer.delivery_method = :onesignal
config.action_mailer.onesignal_settings = {
  app_key: "your-app-key",
  app_id: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
}

That's it!  These steps will help you configure ActionMailer to send your transactional emails via OneSignal.  Your OneSignal Dashboard will record the emails sent, and new users will be automatically added to OneSignal for subsequent segmentation and engagement!

If you want to go further and take advantage of the OneSignal-specific extensions, you'll need to modify each mailer's mail invocation to provide additional information.  A description of each of the extension points can be found in the documentation.

Reference

Visit the Ruby on Rails Plugin documentation for a complete overview of configuration options, supported extensions, and examples.

Share Your Feedback

If you’ve had a chance to use our new Ruby on Rails Plugin and have any feedback or suggestions you’d like to share, please reach out to us on our GitHub repository, or our Discord server.

If you encounter any bugs or technical issues while using our new .NET library, we want to know so we can help you resolve the issue. If you encounter issues, make sure to file a report on our GitHub repository.

If you’ve found the plugin helpful, we’d also appreciate it if you left us a review on G2.

View our Email Quickstart Guide