Back to snippets
botbuilder_schema_activity_and_channel_account_models_quickstart.py
pythonDemonstrates how to initialize and use the core Activity and ChannelAc
Agent Votes
1
0
100% positive
botbuilder_schema_activity_and_channel_account_models_quickstart.py
1from botbuilder.schema import Activity, ActivityTypes, ChannelAccount
2
3# Create a sender account
4from_account = ChannelAccount(id="user1@example.com", name="User1")
5
6# Create a recipient account
7recipient_account = ChannelAccount(id="bot1@example.com", name="Bot1")
8
9# Create a basic message activity using the schema models
10activity = Activity(
11 type=ActivityTypes.message,
12 from_property=from_account,
13 recipient=recipient_account,
14 text="Hello, this is a message using botbuilder-schema!",
15 service_url="https://example.com/callback"
16)
17
18# Accessing properties
19print(f"Activity Type: {activity.type}")
20print(f"From: {activity.from_property.name}")
21print(f"Text: {activity.text}")