BotBuilder-schema contains the serialized data sent across the wire between user and bot when using Bot Framework
npx @tessl/cli install tessl/pypi-botbuilder-schema@4.17.0BotBuilder-schema contains the serialized data sent across the wire between user and bot when using Bot Framework. This package provides comprehensive data models for activities, conversations, channels, attachments, and authentication flows, serving as the foundational schema layer for Microsoft Bot Framework applications.
pip install botbuilder-schemafrom botbuilder.schema import Activity, ChannelAccount, ConversationAccountActivity types and enums:
from botbuilder.schema import ActivityTypes, RoleTypes, TextFormatTypesTeams extension:
from botbuilder.schema.teams import TeamsChannelData, TaskModuleRequestfrom botbuilder.schema import (
Activity,
ActivityTypes,
ChannelAccount,
ConversationAccount,
TextFormatTypes
)
# Create a simple message activity
message = Activity(
type=ActivityTypes.message,
text="Hello, World!",
from_property=ChannelAccount(id="user123", name="User"),
recipient=ChannelAccount(id="bot456", name="Bot"),
conversation=ConversationAccount(id="conversation789"),
channel_id="webchat",
text_format=TextFormatTypes.plain
)
# Create a conversation update activity
update = Activity(
type=ActivityTypes.conversation_update,
members_added=[ChannelAccount(id="newuser", name="New User")],
conversation=ConversationAccount(id="conversation789"),
channel_id="webchat"
)
# Create a reply to an existing activity
reply = message.create_reply("Thanks for your message!")The BotBuilder Schema follows a hierarchical design:
All models inherit from msrest.serialization.Model providing automatic JSON serialization for REST API communication across Bot Framework channels.
The foundational Activity model and supporting types that enable communication between bots and users across all Bot Framework channels. Includes activity creation, manipulation, and conversation management.
class Activity(Model):
def __init__(self, *, type: str = None, id: str = None,
text: str = None, from_property = None,
recipient = None, conversation = None, **kwargs): ...
def create_reply(self, text: str = None) -> 'Activity': ...
def apply_conversation_reference(self, reference: 'ConversationReference') -> 'Activity': ...
def get_conversation_reference(self) -> 'ConversationReference': ...
def has_content(self) -> bool: ...Account and conversation representations that identify participants and conversation contexts across different chat platforms and channels.
class ChannelAccount(Model):
def __init__(self, *, id: str = None, name: str = None,
aad_object_id: str = None, role: str = None, **kwargs): ...
class ConversationAccount(Model):
def __init__(self, *, is_group: bool = None, conversation_type: str = None,
id: str = None, name: str = None, **kwargs): ...Channel and Conversation Models
Interactive card models for creating rich user experiences including hero cards, thumbnails, receipts, OAuth flows, and media content with buttons and actions.
class HeroCard(Model):
def __init__(self, *, title: str = None, subtitle: str = None,
text: str = None, images: List = None, buttons: List = None, **kwargs): ...
class CardAction(Model):
def __init__(self, *, type: str = None, title: str = None,
value = None, **kwargs): ...File attachment and media management models supporting upload, download, and display of documents, images, audio, and video content.
class Attachment(Model):
def __init__(self, *, content_type: str = None, content_url: str = None,
content = None, name: str = None, **kwargs): ...
class AttachmentData(Model):
def __init__(self, *, type: str = None, name: str = None,
original_base64: str = None, **kwargs): ...OAuth token management, authentication flows, and signin processes including token requests, responses, and exchange mechanisms for secure bot authentication.
class TokenResponse(Model):
def __init__(self, *, connection_name: str = None, token: str = None,
expiration: str = None, **kwargs): ...
class TokenRequest(Model):
def __init__(self, *, provider: str = None, settings: dict = None, **kwargs): ...Comprehensive enumeration types defining activity types, role types, input hints, action types, and other standardized values used throughout the Bot Framework.
class ActivityTypes(str, Enum):
message = "message"
conversation_update = "conversationUpdate"
typing = "typing"
# ... additional types
class RoleTypes(str, Enum):
user = "user"
bot = "bot"
skill = "skill"Semantic entity models for representing structured data like mentions, places, geographic coordinates, and generic schema.org entities within Bot Framework activities.
class Entity(Model):
def __init__(self, *, type: str = None, **kwargs): ...
class GeoCoordinates(Model):
def __init__(self, *, elevation: float = None, latitude: float = None,
longitude: float = None, type: str = None, name: str = None, **kwargs): ...
class Place(Model):
def __init__(self, *, address=None, geo=None, has_map=None,
type: str = None, name: str = None, **kwargs): ...
class Thing(Model):
def __init__(self, *, type: str = None, name: str = None, **kwargs): ...Teams-specific models for meetings, task modules, messaging extensions, O365 connector cards, and file handling within Microsoft Teams environments.
class TeamsChannelData(Model):
def __init__(self, *, team = None, channel = None, meeting = None, **kwargs): ...
class TaskModuleRequest(Model):
def __init__(self, *, data = None, context = None, **kwargs): ...# Import from botbuilder.schema
Activity: Model
ChannelAccount: Model
ConversationAccount: Model
ConversationReference: Model
ResourceResponse: Model
ErrorResponse: Model# Activity and message types
ActivityTypes: Enum
RoleTypes: Enum
TextFormatTypes: Enum
ActivityImportance: Enum
# Action and input types
ActionTypes: Enum
InputHints: Enum
AttachmentLayoutTypes: Enum
MessageReactionTypes: Enum
# Status and flow types
EndOfConversationCodes: Enum
DeliveryModes: Enum
ContactRelationUpdateActionTypes: Enum
InstallationUpdateActionTypes: Enum# Authentication constants
SignInConstants: Enum
CallerIdConstants: Enum
# Speech synthesis constants
SpeechConstants: class