Hotline.Flow.Context (Hotline v0.2.1)

Copy Markdown View Source

Flow execution context passed to prompt functions and handle_input/3 callbacks.

Holds the current step, accumulated data, and metadata for a running flow.

Fields

  • :flow_module — the module implementing Hotline.Flow
  • :chat_id — Telegram chat ID this flow belongs to
  • :step — current step atom (e.g. :name, :confirm)
  • :data — accumulated data map, built up via {:next, store: %{...}}
  • :opts — user-provided options passed when starting the flow

Example

ctx = Context.new(MyFlow, 123)
ctx = Context.store(ctx, %{name: "Alice"})
ctx.data.name
#=> "Alice"

Summary

Functions

Move the context to a specific step.

Create a new context for a flow.

Merge new data into the context's accumulated data.

Types

t()

@type t() :: %Hotline.Flow.Context{
  chat_id: integer(),
  data: map(),
  flow_module: module(),
  opts: map(),
  step: atom() | nil
}

Functions

move_to(ctx, step)

@spec move_to(t(), atom()) :: t()

Move the context to a specific step.

new(flow_module, chat_id, opts \\ %{})

@spec new(module(), integer(), map()) :: t()

Create a new context for a flow.

store(ctx, new_data)

@spec store(t(), map()) :: t()

Merge new data into the context's accumulated data.