Message#

The Message class is a universal data model for representing a message that should be supported by DFF. It only contains types and properties that are compatible with most messaging services.

class Session(value)[source]#

Bases: Enum

An enumeration that defines two possible states of a session.

ACTIVE = 1#
FINISHED = 2#
class DataModel(**data)[source]#

Bases: BaseModel

This class is a Pydantic BaseModel that serves as a base class for all DFF models.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class Command(**data)[source]#

Bases: DataModel

This class is a subclass of DataModel and represents a command that can be executed in response to a user input.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class Location(**data)[source]#

Bases: DataModel

This class is a data model that represents a geographical location on the Earth’s surface. It has two attributes, longitude and latitude, both of which are float values. If the absolute difference between the latitude and longitude values of the two locations is less than 0.00004, they are considered equal.

longitude: float#
latitude: float#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class Attachment(**data)[source]#

Bases: DataModel

This class represents an attachment that can be either a file or a URL, along with an optional ID and title.

source: Union[Url[Url], Path[Path], None]#
id: Optional[str]#
title: Optional[str]#
get_bytes()[source]#
Return type:

Optional[bytes]

classmethod validate_source_or_id(values)[source]#
classmethod validate_source(value)[source]#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class Audio(**data)[source]#

Bases: Attachment

Represents an audio file attachment.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

source: Union[Url[Url], Path[Path], None]#
id: Optional[str]#
title: Optional[str]#
class Video(**data)[source]#

Bases: Attachment

Represents a video file attachment.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

source: Union[Url[Url], Path[Path], None]#
id: Optional[str]#
title: Optional[str]#
class Image(**data)[source]#

Bases: Attachment

Represents an image file attachment.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

source: Union[Url[Url], Path[Path], None]#
id: Optional[str]#
title: Optional[str]#
class Document(**data)[source]#

Bases: Attachment

Represents a document file attachment.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

source: Union[Url[Url], Path[Path], None]#
id: Optional[str]#
title: Optional[str]#
class Attachments(**data)[source]#

Bases: DataModel

This class is a data model that represents a list of attachments.

files: List[Attachment]#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Bases: DataModel

This class is a DataModel representing a hyperlink.

source: Url[Url]#
title: Optional[str]#
property html#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class Button(**data)[source]#

Bases: DataModel

This class allows for the creation of a button object with a source URL, a text description, and a payload.

source: Optional[Url[Url]]#
text: str#
payload: Optional[Any]#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class Keyboard(**data)[source]#

Bases: DataModel

This class is a DataModel that represents a keyboard object that can be used for a chatbot or messaging application.

buttons: List[Button]#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class Message(text=None, commands=None, attachments=None, annotations=None, misc=None, **kwargs)[source]#

Bases: DataModel

Class representing a message and contains several class level variables to store message information.

text: Optional[str]#
commands: Optional[List[Command]]#
attachments: Optional[Attachments]#
annotations: Optional[dict]#
misc: Optional[dict]#
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].