BotBuilder Schema

4.17.1 · abandoned · verified Sun Apr 12

The `botbuilder-schema` library provides the core data structures and schema definitions for the Microsoft Bot Framework Python SDK. It defines essential classes like `Activity`, `ConversationAccount`, and `ChannelAccount` that represent messages and participants in a bot conversation. Version 4.17.1 is the final release, as the broader Bot Framework Python SDK has officially reached end-of-life and will no longer be updated or maintained.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate core schema objects like `Activity`, `ConversationAccount`, and `ChannelAccount`, which are fundamental for representing messages and participants in the Bot Framework.

import datetime
from botbuilder.schema import Activity, ActivityTypes, ConversationAccount, ChannelAccount

# Create a sample conversation account
conversation = ConversationAccount(
    id="conversationId123",
    conversation_type="personal",
    is_group=False,
    tenant_id="tenantId123"
)

# Create a sample channel account for the user
user = ChannelAccount(
    id="userId123",
    name="Test User",
    role="user"
)

# Create a sample channel account for the bot
bot = ChannelAccount(
    id="botId456",
    name="Test Bot",
    role="bot"
)

# Create an Activity object
activity = Activity(
    type=ActivityTypes.message,
    id="messageId789",
    timestamp=datetime.datetime.now(datetime.timezone.utc),
    service_url="https://example.azurewebsites.net/api/messages",
    channel_id="emulator",
    conversation=conversation,
    from_property=user, # 'from' is a reserved keyword in Python, hence from_property
    recipient=bot,
    text="Hello from the botbuilder-schema quickstart!",
    locale="en-US"
)

print(f"Created Activity of type: {activity.type}")
print(f"Activity text: {activity.text}")
print(f"From: {activity.from_property.name} ({activity.from_property.id})")
print(f"To: {activity.recipient.name} ({activity.recipient.id})")

view raw JSON →