Action parameters

This guide details all the possible options for defining action parameters in Kamihi.

Parameter Name Description Type More information
data The main data argument for the action. If only one query is defined for the action, its results will be automatically assigned to this parameter. list Using data sources in actions
data_<query_name> When multiple queries are defined for the action, each query's results can be assigned to a separate parameter by using this naming convention. Replace <query_name> with the actual name of the query file (without the datasource and extension). list Using data sources in actions
template The Jinja2 template to be used for rendering the action's response. By default, Kamihi looks for a template file with the same name as the action in the action's folder. jinja2.Template Using templates in actions
template_<name> To use a template with a custom name, specify the template file in the action's parameters using the Annotated syntax. Replace <name> with the actual name of the template file. jinja2.Template Using templates in actions
update The update object representing the incoming message or event that triggered the action. This allows you to access details about the user, chat, and message context. telegram.Update -
context The context object that provides additional information about the current state of the bot and the conversation. This can be used to store temporary data or manage session state. telegram.ext.CallbackContext -
logger A logger instance that can be used to log messages for debugging or monitoring purposes within the action. loguru.Logger -
user The user object representing the user who triggered the action. This allows you to access user-specific information such as Telegram ID and any other details in the User model. models.User Extending the user model
users A list of user objects representing all the users that can use this action. list[models.User] -
action_folder The path to the folder where the action's files are stored. This can be useful for accessing additional resources or files related to the action. pathlib.Path -
.* Custom parameters defined by the user, that correspond to questions. They need to be properly annotated using typing.Annotated and a question type from kamihi.questions. Varies Asking questions