websocket_platform#
- class besser.bot.platforms.websocket.websocket_platform.WebSocketPlatform(bot, use_ui=True)[source]#
Bases:
Platform
The WebSocket Platform allows a bot to communicate with the users using the WebSocket bidirectional communications protocol.
This platform implements the WebSocket server, and it can establish connection with a client, allowing the bidirectional communication between server and client (i.e. sending and receiving messages).
Note
We provide a UI (streamlit_ui) implementing a WebSocket client to communicate with the bot, though you can use or create your own UI as long as it has a WebSocket client that connects to the bot’s WebSocket server.
- Parameters:
- _connections#
The list of active connections (i.e. users connected to the bot)
- _websocket_server#
The WebSocket server instance
- Type:
WebSocketServer or None
- _message_handler#
The function that handles the user connections (sessions) and incoming messages
- Type:
Callable[[ServerConnection], None]
- _abc_impl = <_abc._abc_data object>#
- initialize()[source]#
Initialize the platform. This function is called right before starting the platform.
- reply_dataframe(session, df)[source]#
Send a DataFrame bot reply, i.e. a table, to a specific user.
- Parameters:
session (Session) – the user session
df (pandas.DataFrame) – the message to send to the user
- reply_options(session, options)[source]#
Send a list of options as a reply. They can be used to let the user choose one of them