Agent API Reference

class openfloor.agent.BotAgent(manifest)[source]

Bases: OpenFloorAgent

BotAgent is a simple bot agent. It can be used as a class in its own right or subclassed to create more complex agents.

The class provides default event handlers that meet the Open Floor specification requirements for a bot agent.

The default on_envelope handler processes events in a specific order, checking for invite events first if the bot is not already in a conversation.

Event handlers can be customized by subclassing and overriding the default handlers.

For a minimal implementation, all that is required is the following - Implement a handler for invite events to send a greeting - Implement a handler for bye events to send a farewell - Implement a handler for utterance events to handle conversation

bot_on_context(event, in_envelope, out_envelope)[source]
Return type:

None

bot_on_envelope(in_envelope, out_envelope)[source]
Return type:

Envelope

bot_on_get_manifests(event, in_envelope, out_envelope)[source]
Return type:

None

bot_on_grant_floor(event, in_envelope, out_envelope)[source]
Return type:

None

bot_on_invite(event, in_envelope, out_envelope)[source]
Return type:

None

bot_on_revoke_floor(event, in_envelope, out_envelope)[source]
Return type:

None

bot_on_uninvite(event, in_envelope, out_envelope)[source]
Return type:

None

bot_on_utterance(event, in_envelope, out_envelope)[source]
Return type:

None

process_envelope(in_envelope)[source]
Return type:

Envelope

class openfloor.agent.OpenFloorAgent(manifest)[source]

Bases: OpenFloorEvents

add_metadata(events)[source]

Split events into those intended for this agent and those for other agents

Parameters:

events (List[Event]) – List of events to split

Returns:

  • event: The original event

  • metadata: Dictionary containing:
    • addressed_to_me: Boolean indicating if event is intended for this agent

Return type:

List of tuples (event, metadata) where

property serviceUrl: str

A convenient shorthand to get the serviceUrl from the manifest

property speakerUri: str

A convenient shorthand to get the speakerUri from the manifest

class openfloor.agent.OpenFloorEvents(eventType, to=None, reason=None, parameters=<factory>)[source]

Bases: Event

Base class for Open Floor agents that defines event handlers