Developer
User guidesDeveloper websiteHelp centerLog in
  • Welcome!
  • Organisations structure
    • Datamart
    • Users and roles
  • User points
    • User identifiers
      • Networks IDs
        • Device-based Network IDs
          • Custom Device ID integration
          • ID5
          • First ID
        • User-based Network IDs
          • Custom User ID integration
          • UTIQ martechpass
      • Accounts
      • Emails
      • Device identifiers
    • User activities and events
    • Compartments
    • User profiles
    • User segments
    • Hyper point & Quarantine
  • Data model
    • Defining your schema
    • Computed fields
      • Concepts
      • Setup
      • Development
      • Examples
  • Data ingestion
    • Real time user tracking
      • Website tracking
      • Mobile apps tracking
      • Ads exposure tracking
      • AMP tracking
      • Conversions tracking
      • Email views and clicks
      • Tracking API
      • Event rules
      • Activity analyzers
    • Bulk processing
      • Imports
        • User activities import
        • User profiles import
        • User choices import
        • Segments import
      • Deletions
        • User identifiers deletion
        • Device points deletion
        • User points deletion
      • User identifiers association
      • Integration batch
    • Activities analytics
    • Data warehouse
      • Preliminary setup
        • BigQuery
      • Create data warehouse
  • Querying your data
    • OTQL queries
    • OTQL examples
    • GraphQL queries
    • UserPoint API
    • User activities
    • Activities analytics queries
      • API Quickstart
      • Dimensions and metrics
      • Use cases
    • Funnel API
  • Alerting
    • Alert configurations
  • Data visualisation
    • Quickstart
    • Dashboards
    • Sections and cards
    • Charts
    • Datasets and data sources
      • Using a data file data source
    • Transformations
    • Filters
    • Cookbook
    • Reference
  • Advanced usages
    • Audience segmentation
      • Audience features
      • Segment builders
      • Audience segment metrics
      • Audience segment feed
        • Building new feeds
        • Monitoring a feed
        • Curated Audiences (SDA)
      • Edge segments
      • Cohort-based Lookalike
    • Contextual targeting
      • Setup
      • Activation
        • Google Ad Manager
        • Xandr (through prebid.js)
      • API documentation
    • Exporting your data
      • Query Exports
      • Datamart replication
    • Data privacy compliance
      • User choices
      • Cleaning rules
      • Exercise of user rights
      • Cookies
    • Campaigns
    • Automations
      • Email routers
      • Email renderers
      • Opt-in provider
      • Custom action plugins
      • Usage limits for automations
    • Plugins
      • Concepts
      • Creation & Deployment
      • Coding your plugin
      • Manage existing plugins
      • Layouts
      • Presets
      • Monitoring
      • Throttling
      • Batching (for external feeds)
    • Platform monitoring
      • Resources usage
        • Dimensions and metrics
      • Collection volumes
        • Dimensions and metrics
      • Events ingestion monitoring
        • Dimensions and metrics
    • Data Clean Room
      • Bunker
      • Clean room
  • Resources
    • Tutorial: Data Ingestion
      • Your first events
        • Add the mediarithmics tag
          • Getting the tag
          • Adding the tag
        • Send events using the tag
          • Adding event properties
          • Finding the UserEvent type in your schema
          • Matching your schema
          • Standard events
      • Your first bulk imports
        • API basics
          • Authentication
          • Your first API call
        • Send documents using the API
          • Requirements
          • Sending documents
    • Using our API
      • Authentication
    • Tools & libraries
      • mics CLI
      • JS Tag
      • Plugin SDK
    • Data cubes
      • Creating a report
      • Reference
Powered by GitBook
On this page
  • Endpoints to implement
  • Send an email to the router
  • Check email channel
  • Available outbound services
  • Retrieve the instance properties
  • Creating an email router plugin
  • Interfaces to implement
  • Debugging
  • Plugin logs and metrics

Was this helpful?

Export as PDF
  1. Advanced usages
  2. Automations

Email routers

PreviousAutomationsNextEmail renderers

Last updated 4 years ago

Was this helpful?

An email router plugin is a 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

If you're looking to customizing your emails, you should look at the plugin type.

Endpoints to implement

Email routers need to implement two endpoints.

Send an email to the router

POST myworker/v1/email_routing

This endpoint is called any time a user goes through a send email node in an automation.

Request Body

Name
Type
Description

data

object

PluginEmailData. See Email renderer.

content

object

PluginEmailContent. See Email renderer.

meta

object

PluginEmailMeta. See Email renderer.

user_identifiers

object

The available user identifiers for the user.

datamart_id

string

The ID of the datamart.

blast_id

string

The ID of the campaign blast.

campaign_id

string

The ID of the campaign.

creative_id

string

The ID of the email template.

context

string

The email call context. One of LIVE, STAGE or PREVIEW.

call_id

string

The email call ID.

email_router_id

string

The ID of the email router plugin instance. Used to retrieve the instance properties.

{
    "result": true
}
{
  "error": "..."
}

Check email channel

POST /v1/email_router_check

The endpoint is called before sending an email to do preliminary checks. In particular, to check if it is possible to send an email with the provided identifiers.

Request Body

Name
Type
Description

user_identifiers

object

The available user identifiers for the user.

email_router_id

string

The ID of the email router plugin instance. Used to retrieve the instance properties.

{
    "result": true
}
{
    "error": "..."
}

Available outbound services

Retrieve the instance properties

GET https://api.mediarithmics.com/v1/email_routers/:id/properties

Get the properties associated with the email router plugin instance.

Path Parameters

Name
Type
Description

id

string

ID of the email router plugin instance, typically theemail_router_id from the incoming request.

{
  "status": "ok",
  "data": [
    {
      "technical_name": "provider",
      "value": { "value": "mediarithmics" },
      "property_type": "STRING",
      "origin": "PLUGIN_STATIC",
      "writable": true,
      "deletable": false
    },
    {
      "technical_name": "name",
      "value": { "value": "Email router example" },
      "property_type": "STRING",
      "origin": "PLUGIN_STATIC",
      "writable": false,
      "deletable": false
    }
  ]
}

Creating an email router plugin

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.

We can provide you with a "Hello World" project using our SDK. Please contact your support in order to have access to it.

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.

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});
  }
}

Debugging

Plugin logs and metrics

See to learn why you should use the email_router_id parameter to retrieve the instance properties.

The code of the email router can call the following API endpoint to retrieve.

See the documentation to see .

Use our 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 .

The project structure and files work as .

You can monitor email router plugins.

plugin
complete documentation in the specific section.
email renderer
Plugin Instances
its instance context
plugins
how plugins are created and deployed
Plugin SDK
in the examples folder of the plugin SDK
with every other plugin
as you do with all plugins