Flow Fundamentals

Flows represent a collection of actions ("Blocks") and the decision-making logic that links Blocks together into a flowchart-like description of an interactive mobile service, business process, or anything else that can be modeled as programmatic flow-chart.

Contents

Format

Containers and Flow Definitions are a set of nested key-value objects formatted in JSON, version ECMA-404.

Data Formats

Throughout the specification, the terms "string", "object", and "array" refer to the corresponding entities in the JSON specification. An "expression" is a string conforming to the Expressions Specification.

Resources

A Resource describes a collection of localized strings or media resources, used when content needs to be presented to Contacts in multiple languages. Resources have the following logical structure:

Resource {
  uuid: string,
  values: ResourceValue[]
}

ResourceValue {
  language_id: string (Language Identifier),
  content_type: SupportedContentType,
  mime_type: string,
  modes: SupportedMode[],
  value: string,
}

SupportedContentType {
  TEXT = 'TEXT',
  AUDIO = 'AUDIO',
  IMAGE = 'IMAGE',
  VIDEO = 'VIDEO',
}

SupportedMode {
  TEXT = 'TEXT',
  SMS = 'SMS',
  USSD = 'USSD',
  IVR = 'IVR',
  RICH_MESSAGING = 'RICH_MESSAGING',
  OFFLINE = 'OFFLINE',
}

for example,

{
   uuid: "c2dbafbd-e9bd-408f-aabc-25cf67040002",
   values: [
      {
         language_id: "eng",
         modes: ["SMS", "USSD"],
         content_type: "TEXT",
         mime_type: "text/plain",
         value: "Howdy! You've reached the Museum of Interoperability!"
      },
      {
         language_id: "eng",
         modes: ["RICH_MESSAGING"],
         content_type: "TEXT",
         mime_type: "text/plain",
         value: "Howdy! You've reached the Museum of Interoperability! This is a long message for you because we've gone beyond the limitations for 180 characters. I'm your guide, Florian. I hope you're excited for this two hour tour through the history of interoperable data systems."
      },
      {
         language_id: "eng",
         modes: ["RICH_MESSAGING"],
         content_type: "IMAGE",
         mime_type: "image/png",
         value: "https://your-server-somewhere.flowinteroperability.org/example-image.png"
      }
   ]
}

A resource may provide one or many values within it. This provides flexibility to use the same text or media for several modes, or to specify unique media or text in each mode.

The mime_type field should be provided for all values; when provided, this must be an IANA media type (RFC 6838).

The language_id must correspond to a Language Identifier described in the Flow's languages.

Language Objects and Identifiers

Flows describe a list of languages they have content for. Flows use the ISO 639-3 language coding to describe nearly all spoken and written languages. They also support multiple languages with the same ISO 639-3 code (referred to as language variants), to support use-cases where organizations might have distinct sets of content for the same language. A common example of variants could be "English - India" and "English - East Africa", or "English - Male voice" and "English - Female voice".

Language objects must have the following keys:

Language Identifiers

The recommended structure for Language Identifier strings is:

  • <iso_639_3>-<variant>, where the variant is not null.

  • <iso_639_3>, when the variant is null.

Language Example

languages: [
   {
      id: "eng-male",
      label: "English - Male Voice",
      iso_639_3: "eng",
      variant: "male",
      bcp_47: "en-US"
   },
   {
      id: "eng-female",
      label: "English - Female Voice",
      iso_639_3: "eng",
      variant: "female",
      bcp_47: "en-US"
   },
   {
      id: "mis-mysecretlanguage",
      label: "My secret code language",
      iso_639_3: "mis",
      variant: "mysecretlanguage",
      bcp_47: null
   },
   {
      id: "fre",
      label: "Francais",
      iso_639_3: "fre",
      variant: null,
      bcp_47: fr-FR
   }
]

UUID Format

The term "uuid" refers to a universally unique identifier. Implementations may use any UUID version from RFC4122 or Version 6 IDs. Platforms are recommended to use version 6 IDs for performance and compatibility. The hyphenated string representation of the UUID must be used within JSON documents, for instance:

"uuid":"2b375764-9fcc-11e7-abc4-cec278b6b50a"

Vendor Metadata

To enable extensions of the Specification, entities support the vendor_metadata optional field. This is intended for parameters that are not controlled by the Specification, but could be relevant to a specific vendor/platform/implementation. Vendors must use namespaces within vendor_metadata to avoid collisions. Suggested namespaces use reverse domain name notation, with periods replaced by underscores (e.g.: A vendor with domain https://my.example-flow-server.com would place entries within vendor_metadata.com_example-flow-server_my).

Top-level Specification Elements

Containers

A Container is a "package" document containing one or more Flow Definitions, useful for sharing multiple Flows in a single document. The required keys for a Container object are:

Example

{
   "specification_version": "1.0.0-rc1",
   "uuid": "95f29456-8a33-4d26-b22a-00b0b169056c",
   "name": "Summary Case Report Test",
   "description": "Summary Case Report Test",
   "vendor_metadata": {},
   "flows": [...]
}

Flows

A Flow represents a set of Blocks and their direct connections. The required keys for a Flow are:

Modes

Possible modes for supported_modes are:

  • TEXT: general text-based interactions. This includes SMS and USSD channels, which may have distinct behaviour while sharing the same content.

  • SMS: content specific for SMS

  • USSD: content specific for USSD

  • IVR: content specific for interactive voice response

  • RICH_MESSAGING: content used for data channels that support multimedia including text, audio, images, and video, such as social network chatbots (Facebook Messenger, WhatsApp, Twitter, Telegram, etc.)

  • OFFLINE: content used for mobile apps designed to run offline without a data connection.

Flow Example

{
   "uuid": "06c912aa-0d36-4d9c-b144-0cd3a38e8293",
   "name": "Summary Case Report Test",
   "label": "Summary Case Report Test for mHero Applications",
   "last_modified": "2021-02-05 18:55:59.229Z",
   "interaction_timeout": 172800,
   "first_block_id": "08509fdf-2cd2-43a8-9627-011254d30aa7",
   "supported_modes": [
      "SMS",
      "USSD",
      "RICH_MESSAGING"
   ],
   "languages": [
      {
         "id": "eng",
         "label": "English",
         "iso_639_3": "eng",
         "variant": null,
         "bcp_47": "en-UK"
      }
   ],
   "vendor_metadata": {},
   "blocks": [...],
   "resources": {...}
}

Blocks

The required keys for a Block are:

Exit node specification

Each exit node in exits must contain:

Each exit must specify one of either test or default. Each block must have exactly one default exit. The default exit is listed last in the list.

Setting Contact Properties

A common use-case for platforms that run flows on Contacts is to modify the Contact's properties based on the interactions within a flow. To simplify this use-case, all blocks have a standard capability to specify how a contact's properties should be updated. This update shall happen immediately prior to following the exit node out of the block. This is specified via the optional set_contact_property array within the Block config:

config {
   ...,
   set_contact_property: [
      {
         property_key: <string>
         property_value: <Expression>
      },
      {
         property_key: <string>
         property_value: <Expression>
      },
      ...
   ]
}

The property_key is a string attribute within the context of the Contact, and is not further restricted by this specification. For complete block interoperability across vendors, vendors would need to agree on the format and identity of property_key. (e.g. property_key could be "gender" , or it could be a UUID referenced to an external taxonomy service.)

Block Example

{
   "uuid": "0a0da5ab-66bc-4cd5-94c1-1e97f1875ee0",
   "vendor_metadata": {},
   "type": "MobilePrimitives.OpenResponse",
   "name": "patient_id",
   "label": "Patient ID",
   "semantic_label": "VMO::Person::Patient::ID",
   "exits": [
      {
         "uuid": "3b5c4568-6f8e-43d8-9c23-e0f444c9fd26",
         "name": "Default",
         "default": true,
         "config": {},
         "destination_block": "80a8a17e-2438-454b-b2f0-4b64fd06d700"
      }
   ],
   "config": {
      "prompt": "d99f9833-ace6-4f7f-957e-0a516e3dbb47"
      "set_contact_property": [
         {
            "property_key": "gender"
            "property_value": "block.value"
         }
      ]
   }
}

Last updated