telega/flow/instance

Instance CRUD, accessors, factories, WaitResult, and serialization.

Values

pub fn clear_step_data(
  instance: types.FlowInstance,
) -> types.FlowInstance

Clear all step data

pub fn clear_step_data_key(
  instance: types.FlowInstance,
  key key: String,
) -> types.FlowInstance

Clear specific step data key

pub fn get_current_step(
  flow: types.Flow(step_type, session, error),
  instance: types.FlowInstance,
) -> Result(step_type, Nil)

Get current step as typed value

pub fn get_data(
  instance: types.FlowInstance,
  key key: String,
) -> option.Option(String)

Get data from the flow instance

pub fn get_step_data(
  instance: types.FlowInstance,
  key key: String,
) -> option.Option(String)

Get step data

pub fn get_wait_result(
  instance: types.FlowInstance,
) -> types.WaitResult

Get the result of waiting for user input or callback

pub fn instance_chat_id(instance: types.FlowInstance) -> Int

Get the chat ID

pub fn instance_created_at(instance: types.FlowInstance) -> Int

Get the created_at timestamp

pub fn instance_current_step(
  instance: types.FlowInstance,
) -> String

Get the current step name

pub fn instance_flow_name(instance: types.FlowInstance) -> String

Get the flow name

pub fn instance_from_row(
  row: types.FlowInstanceRow,
) -> types.FlowInstance

Construct a FlowInstance from a flat row

pub fn instance_id(instance: types.FlowInstance) -> String

Get the instance ID

pub fn instance_to_row(
  instance: types.FlowInstance,
) -> types.FlowInstanceRow

Convert a FlowInstance to a flat row for database storage

pub fn instance_updated_at(instance: types.FlowInstance) -> Int

Get the updated_at timestamp

pub fn instance_user_id(instance: types.FlowInstance) -> Int

Get the user ID

pub fn instance_wait_token(
  instance: types.FlowInstance,
) -> option.Option(String)

Get the wait token

pub fn is_expired(
  instance: types.FlowInstance,
  ttl_ms: option.Option(Int),
) -> Bool

Check if an instance is expired based on TTL or wait timeout

pub fn new_instance(
  id id: String,
  flow_name flow_name: String,
  user_id user_id: Int,
  chat_id chat_id: Int,
  current_step current_step: String,
) -> types.FlowInstance

Create a new FlowInstance with minimal required fields

pub fn new_instance_with_data(
  id id: String,
  flow_name flow_name: String,
  user_id user_id: Int,
  chat_id chat_id: Int,
  current_step current_step: String,
  data data: dict.Dict(String, String),
) -> types.FlowInstance

Create a new FlowInstance with initial data

pub fn next_with_data(
  ctx: bot.Context(session, error),
  instance: types.FlowInstance,
  step step: step_type,
  key key: String,
  value value: String,
) -> Result(
  #(
    bot.Context(session, error),
    types.FlowAction(step_type),
    types.FlowInstance,
  ),
  error,
)

Update instance data and continue to next step

pub fn store_data(
  instance: types.FlowInstance,
  key key: String,
  value value: String,
) -> types.FlowInstance

Store data in the flow instance

pub fn store_step_data(
  instance: types.FlowInstance,
  key key: String,
  value value: String,
) -> types.FlowInstance

Store step data

Search Document