Skip to content

shipany.bot.conversation.models.activations

shipany.bot.conversation.models.activations package

Submodules

shipany.bot.conversation.models.activations.base module

pydantic model shipany.bot.conversation.models.activations.base.BaseActivation

Bases: BaseModel

Base activation model.

field next_step : str [Required] (alias ‘next-step’)

Next step identifier.

field condition : JsonLogic | None = None

Condition that must be met to activate the step. Expressed in JSONLogic. Empty means always true.

shipany.bot.conversation.models.activations.command module

pydantic model shipany.bot.conversation.models.activations.command.CommandActivation

Bases: BaseActivation

Describes a command that triggers the conversation.

Examples:

  • Command with a prefix:
    {
    "next-step": "step-1",
    "condition": {"var": "user.name"},
    "command": "start",
    "prefix": "/"
    }
  • Command without a prefix:
    {
    "next-step": "step-1",
    "condition": {"var": "user.name"},
    "command": "start",
    "prefix": ""
    }

field command : str [Required]

Command name.

field prefix : str = ”

Command prefix.

validator check_command_prefix » all fields

Check if the command prefix is valid. The prefix must be a non-alphabetic character.

  • Parameters: self (Self)
  • Return type: Self

shipany.bot.conversation.models.activations.event module

pydantic model shipany.bot.conversation.models.activations.event.EventActivation

Bases: BaseActivation

Describes an event that triggers the conversation. Commonly used for message events.

Payload samples

  • Event with a prefix:
    {
    "next-step": "step-1",
    "condition": {"var": "user.name"},
    "event": "on-message"
    }

Pydantic model parameters

field event : str [Required]

Event name that can trigger the conversation steps.

validator validate_event » event

Validate the event name. The event name should start with ‘on-’ prefix.

  • Parameters: value (str)
  • Return type: str

shipany.bot.conversation.models.activations.timeout module

pydantic model shipany.bot.conversation.models.activations.timeout.TimeoutActivation

Bases: BaseActivation

Describes a timeout that triggers the conversation.

Payload samples

  • Timeout activation:
    {
    "next-step": "step-1",
    "condition": {"var": "user.name"},
    "timeout": "timeout-1"
    }

Pydantic model parameters

field timeout_id : str [Required] (alias ‘timeout’)

Timeout identifier. Can be paired with TimeoutAction.

shipany.bot.conversation.models.activations.webhook module

pydantic model shipany.bot.conversation.models.activations.webhook.WebhookActivation

Bases: BaseActivation

Webhook model.

Contains information about the webhook path and the list of actions to perform in response.

Payload samples

  • Webhook activation:
    {
    "next-step": "step-1",
    "condition": {"var": "user.name"},
    "webhook": "webhook-1"
    }

Pydantic model parameters

  • Config:
    • extra: str = ignore
    • frozen: bool = True
  • Fields:

field webhook : str [Required]

Webhook identifier. Must be declared in the .webhooks list.

Module contents

The module contains the activation models for the bot.

Built-in activation models are used to trigger the bot’s conversations. They are used to define the conditions under which a conversation should be triggered.

The activation models are:

  • CommandActivation: activation model for commands
  • EventActivation: activation model for events
  • TimeoutActivation: activation model for timeouts
  • WebhookActivation: activation model for webhooks