How To

Last updated: November 12th, 2021

Requirements

The email automation tool is designed to allow you to send emails using Kentico's email templates and mailing system. A few modules are needed to set up the email automation completely.

  • JDep API (jdep_api)
  • Kentico API (kentico)
  • Email Automation (email_automation)

Installation

Install the modules mentioned in the requirements section. This can be done via the Drupal UI by going to the Extend page and checking each module in the form and then clicking Install. Alternatively, the modules can be installed via Drush through the following commands:

$ drush en jdep_api;
$ drush en kentico;
$ drush en email_automation;

There are a few configuration changes that need to be made in order to get the modules working correctly. There are forms available to make these changes but the default configurations may work depending on which environment you are utilizing.

Useful Tip:

If you experience issues after installing one (or more) of the modules, running drush cr normally fixes routine problems.

Kentico

The Kentico API module was built to connect Drupal sites to Kentico sites in order to utilize the built-in mailing functionality in Kentico including the mailer system and email templates. The configuration form to make these connections can be found at Configuration > Kentico API or by going to /admin/config/kentico.

The configuration is added by default when the module is installed. If it's outdated and you would like it to be updated for the next install, the install file named kentico.api.settings.yml located inside the kentico > config > install directory can be modified accordingly.

screenshot

The form is built so that it can store configuration sets for multiple environments. This format allows the user to store the values for all of the environments but switch between them without having to delete values that may be needed elsewhere.

There are two kinds of connections that are used in the Kentico configuration: Native API and RCM Web API.

The Native API is the API that is built into Kentico. There are a number of calls that can be utilized and found at https://www.rcmusic.com/rest/. The RCM Web API is a custom API built specifically for use with RCM and the available calls can be found at https://api-kentico.rcmusic.com/Help.

Select the environment from the Select active environment dropdown that you want to use and the Base URL, Username, and Password will be updated based on the values in the install file. Edit these values as needed.

Email Automation

The Email Automation module allows the user to map Drupal emails to the templates that are defined in the desired Kentico environment.

The module requires two tables: rcm_email_automation_mapping and rcm_email_automation_logging. Both tables need to exist but are not added when the module is installed (they were added via a different module at the time of creation). If the environment doesn't already have the tables they can added using the following queries:

Create the rcm_email_automation_mapping Table

This table maps the Drupal email name to the Kentico email template.

CREATE TABLE `rcm_email_automation_mapping` (
  `mappingid` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Auto-increment mapping ID.',
  `email` varchar(255) NOT NULL COMMENT 'Name of the email.',
  `template` varchar(255) NOT NULL COMMENT 'The template machine name.',
  `description` varchar(500) NOT NULL COMMENT 'What the email is used for.',
  PRIMARY KEY (`mappingid`)
) ENGINE=InnoDB AUTO_INCREMENT=99 DEFAULT CHARSET=utf8mb4 COMMENT='The mapping for Drupal emails to templates.';
Create the rcm_email_automation_logging Table

This table logs the email activity every time an email is attempted using the Email Automation module.

CREATE TABLE `rcm_email_automation_logging` (
  `logid` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Auto-increment logging ID.',
  `email` varchar(255) NOT NULL COMMENT 'Name of the email.',
  `template` varchar(255) DEFAULT NULL COMMENT 'The template machine name.',
  `createddate` int(11) NOT NULL COMMENT 'The timestamp that the email was created.',
  `userid` int(11) NOT NULL COMMENT 'The ID of the user that created the email.',
  `email_values` longtext COMMENT 'JSON encoded values of the email (from, to, body, etc).',
  `sent` int(11) NOT NULL COMMENT 'Did the email send?',
  `fid_html` int(11) DEFAULT NULL COMMENT 'The ID of the file in the admin database from the file_managed table',
  `error` varchar(500) DEFAULT NULL COMMENT 'If applicable, the error for why an email didn''t send.',
  PRIMARY KEY (`logid`)
) ENGINE=InnoDB AUTO_INCREMENT=631753 DEFAULT CHARSET=utf8mb4 COMMENT='Log emails that are sent through the automated system.';

Note:

Although there is no further configuration that needs to be updated for the module to be usable, there is a form for further customization found at Configuration > Email Automation > Settings or by going to /admin/config/email-automation/settings.