Labels#

Labels are one of the important components of the dialog graph, which determine the targeted node name of the transition. They are used to identify the next step in the conversation. Labels can also be used in combination with other conditions, such as the current context or user data, to create more complex and dynamic conversations.

This module contains a standard set of scripting labels that can be used by developers to define the conversation flow.

repeat(priority=None)[source]#

Returns transition handler that takes Context, Pipeline and priority. This handler returns a label to the last node with a given priority. If the priority is not given, Pipeline.actor.label_priority is used as default.

Parameters:

priority (Optional[float]) – Priority of transition. Uses Pipeline.actor.label_priority if priority not defined.

Return type:

Callable

previous(priority=None)[source]#

Returns transition handler that takes Context, Pipeline and priority. This handler returns a label to the previous node with a given priority. If the priority is not given, Pipeline.actor.label_priority is used as default. If the current node is the start node, fallback is returned.

Parameters:

priority (Optional[float]) – Priority of transition. Uses Pipeline.actor.label_priority if priority not defined.

Return type:

Callable

to_start(priority=None)[source]#

Returns transition handler that takes Context, Pipeline and priority. This handler returns a label to the start node with a given priority. If the priority is not given, Pipeline.actor.label_priority is used as default.

Parameters:

priority (Optional[float]) – Priority of transition. Uses Pipeline.actor.label_priority if priority not defined.

Return type:

Callable

to_fallback(priority=None)[source]#

Returns transition handler that takes Context, Pipeline and priority. This handler returns a label to the fallback node with a given priority. If the priority is not given, Pipeline.actor.label_priority is used as default.

Parameters:

priority (Optional[float]) – Priority of transition. Uses Pipeline.actor.label_priority if priority not defined.

Return type:

Callable

_get_label_by_index_shifting(ctx, pipeline, priority=None, increment_flag=True, cyclicality_flag=True)[source]#

Function that returns node label from the context and pipeline after shifting the index.

Parameters:
  • ctx (Context) – Dialog context.

  • pipeline (Pipeline) – Dialog pipeline.

  • priority (Optional[float]) – Priority of transition. Uses Pipeline.actor.label_priority if priority not defined.

  • increment_flag (bool) – If it is True, label index is incremented by 1, otherwise it is decreased by 1. Defaults to True.

  • cyclicality_flag (bool) – If it is True the iteration over the label list is going cyclically (e.g the element with index = len(labels) has index = 0). Defaults to True.

Return type:

Tuple[str, str, float]

Returns:

The tuple that consists of (flow_label, label, priority). If fallback is executed (flow_fallback_label, fallback_label, priority) are returned.

forward(priority=None, cyclicality_flag=True)[source]#

Returns transition handler that takes Context, Pipeline and priority. This handler returns a label to the forward node with a given priority and cyclicality_flag. If the priority is not given, Pipeline.actor.label_priority is used as default.

Parameters:
  • priority (Optional[float]) – Float priority of transition. Uses Pipeline.actor.label_priority if priority not defined.

  • cyclicality_flag (bool) – If it is True, the iteration over the label list is going cyclically (e.g the element with index = len(labels) has index = 0). Defaults to True.

Return type:

Callable

backward(priority=None, cyclicality_flag=True)[source]#

Returns transition handler that takes Context, Pipeline and priority. This handler returns a label to the backward node with a given priority and cyclicality_flag. If the priority is not given, Pipeline.actor.label_priority is used as default.

Parameters:
  • priority (Optional[float]) – Float priority of transition. Uses Pipeline.actor.label_priority if priority not defined.

  • cyclicality_flag (bool) – If it is True, the iteration over the label list is going cyclically (e.g the element with index = len(labels) has index = 0). Defaults to True.

Return type:

Callable