payload#
- class besser.bot.platforms.payload.Payload(action, message=None)[source]#
Bases:
object
Represents a payload object used for encoding and decoding messages between a bot and any other external agent.
- class besser.bot.platforms.payload.PayloadAction(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
Enum
Enumeration of the different possible actions embedded into a
Payload
.- BOT_REPLY_DF = 'bot_reply_dataframe'#
Indicates that the payload’s purpose is to send a bot reply containing a
pandas.DataFrame
object.- Type:
- BOT_REPLY_FILE = 'bot_reply_file'#
Indicates that the payload’s purpose is to send a bot reply containing a
file.File
object.- Type:
- BOT_REPLY_IMAGE = 'bot_reply_image'#
Indicates that the payload’s purpose is to send a bot reply containing a
file.File
object, specifically an image.- Type:
- BOT_REPLY_LOCATION = 'bot_reply_location'#
Indicates that the payload’s purpose is to send a bot reply containing a location, which is a dictionary composed by a latitude and a longitude.
- Type:
- BOT_REPLY_OPTIONS = 'bot_reply_options'#
Indicates that the payload’s purpose is to send a bot reply containing a list of strings, where the user should select 1 of them.
- Type:
- BOT_REPLY_PLOTLY = 'bot_reply_plotly'#
Indicates that the payload’s purpose is to send a bot reply containing a
plotly.graph_objs.Figure
object.- Type:
- BOT_REPLY_STR = 'bot_reply_str'#
Indicates that the payload’s purpose is to send a bot reply containing a
str
object.- Type:
- RESET = 'reset'#
Use the
WebSocketPlatform
on this bot.- Type:
- USER_FILE = 'user_file'#
Indicates that the payload’s purpose is to send a user file.
- Type:
- USER_MESSAGE = 'user_message'#
Indicates that the payload’s purpose is to send a user message.
- Type:
- USER_VOICE = 'user_voice'#
Indicates that the payload’s purpose is to send a user audio.
- Type:
- class besser.bot.platforms.payload.PayloadEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]#
Bases:
JSONEncoder
Encoder for the
Payload
class.Example
import json encoded_payload = json.dumps(payload, cls=PayloadEncoder)