FlowRunner (flow_runner v6.15.1)

Copy Markdown

Provides functions to run a Flow.

Summary

Functions

Compile takes a json flow and returns a parsed and validated flow as a tuple.

Compile takes a json flow and returns a parsed and validated flow.

Get the default language for a flow.

Expression evaluation options for a context.

Fetches a flow from a container with the given UUID

Find the next block the current context is expecting. Returns both the current block and the next block

Get the language struct for a context

Functions

blocks_module()

compile(json)

Compile takes a json flow and returns a parsed and validated flow as a tuple.

compile(blocks_module, json)

See FlowRunner.Compile.compile/2.

compile!(json)

Compile takes a json flow and returns a parsed and validated flow.

compile!(blocks_module, json)

See FlowRunner.Compile.compile!/2.

default_flow_language(flow)

@spec default_flow_language(FlowRunner.Spec.Flow.t()) :: FlowRunner.Spec.Language.t()

Get the default language for a flow.

The flowspec is unclear about how to go about this. Our assumption is that the first language defined in the list of a flow's languages is the default language.

The flowspec does guarantee that there must be at least 1 language.

expression_callbacks_module()

expression_opts(vars)

@spec expression_opts(FlowRunner.Context.t() | map()) :: Keyword.t()

Expression evaluation options for a context.

The expression-language mode is stamped into context.private by the consumer (engage stamps it per journey); a missing stamp degrades safely to :v2, and a bare vars map (accepted for backwards compatibility) likewise evaluates under :v2.

fetch_flow_by_uuid(container, uuid)

Fetches a flow from a container with the given UUID

fetch_resource_by_uuid(container, uuid)

See FlowRunner.Spec.Container.fetch_resource_by_uuid/2.

fetch_resource_value(resource, language, mode, flow)

find_next_block(container, flow, context, user_input)

@spec find_next_block(
  FlowRunner.Spec.Container.t(),
  FlowRunner.Spec.Flow.t(),
  FlowRunner.Context.t(),
  user_input :: String.t() | nil
) ::
  {:ok, FlowRunner.Context.t(),
   previous_block :: FlowRunner.Spec.Block.t() | nil,
   next_block :: FlowRunner.Spec.Block.t() | nil}
  | {:error, reason :: String.t()}

Find the next block the current context is expecting. Returns both the current block and the next block

language_for_context(flow, context)

Get the language struct for a context

The FlowRunner.Context stores the language as an iso-639-3 language code ("eng"/"afr" etc). Internally flowspec maintains a list of languages which have a UUID as an id.

Here we lookup the language struct for the language code currently active in the context. This is needed because the Flowspec resource values refer to languages by the Language's ID (uuid) rather than the iso-639-3 code.