FlowRunner.Simulator (flow_runner v6.15.1)

Copy Markdown

A simulator for interacting with the Flow Runner.

This is used for testing purposes and ca be used to build a simulator that the user can experiment with to test the service they are building.

Summary

Types

quick_reply_choice()

@type quick_reply_choice() :: %{
  name: String.t(),
  test: String.t(),
  prompt: String.t()
}

t()

@type t() :: %FlowRunner.Simulator{
  block: term(),
  callbacks_module: term(),
  container: term(),
  context: term(),
  flow: term(),
  history: term(),
  language: term(),
  last_user_input: term(),
  mode: term(),
  stacks: term(),
  user_inputs: term(),
  uuid: term()
}

Functions

fetch_resource_by_uuid!(sim, uuid)

fetch_resource_values(sim, resource, content_type, mime_type \\ nil)

generate_choices_for_dynamic_quick_replies(sim, choices)

@spec generate_choices_for_dynamic_quick_replies(t(), [quick_reply_choice()]) :: [
  FlowRunner.Simulator.Output.t()
]

Generate the list of options available for a dynamic quick reply block.

IMPORTANT: We use the button name as the values here.

generate_choices_for_static_quick_replies(sim, choices)

@spec generate_choices_for_static_quick_replies(t(), [quick_reply_choice()]) :: [
  FlowRunner.Simulator.Output.t()
]

Generate the list of options available for a static quick reply block.

IMPORTANT: We use the button labels as the values here.

get_vendor(vendor_metadata, key)

@spec get_vendor(map(), key :: String.t() | [String.t()]) :: term()

history(sim)

new(container, callbacks_module \\ Expression.Callbacks.Standard)

next(sim, user_input \\ nil, acc \\ [], recursion \\ 0)

@spec next(t(), String.t() | nil, list(), non_neg_integer()) ::
  {:end, t(), list()}
  | {:waiting, t(), list()}
  | {:error, t(), reason :: String.t()}

output(sim, map)

output_block(sim, output)

output_listreply_block(sim, map)

output_quickreply_block(sim, map)

resource_value_output(sim, map, event_value \\ nil)

start(sim, vars \\ %{}, language_code \\ "eng", mode \\ "RICH_MESSAGING")

track_input(sim, user_input)

@spec track_input(t(), String.t() | nil) :: t()

Keep track of the inputs received for the simulator, updating the last_user_input if it's not nil.

track_output(sim, output)

@spec track_output(t(), FlowRunner.Spec.Block.t() | nil) :: t()

Keep track of the blocks generated as output and keep them aligned with the original input that was received which triggered this block.

Multiple blocks may be output

update_context(sim, vars \\ %{}, language_code \\ "eng", mode \\ "RICH_MESSAGING")