Extra Horizon
GitHub
  • Extra Horizon Documentation
  • Getting Started
    • Start familiarizing yourself
  • Tutorials
    • Medical Device Tutorial
      • Preparation
      • Build your first prototype
        • Define a data model
        • Configure your workflows
          • Workflow 1: Analyze a measurement
          • Workflow 2: Create & store a PDF report
          • Workflow 3: Send an e-mail
        • Define your permissions
          • Update your schema with user permissions
          • Update your schema with group permissions
        • Build the Front-End
          • Set up oAuth in your backend
          • Demo login page
      • Summary & Wrap up
    • Polysomnography (PSG) Tutorial
    • Retool - Building dashboards Tutorial
  • FAQ
    • General
  • Services
    • Identity and Access Management
      • User service
        • Users
        • Groups
        • Global roles
        • Configuration
      • Auth Service
        • Applications
        • OAuth2
        • OAuth1
        • MFA
        • OpenID Connect
          • Google Cloud
          • Azure ADFS
    • Data Management
      • File Service
      • Data Service
        • Schemas
        • Documents
        • FAQ Data Service
    • Automation
      • Task Service
        • Functions
        • Tasks
        • API Functions
        • Examples
          • Hello world (JS)
          • Hello world (Py)
          • Hello world (Docker)
        • FAQ
      • Dispatchers Service
      • Event Service
        • System Events
    • Communication
      • Notification Service
        • Notifications
        • Settings
      • Mail Service
    • Other
      • Localization Service
        • Language Codes
      • Template Service
        • Localizations
      • Payments Service
        • Subscriptions
        • Stripe
        • iOS App Store
      • Configurations Service
  • API Reference
    • OpenAPI Specifications
    • 📦Changelog
      • Per-service Changelog
    • Postman Reference Collection
  • Tools
    • SDK
    • CLI
    • Control Center
  • Additional Resources
    • Resource Query Language (RQL)
    • Handling Errors
    • GitHub
    • API interaction (Python)
    • Migration guide: Enabling verification request limiting
  • ExH Platform
    • 🙋Support
    • ⏱️Usage and Performance
    • 🔓Security
    • 🗺️Regions
    • ⚖️Cloud Subscription Agreement
    • 🇺🇸CFR 21 Part 11
Powered by GitBook
On this page
  • Create your first dispatcher
  • List Dispatchers
  • Update a Dispatcher
  • Dispatcher Properties
  • eventType
  • name
  • description
  • actions
  • tags

Was this helpful?

  1. Services
  2. Automation

Dispatchers Service

Whereas the Event Service is in charge of communicating the occurrence of specific types of events, the Dispatcher Service gives you the ability to act on them. Learn how to configure dispatchers.

Example use case

When a User object is removed in the User Service, the customer must guarantee that all personally identifiable information of the user disappears from all services. A dispatcher for the user_deleted Event type must therefore create a Task which eliminates the PII in, for example, the Data Service.

Create your first dispatcher

Dispatching an action based on an event is easy. First you need to choose the action type. The dispatcher service currently supports two types of actions (a mail and task action).

The Task Action contains the (optional) parameters for the Create a Task request to the Task Service:

await exh.dispatchers.create({
  eventType: 'my-event-type',
  name: 'my-unique-dispatcher-name',
  description: 'A Dispatcher that handles my-event-type',
  actions: [
    {
      type: 'task',
      name: 'my-unique-action-name'
      description: 'An Action that handles my-event-type',
      functionName: 'my-function-name',
      data: {
        customStringField: 'myStringHere',
        customNumberField: 42
      },
      startTimestamp: new Date(),
      tags: [
        'tag1',
        'tag2'
      ]
    }
  ],
  tags: [
    'tag1',
    'tag2'
  ]
});
  • name: The unique name of the Action. - (optional)

  • description: A brief description for the Action. - (optional)

  • functionName: The name of the Task Service Function to invoke.

  • data: The key-value pairs the Task Service Function expects as input. - (optional)

  • starTimestamp: The moment at which the Task is to be executed. If no time is specified, the Task will be immediately performed. - (optional)

  • tags: Descriptive keywords that are stored in the Task object. - (optional)

The dispatcher service will append the original event data as a property called event and pass it to the task service. Setting the event property yourself will be overridden.

The fixed components include the recipients of the email and the templateId which is needed to compose the email subject and body text fields.

await exh.dispatchers.create({
  eventType: 'my-event-type',
  name: 'my-unique-dispatcher-name',
  description: 'A Dispatcher that handles my-event-type',
  actions: [
    {
      type: 'mail',
      name: 'my-unique-action-name'
      description: 'An Action that handles my-event-type',
      recipients: {
        to: ["john.doe@example.com"],
        cc: ["jane.doe@example.com"],
        bcc: ["bcc@example.com"]
      },
      templateId: 'abcdef0123456789abcdef013456789ab'
    }
  ],
  tags: [
    'tag1',
    'tag2'
  ]
});
  • name: The unique name of the Action - (optional)

  • description: A brief description for the Action - (optional)

  • recipients: The recipients list of the mail, including to, cc and bcc

  • templateId: The id of the mail template to be consumed

The dispatcher service will add the original event data as a property called event and pass it tot the mail and template service.

Only template-based emails can be sent via the Dispatcher Service. You must create an email template before you can send an email via a dispatcher action.

Events can originate from any service and the dispatcher service will put listeners based on the dispatchers configured.

List Dispatchers

In order to list dispatchers a user is required to have the VIEW_DISPATCHERS permission.

const dispatchers = await exh.dispatchers.find();

Update a Dispatcher

In order to update a Dispatcher a user is required to have the UPDATE_DISPATCHERS permission.

await exh.dispatchers.update(
    dispatcherId, 
    {
        eventType: 'my-event-type',
        name: 'my-unique-dispatcher-name',
        description: 'A Dispatcher that handles my-event-type',
        "tags": [
          "tag1",
          "tag2"
        ]
    }
);

Dispatcher Properties

eventType

The type of event the Dispatcher will respond to e.g user_deleted

name

The unique name of the Dispatcher - (Optional)

description

A brief description for the Dispatcher - (Optional)

actions

The actions the Dispatcher shall execute

tags

A list of string identifiers that can be attached to a Dispatcher

When managing Dispatchers using the CLI EXH_CLI_MANAGED will be appended to the tags array

PreviousFAQNextEvent Service

Last updated 10 months ago

Was this helpful?

A Mail Action contains part of the parameters required for the Send an email request to the . These components are fixed for the email that must be send in response to the type of Event that is monitored by the Dispatcher. The variable parameters are derived from the content attribute of the captured Event object.

Mail Service