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.
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
get
https://api.mediarithmics.com
/v1/email_routers/:id/properties
Retrieve the instance properties
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.
We can provide you with a "Hello World" project using our SDK. Please contact your support in order to have access to it.
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.
import { core } from '@mediarithmics/plugins-nodejs-sdk';
export class MyEmailRouterPlugin extends core.EmailRouterPlugin {
constructor() {
super();
}
protected async onEmailRouting(
request: core.EmailRoutingRequest,
instanceContext: core.EmailRouterBaseInstanceContext
): Promise<core.EmailRoutingPluginResponse> {
const identifier = request.user_identifiers.find(identifier => {
return (
identifier.type === 'USER_EMAIL' &&
!!(identifier as core.UserEmailIdentifierInfo).email
);
}) as core.UserEmailIdentifierInfo;
if (!identifier) {
throw Error('No clear email identifiers were provided');
}
const payload = this.buildMyEmailRouterPayload(
request.creative_id,
identifier.hash
);
await this.sendToMyEmailRouter(payload);
return { result: true };
}
protected async onEmailCheck(
request: core.CheckEmailsRequest,
instanceContext: core.EmailRouterBaseInstanceContext
): Promise<core.CheckEmailsPluginResponse> {
// If your router does not have a route to check its status, you can use this
return Promise.resolve({result: true});
}
}
Last modified 2yr ago