Events#
An agent can receive events
through its platforms.
An agent can define transitions from one state to another based on the reception of specific events.
Note
The Transitions wiki page explains how to define event-based transitions in agents.
All events contain the following information:
name: name of the event
session_id: the id of the session the event was sent to. If an event has been broadcasted to all agent sessions, this attribute is empty
timestamp: the timestamp indicating the event reception instant
Then, each event implementation may have different attributes.
You can access the received event from the user session (i.e., from state bodies or transition conditions)
The session always contains the last received event (the one that triggered the transition to the state you are reading the event from)
def example_body(session: Session):
event: Event = session.event
# Depending on the type of event, we can access specific information
if isinstance(event, ReceiveTextEvent):
message: str = event.message
intent_prediction: IntentClassifierPrediction = event.predicted_intent
human: bool = event.human # Whether the message was sent by a human or not
if isinstance(event, ReceiveFileEvent):
file: File = event.file
human: bool = event.human
if isinstance(event, GitHubEvent) or isinstance(event, GitLabEvent):
category = event.category
action = event.action
payload = event.payload
Next, we introduce all available events in BAF.
Base events#
This set of events are used to receive data, usually in the form of text, JSON or file messages.
Currently, WebSocket platform and Telegram platform use these events to send data to the agents.
For example, when a user sends a text message to an agent through the WebSocket platform, the platform packs it in a ReceiveTextEvent so the agent can use it to trigger the appropriate transition to another state.
Important
All events described in base_events API documentation.
GitHub events#
You can use the GitHub platform in an agent to receive events from GitHub.
Important
All events described in github_webhooks_events API documentation.
GitLab events#
You can use the GitLab platform in an agent to receive events from GitLab.
Important
All events described in gitlab_webhooks_events API documentation.
API References#
GitHubEvent:
besser.agent.library.transition.events.github_webhooks_events.GitHubEvent()
GitLabEvent:
besser.agent.library.transition.events.gitlab_webhooks_events.GitLabEvent()
IntentClassifierPrediction:
besser.agent.nlp.intent_classifier.intent_classifier_prediction.IntentClassifierPrediction
ReceiveFileEvent:
besser.agent.library.transition.events.base_events.ReceiveFileEvent
ReceiveTextEvent:
besser.agent.library.transition.events.base_events.ReceiveTextEvent
Session:
besser.agent.core.session.Session