Email routers
An email router plugin is a plugin that can be associated to a send email node in an automation, allowing you to manage the connection with an external email router.
If you don't know what a plugin is, you can find complete documentation in the specific section.
If you're looking to customizing your emails, you should look at the email renderer plugin type.

Endpoints to implement

Email routers need to implement two endpoints.
post
myworker
/v1/email_routing
Send an email to the router
See Plugin Instances to learn why you should use the email_router_id parameter to retrieve the instance properties.
post
/v1/email_router_check
Check email channel

Available outbound services

The code of the email router can call the following API endpoint to retrieve its instance context.
get
https://api.mediarithmics.com
/v1/email_routers/:id/properties
Retrieve the instance properties

Creating an email router plugin

See the plugins documentation to see how plugins are created and deployed.
An email router plugin has the EMAIL_ROUTER plugin type. Its group id should be {domain.organisation.email-router} (for example com.mediarithmics.email-router).
Its artifact id should be the name of the email router plugin, i.e. example-email-router.
Use our Plugin SDK to create your email router plugin in Node.js: the required routes are already defined and you only have to override specific functions.
You can find a sample email router plugin in the examples folder of the plugin SDK.
We can provide you with a "Hello World" project using our SDK. Please contact your support in order to have access to it.
The project structure and files work as with every other plugin.

Interfaces to implement

Your should extend EmailRouterPlugin class and implement the onEmailRouting and onEmailCheck functions from the plugin SDK.
The onEmailRouting function is called every time a user runs through a send email node in an automation. It is responsible for sending the email.
Don't forget to catch your errors. You should log / respond with the appropriate message to facilitate debugging.
1
import { core } from '@mediarithmics/plugins-nodejs-sdk';
2
3
export class MyEmailRouterPlugin extends core.EmailRouterPlugin {
4
constructor() {
5
super();
6
}
7
8
protected async onEmailRouting(
9
request: core.EmailRoutingRequest,
10
instanceContext: core.EmailRouterBaseInstanceContext
11
): Promise<core.EmailRoutingPluginResponse> {
12
const identifier = request.user_identifiers.find(identifier => {
13
return (
14
identifier.type === 'USER_EMAIL' &&
15
!!(identifier as core.UserEmailIdentifierInfo).email
16
);
17
}) as core.UserEmailIdentifierInfo;
18
19
if (!identifier) {
20
throw Error('No clear email identifiers were provided');
21
}
22
23
const payload = this.buildMyEmailRouterPayload(
24
request.creative_id,
25
identifier.hash
26
);
27
28
await this.sendToMyEmailRouter(payload);
29
return { result: true };
30
}
31
32
protected async onEmailCheck(
33
request: core.CheckEmailsRequest,
34
instanceContext: core.EmailRouterBaseInstanceContext
35
): Promise<core.CheckEmailsPluginResponse> {
36
// If your router does not have a route to check its status, you can use this
37
return Promise.resolve({result: true});
38
}
39
}
Copied!

Debugging

Plugin logs and metrics

You can monitor email router plugins as you do with all plugins.