Activity Class

An Activity is the basic communication type for the Bot Framework 3.0 protocol.

Inheritance
msrest.serialization.Model
Activity

Constructor

Activity(*, type=None, id: str = None, timestamp=None, local_timestamp=None, local_timezone: str = None, service_url: str = None, channel_id: str = None, from_property=None, conversation=None, recipient=None, text_format=None, attachment_layout=None, members_added=None, members_removed=None, reactions_added=None, reactions_removed=None, topic_name: str = None, history_disclosed: bool = None, locale: str = None, text: str = None, speak: str = None, input_hint=None, summary: str = None, suggested_actions=None, attachments=None, entities=None, channel_data=None, action: str = None, reply_to_id: str = None, label: str = None, value_type: str = None, value=None, name: str = None, relates_to=None, code=None, expiration=None, importance=None, delivery_mode=None, listen_for=None, text_highlights=None, semantic_action=None, caller_id: str = None, **kwargs)

Parameters

Name Description
type
Required
str or <xref:botframework.connector.models.ActivityTypes>

Contains the activity type. Possible values include: 'message', 'contactRelationUpdate', 'conversationUpdate', 'typing', 'endOfConversation', 'event', 'invoke', 'deleteUserData', 'messageUpdate', 'messageDelete', 'installationUpdate', 'messageReaction', 'suggestion', 'trace', 'handoff'

id
Required
str

Contains an ID that uniquely identifies the activity on the channel.

timestamp
Required

Contains the date and time that the message was sent, in UTC, expressed in ISO-8601 format.

local_timestamp
Required

Contains the local date and time of the message expressed in ISO-8601 format. For example, 2016-09-23T13:07:49.4714686-07:00.

local_timezone
Required
str

Contains the name of the local timezone of the message, expressed in IANA Time Zone database format. For example, America/Los_Angeles.

service_url
Required
str

Contains the URL that specifies the channel's service endpoint. Set by the channel.

channel_id
Required
str

Contains an ID that uniquely identifies the channel. Set by the channel.

from_property
Required
<xref:botframework.connector.models.ChannelAccount>

Identifies the sender of the message.

conversation
Required
<xref:botframework.connector.models.ConversationAccount>

Identifies the conversation to which the activity belongs.

recipient
Required
<xref:botframework.connector.models.ChannelAccount>

Identifies the recipient of the message.

text_format
Required
str or <xref:botframework.connector.models.TextFormatTypes>

Format of text fields Default:markdown. Possible values include: 'markdown', 'plain', 'xml'

attachment_layout
Required
str or <xref:botframework.connector.models.AttachmentLayoutTypes>

The layout hint for multiple attachments. Default: list. Possible values include: 'list', 'carousel'

members_added
Required
list[<xref:botframework.connector.models.ChannelAccount>]

The collection of members added to the conversation.

members_removed
Required
list[<xref:botframework.connector.models.ChannelAccount>]

The collection of members removed from the conversation.

reactions_added
Required
list[<xref:botframework.connector.models.MessageReaction>]

The collection of reactions added to the conversation.

reactions_removed
Required
list[<xref:botframework.connector.models.MessageReaction>]

The collection of reactions removed from the conversation.

topic_name
Required
str

The updated topic name of the conversation.

history_disclosed
Required

Indicates whether the prior history of the channel is disclosed.

locale
Required
str

A locale name for the contents of the text field. The locale name is a combination of an ISO 639 two- or three-letter culture code associated with a language and an ISO 3166 two-letter subculture code associated with a country or region. The locale name can also correspond to a valid BCP-47 language tag.

text
Required
str

The text content of the message.

speak
Required
str

The text to speak.

input_hint
Required
str or <xref:botframework.connector.models.InputHints>

Indicates whether your bot is accepting, expecting, or ignoring user input after the message is delivered to the client. Possible values include: 'acceptingInput', 'ignoringInput', 'expectingInput'

summary
Required
str

The text to display if the channel cannot render cards.

suggested_actions
Required
<xref:botframework.connector.models.SuggestedActions>

The suggested actions for the activity.

attachments
Required
list[<xref:botframework.connector.models.Attachment>]

Attachments

entities
Required
list[<xref:botframework.connector.models.Entity>]

Represents the entities that were mentioned in the message.

channel_data
Required

Contains channel-specific content.

action
Required
str

Indicates whether the recipient of a contactRelationUpdate was added or removed from the sender's contact list.

reply_to_id
Required
str

Contains the ID of the message to which this message is a reply.

label
Required
str

A descriptive label for the activity.

value_type
Required
str

The type of the activity's value object.

value
Required

A value that is associated with the activity.

name
Required
str

The name of the operation associated with an invoke or event activity.

relates_to
Required
<xref:botframework.connector.models.ConversationReference>

A reference to another conversation or activity.

code
Required
str or <xref:botframework.connector.models.EndOfConversationCodes>

The a code for endOfConversation activities that indicates why the conversation ended. Possible values include: 'unknown', 'completedSuccessfully', 'userCancelled', 'botTimedOut', 'botIssuedInvalidMessage', 'channelFailed'

expiration
Required

The time at which the activity should be considered to be "expired" and should not be presented to the recipient.

importance
Required
str or <xref:botframework.connector.models.ActivityImportance>

The importance of the activity. Possible values include: 'low', 'normal', 'high'

delivery_mode
Required
str or <xref:botframework.connector.models.DeliveryModes>

A delivery hint to signal to the recipient alternate delivery paths for the activity. The default delivery mode is "default". Possible values include: 'normal', 'notification', 'expectReplies', 'ephemeral'

listen_for
Required

List of phrases and references that speech and language priming systems should listen for

text_highlights
Required
list[<xref:botframework.connector.models.TextHighlight>]

The collection of text fragments to highlight when the activity contains a ReplyToId value.

semantic_action
Required
<xref:botframework.connector.models.SemanticAction>

An optional programmatic action accompanying this request

caller_id
Required
str

A string containing an IRI identifying the caller of a bot. This field is not intended to be transmitted over the wire, but is instead populated by bots and clients based on cryptographically verifiable data that asserts the identity of the callers (e.g. tokens).

Keyword-Only Parameters

Name Description
type
Required
id
Required
timestamp
Required
local_timestamp
Required
local_timezone
Required
service_url
Required
channel_id
Required
from_property
Required
conversation
Required
recipient
Required
text_format
Required
attachment_layout
Required
members_added
Required
members_removed
Required
reactions_added
Required
reactions_removed
Required
topic_name
Required
history_disclosed
Required
locale
Required
text
Required
speak
Required
input_hint
Required
summary
Required
suggested_actions
Required
attachments
Required
entities
Required
channel_data
Required
action
Required
reply_to_id
Required
label
Required
value_type
Required
value
Required
name
Required
relates_to
Required
code
Required
expiration
Required
importance
Required
delivery_mode
Required
listen_for
Required
text_highlights
Required
semantic_action
Required
caller_id
Required

Methods

apply_conversation_reference

Updates this activity with the delivery information from an existing ConversationReference

incoming activity, where the bot is the recipient; otherwise, False. Default is False, and the activity will show the bot as the sender.

as_contact_relation_update_activity

Returns this activity as a ContactRelationUpdateActivity object; or None, if this is not that type of activity.

as_conversation_update_activity

Returns this activity as a ConversationUpdateActivity object; or None, if this is not that type of activity.

as_end_of_conversation_activity

Returns this activity as an EndOfConversationActivity object; or None, if this is not that type of activity.

as_event_activity

Returns this activity as an EventActivity object; or None, if this is not that type of activity.

as_handoff_activity

Returns this activity as a HandoffActivity object; or None, if this is not that type of activity.

as_installation_update_activity

Returns this activity as an InstallationUpdateActivity object; or None, if this is not that type of activity.

as_invoke_activity

Returns this activity as an InvokeActivity object; or None, if this is not that type of activity.

as_message_activity

Returns this activity as a MessageActivity object; or None, if this is not that type of activity.

as_message_delete_activity

Returns this activity as a MessageDeleteActivity object; or None, if this is not that type of activity.

as_message_reaction_activity

Returns this activity as a MessageReactionActivity object; or None, if this is not that type of activity.

as_message_update_activity

Returns this activity as an MessageUpdateActivity object; or None, if this is not that type of activity.

as_suggestion_activity

Returns this activity as a SuggestionActivity object; or None, if this is not that type of activity.

as_trace_activity

Returns this activity as a TraceActivity object; or None, if this is not that type of activity.

as_typing_activity

Returns this activity as a TypingActivity object; or null, if this is not that type of activity.

create_contact_relation_update_activity

Creates an instance of the Activity class as aContactRelationUpdateActivity object.

create_conversation_update_activity

Creates an instance of the Activity class as a ConversationUpdateActivity object.

create_end_of_conversation_activity

Creates an instance of the Activity class as an EndOfConversationActivity object.

create_event_activity

Creates an instance of the Activity class as an EventActivity object.

create_handoff_activity

Creates an instance of the Activity class as a HandoffActivity object.

create_invoke_activity

Creates an instance of the Activity class as an InvokeActivity object.

create_message_activity

Creates an instance of the Activity class as a MessageActivity object.

create_reply

Creates a new message activity as a response to this activity.

create_trace

Creates a new trace activity based on this activity.

Default is the name of type of the value. :param label: Optional, a descriptive label for this trace operation.

create_trace_activity

Creates an instance of the Activity class as a TraceActivity object.

Default is the name of type of the value. :param label: Optional, a descriptive label for this trace operation.

create_typing_activity

Creates an instance of the Activity class as a TypingActivity object.

get_conversation_reference

Creates a ConversationReference based on this activity.

get_mentions

Resolves the mentions from the entities of this activity.

get_reply_conversation_reference

Create a ConversationReference based on this Activity's Conversation info and the ResourceResponse from sending an activity.

has_content

Indicates whether this activity has content.

is_from_streaming_connection

Determine if the Activity was sent via an Http/Https connection or Streaming This can be determined by looking at the service_url property: (1) All channels that send messages via http/https are not streaming (2) Channels that send messages via streaming have a ServiceUrl that does not begin with http/https.

apply_conversation_reference

Updates this activity with the delivery information from an existing ConversationReference

incoming activity, where the bot is the recipient; otherwise, False. Default is False, and the activity will show the bot as the sender.

apply_conversation_reference(reference: ConversationReference, is_incoming: bool = False)

Parameters

Name Description
reference
Required
is_incoming
default value: False

Returns

Type Description

his activity, updated with the delivery information.

Remarks

Call GetConversationReference on an incoming activity to get a conversation reference that you can then use to update an outgoing activity with the correct delivery information.

as_contact_relation_update_activity

Returns this activity as a ContactRelationUpdateActivity object; or None, if this is not that type of activity.

as_contact_relation_update_activity()

Returns

Type Description

This activity as a message activity; or None.

as_conversation_update_activity

Returns this activity as a ConversationUpdateActivity object; or None, if this is not that type of activity.

as_conversation_update_activity()

Returns

Type Description

This activity as a conversation update activity; or None.

as_end_of_conversation_activity

Returns this activity as an EndOfConversationActivity object; or None, if this is not that type of activity.

as_end_of_conversation_activity()

Returns

Type Description

This activity as an end of conversation activity; or None.

as_event_activity

Returns this activity as an EventActivity object; or None, if this is not that type of activity.

as_event_activity()

Returns

Type Description

This activity as an event activity; or None.

as_handoff_activity

Returns this activity as a HandoffActivity object; or None, if this is not that type of activity.

as_handoff_activity()

Returns

Type Description

This activity as a handoff activity; or None.

as_installation_update_activity

Returns this activity as an InstallationUpdateActivity object; or None, if this is not that type of activity.

as_installation_update_activity()

Returns

Type Description

This activity as an installation update activity; or None.

as_invoke_activity

Returns this activity as an InvokeActivity object; or None, if this is not that type of activity.

as_invoke_activity()

Returns

Type Description

This activity as an invoke activity; or None.

as_message_activity

Returns this activity as a MessageActivity object; or None, if this is not that type of activity.

as_message_activity()

Returns

Type Description

This activity as a message activity; or None.

as_message_delete_activity

Returns this activity as a MessageDeleteActivity object; or None, if this is not that type of activity.

as_message_delete_activity()

Returns

Type Description

This activity as a message delete request; or None.

as_message_reaction_activity

Returns this activity as a MessageReactionActivity object; or None, if this is not that type of activity.

as_message_reaction_activity()

Returns

Type Description

This activity as a message reaction activity; or None.

as_message_update_activity

Returns this activity as an MessageUpdateActivity object; or None, if this is not that type of activity.

as_message_update_activity()

Returns

Type Description

This activity as a message update request; or None.

as_suggestion_activity

Returns this activity as a SuggestionActivity object; or None, if this is not that type of activity.

as_suggestion_activity()

Returns

Type Description

This activity as a suggestion activity; or None.

as_trace_activity

Returns this activity as a TraceActivity object; or None, if this is not that type of activity.

as_trace_activity()

Returns

Type Description

This activity as a trace activity; or None.

as_typing_activity

Returns this activity as a TypingActivity object; or null, if this is not that type of activity.

as_typing_activity()

Returns

Type Description

This activity as a typing activity; or null.

create_contact_relation_update_activity

Creates an instance of the Activity class as aContactRelationUpdateActivity object.

static create_contact_relation_update_activity()

Returns

Type Description

The new contact relation update activity.

create_conversation_update_activity

Creates an instance of the Activity class as a ConversationUpdateActivity object.

static create_conversation_update_activity()

Returns

Type Description

The new conversation update activity.

create_end_of_conversation_activity

Creates an instance of the Activity class as an EndOfConversationActivity object.

static create_end_of_conversation_activity()

Returns

Type Description

The new end of conversation activity.

create_event_activity

Creates an instance of the Activity class as an EventActivity object.

static create_event_activity()

Returns

Type Description

The new event activity.

create_handoff_activity

Creates an instance of the Activity class as a HandoffActivity object.

static create_handoff_activity()

Returns

Type Description

The new handoff activity.

create_invoke_activity

Creates an instance of the Activity class as an InvokeActivity object.

static create_invoke_activity()

Returns

Type Description

The new invoke activity.

create_message_activity

Creates an instance of the Activity class as a MessageActivity object.

static create_message_activity()

Returns

Type Description

The new message activity.

create_reply

Creates a new message activity as a response to this activity.

create_reply(text: str = None, locale: str = None)

Parameters

Name Description
text

The text of the reply.

default value: None
locale

The language code for the text.

default value: None

Returns

Type Description

The new message activity.

Remarks

The new activity sets up routing information based on this activity.

create_trace

Creates a new trace activity based on this activity.

Default is the name of type of the value. :param label: Optional, a descriptive label for this trace operation.

create_trace(name: str, value: object = None, value_type: str = None, label: str = None)

Parameters

Name Description
name
Required
value
default value: None
value_type
default value: None
label
default value: None

Returns

Type Description

The new trace activity.

create_trace_activity

Creates an instance of the Activity class as a TraceActivity object.

Default is the name of type of the value. :param label: Optional, a descriptive label for this trace operation.

static create_trace_activity(name: str, value: object = None, value_type: str = None, label: str = None)

Parameters

Name Description
name
Required
value
default value: None
value_type
default value: None
label
default value: None

Returns

Type Description

The new trace activity.

create_typing_activity

Creates an instance of the Activity class as a TypingActivity object.

static create_typing_activity()

Returns

Type Description

The new typing activity.

get_conversation_reference

Creates a ConversationReference based on this activity.

get_conversation_reference()

Returns

Type Description

A conversation reference for the conversation that contains this activity.

get_mentions

Resolves the mentions from the entities of this activity.

get_mentions() -> List[Mention]

Returns

Type Description

The array of mentions; or an empty array, if none are found.

Remarks

This method is defined on the Activity class, but is only intended for use with a message activity, where the activity Activity.Type is set to ActivityTypes.Message.

get_reply_conversation_reference

Create a ConversationReference based on this Activity's Conversation info and the ResourceResponse from sending an activity.

get_reply_conversation_reference(reply: ResourceResponse) -> ConversationReference

Parameters

Name Description
reply
Required

ResourceResponse returned from send_activity.

Returns

Type Description

A ConversationReference that can be stored and used later to delete or update the activity.

has_content

Indicates whether this activity has content.

has_content() -> bool

Returns

Type Description

True, if this activity has any content to send; otherwise, false.

Remarks

This method is defined on the Activity class, but is only intended for use with a message activity, where the activity Activity.Type is set to ActivityTypes.Message.

is_from_streaming_connection

Determine if the Activity was sent via an Http/Https connection or Streaming This can be determined by looking at the service_url property: (1) All channels that send messages via http/https are not streaming (2) Channels that send messages via streaming have a ServiceUrl that does not begin with http/https.

is_from_streaming_connection() -> bool

Returns

Type Description

True if the Activity originated from a streaming connection.