microsoft-agents-activity 0.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of microsoft-agents-activity might be problematic. Click here for more details.

Files changed (195) hide show
  1. microsoft/agents/activity/__init__.py +191 -0
  2. microsoft/agents/activity/_load_configuration.py +25 -0
  3. microsoft/agents/activity/_type_aliases.py +5 -0
  4. microsoft/agents/activity/action_types.py +14 -0
  5. microsoft/agents/activity/activity.py +613 -0
  6. microsoft/agents/activity/activity_event_names.py +6 -0
  7. microsoft/agents/activity/activity_importance.py +7 -0
  8. microsoft/agents/activity/activity_types.py +22 -0
  9. microsoft/agents/activity/adaptive_card_invoke_action.py +24 -0
  10. microsoft/agents/activity/adaptive_card_invoke_response.py +20 -0
  11. microsoft/agents/activity/adaptive_card_invoke_value.py +22 -0
  12. microsoft/agents/activity/agents_model.py +18 -0
  13. microsoft/agents/activity/ai_entity.py +142 -0
  14. microsoft/agents/activity/animation_card.py +54 -0
  15. microsoft/agents/activity/attachment.py +24 -0
  16. microsoft/agents/activity/attachment_data.py +21 -0
  17. microsoft/agents/activity/attachment_info.py +19 -0
  18. microsoft/agents/activity/attachment_layout_types.py +6 -0
  19. microsoft/agents/activity/attachment_view.py +15 -0
  20. microsoft/agents/activity/audio_card.py +54 -0
  21. microsoft/agents/activity/basic_card.py +30 -0
  22. microsoft/agents/activity/caller_id_constants.py +7 -0
  23. microsoft/agents/activity/card_action.py +39 -0
  24. microsoft/agents/activity/card_image.py +19 -0
  25. microsoft/agents/activity/channel_account.py +33 -0
  26. microsoft/agents/activity/channel_adapter_protocol.py +76 -0
  27. microsoft/agents/activity/channels.py +158 -0
  28. microsoft/agents/activity/contact_relation_update_action_types.py +6 -0
  29. microsoft/agents/activity/conversation_account.py +38 -0
  30. microsoft/agents/activity/conversation_members.py +16 -0
  31. microsoft/agents/activity/conversation_parameters.py +37 -0
  32. microsoft/agents/activity/conversation_reference.py +60 -0
  33. microsoft/agents/activity/conversation_resource_response.py +19 -0
  34. microsoft/agents/activity/conversation_update_types.py +15 -0
  35. microsoft/agents/activity/conversations_result.py +17 -0
  36. microsoft/agents/activity/delivery_modes.py +9 -0
  37. microsoft/agents/activity/end_of_conversation_codes.py +10 -0
  38. microsoft/agents/activity/entity.py +38 -0
  39. microsoft/agents/activity/error.py +19 -0
  40. microsoft/agents/activity/error_response.py +12 -0
  41. microsoft/agents/activity/expected_replies.py +13 -0
  42. microsoft/agents/activity/fact.py +18 -0
  43. microsoft/agents/activity/geo_coordinates.py +27 -0
  44. microsoft/agents/activity/hero_card.py +30 -0
  45. microsoft/agents/activity/inner_http_error.py +14 -0
  46. microsoft/agents/activity/input_hints.py +10 -0
  47. microsoft/agents/activity/installation_update_action_types.py +6 -0
  48. microsoft/agents/activity/invoke_response.py +24 -0
  49. microsoft/agents/activity/media_card.py +54 -0
  50. microsoft/agents/activity/media_event_value.py +12 -0
  51. microsoft/agents/activity/media_url.py +16 -0
  52. microsoft/agents/activity/mention.py +19 -0
  53. microsoft/agents/activity/message_reaction.py +13 -0
  54. microsoft/agents/activity/message_reaction_types.py +11 -0
  55. microsoft/agents/activity/message_update_types.py +7 -0
  56. microsoft/agents/activity/oauth_card.py +24 -0
  57. microsoft/agents/activity/paged_members_result.py +16 -0
  58. microsoft/agents/activity/place.py +27 -0
  59. microsoft/agents/activity/receipt_card.py +36 -0
  60. microsoft/agents/activity/receipt_item.py +35 -0
  61. microsoft/agents/activity/resource_response.py +12 -0
  62. microsoft/agents/activity/role_types.py +7 -0
  63. microsoft/agents/activity/semantic_action.py +18 -0
  64. microsoft/agents/activity/semantic_actions_states.py +7 -0
  65. microsoft/agents/activity/sign_in_constants.py +13 -0
  66. microsoft/agents/activity/sign_in_resource.py +14 -0
  67. microsoft/agents/activity/signin_card.py +16 -0
  68. microsoft/agents/activity/suggested_actions.py +18 -0
  69. microsoft/agents/activity/teams/__init__.py +198 -0
  70. microsoft/agents/activity/teams/app_based_link_query.py +18 -0
  71. microsoft/agents/activity/teams/batch_failed_entries_response.py +15 -0
  72. microsoft/agents/activity/teams/batch_failed_entry.py +16 -0
  73. microsoft/agents/activity/teams/batch_operation_response.py +13 -0
  74. microsoft/agents/activity/teams/batch_operation_state_response.py +24 -0
  75. microsoft/agents/activity/teams/bot_config_auth.py +18 -0
  76. microsoft/agents/activity/teams/cache_info.py +18 -0
  77. microsoft/agents/activity/teams/cancel_operation_response.py +19 -0
  78. microsoft/agents/activity/teams/channel_info.py +21 -0
  79. microsoft/agents/activity/teams/config_auth_response.py +17 -0
  80. microsoft/agents/activity/teams/config_response.py +18 -0
  81. microsoft/agents/activity/teams/config_response_base.py +14 -0
  82. microsoft/agents/activity/teams/config_task_response.py +18 -0
  83. microsoft/agents/activity/teams/conversation_list.py +17 -0
  84. microsoft/agents/activity/teams/file_consent_card.py +24 -0
  85. microsoft/agents/activity/teams/file_consent_card_response.py +21 -0
  86. microsoft/agents/activity/teams/file_download_info.py +24 -0
  87. microsoft/agents/activity/teams/file_info_card.py +21 -0
  88. microsoft/agents/activity/teams/file_upload_info.py +26 -0
  89. microsoft/agents/activity/teams/meeting_details.py +23 -0
  90. microsoft/agents/activity/teams/meeting_details_base.py +21 -0
  91. microsoft/agents/activity/teams/meeting_end_event_details.py +15 -0
  92. microsoft/agents/activity/teams/meeting_event_details.py +15 -0
  93. microsoft/agents/activity/teams/meeting_info.py +24 -0
  94. microsoft/agents/activity/teams/meeting_notification.py +15 -0
  95. microsoft/agents/activity/teams/meeting_notification_base.py +14 -0
  96. microsoft/agents/activity/teams/meeting_notification_channel_data.py +16 -0
  97. microsoft/agents/activity/teams/meeting_notification_recipient_failure_info.py +20 -0
  98. microsoft/agents/activity/teams/meeting_notification_response.py +20 -0
  99. microsoft/agents/activity/teams/meeting_participant_info.py +18 -0
  100. microsoft/agents/activity/teams/meeting_participants_event_details.py +16 -0
  101. microsoft/agents/activity/teams/meeting_stage_surface.py +25 -0
  102. microsoft/agents/activity/teams/meeting_start_event_details.py +15 -0
  103. microsoft/agents/activity/teams/meeting_tab_icon_surface.py +15 -0
  104. microsoft/agents/activity/teams/message_actions_payload.py +70 -0
  105. microsoft/agents/activity/teams/message_actions_payload_app.py +29 -0
  106. microsoft/agents/activity/teams/message_actions_payload_attachment.py +30 -0
  107. microsoft/agents/activity/teams/message_actions_payload_body.py +17 -0
  108. microsoft/agents/activity/teams/message_actions_payload_conversation.py +20 -0
  109. microsoft/agents/activity/teams/message_actions_payload_from.py +25 -0
  110. microsoft/agents/activity/teams/message_actions_payload_mention.py +23 -0
  111. microsoft/agents/activity/teams/message_actions_payload_reaction.py +23 -0
  112. microsoft/agents/activity/teams/message_actions_payload_user.py +27 -0
  113. microsoft/agents/activity/teams/messaging_extension_action.py +37 -0
  114. microsoft/agents/activity/teams/messaging_extension_action_response.py +24 -0
  115. microsoft/agents/activity/teams/messaging_extension_attachment.py +32 -0
  116. microsoft/agents/activity/teams/messaging_extension_parameter.py +17 -0
  117. microsoft/agents/activity/teams/messaging_extension_query.py +27 -0
  118. microsoft/agents/activity/teams/messaging_extension_query_options.py +17 -0
  119. microsoft/agents/activity/teams/messaging_extension_response.py +21 -0
  120. microsoft/agents/activity/teams/messaging_extension_result.py +34 -0
  121. microsoft/agents/activity/teams/messaging_extension_suggested_action.py +17 -0
  122. microsoft/agents/activity/teams/notification_info.py +21 -0
  123. microsoft/agents/activity/teams/o365_connector_card.py +32 -0
  124. microsoft/agents/activity/teams/o365_connector_card_action_base.py +21 -0
  125. microsoft/agents/activity/teams/o365_connector_card_action_card.py +30 -0
  126. microsoft/agents/activity/teams/o365_connector_card_action_query.py +15 -0
  127. microsoft/agents/activity/teams/o365_connector_card_date_input.py +30 -0
  128. microsoft/agents/activity/teams/o365_connector_card_fact.py +17 -0
  129. microsoft/agents/activity/teams/o365_connector_card_http_post.py +25 -0
  130. microsoft/agents/activity/teams/o365_connector_card_image.py +18 -0
  131. microsoft/agents/activity/teams/o365_connector_card_input_base.py +28 -0
  132. microsoft/agents/activity/teams/o365_connector_card_multichoice_input.py +40 -0
  133. microsoft/agents/activity/teams/o365_connector_card_multichoice_input_choice.py +17 -0
  134. microsoft/agents/activity/teams/o365_connector_card_open_uri.py +26 -0
  135. microsoft/agents/activity/teams/o365_connector_card_open_uri_target.py +17 -0
  136. microsoft/agents/activity/teams/o365_connector_card_section.py +42 -0
  137. microsoft/agents/activity/teams/o365_connector_card_text_input.py +31 -0
  138. microsoft/agents/activity/teams/o365_connector_card_view_action.py +25 -0
  139. microsoft/agents/activity/teams/on_behalf_of.py +23 -0
  140. microsoft/agents/activity/teams/read_receipt_info.py +47 -0
  141. microsoft/agents/activity/teams/signin_state_verification_query.py +14 -0
  142. microsoft/agents/activity/teams/surface.py +18 -0
  143. microsoft/agents/activity/teams/tab_context.py +14 -0
  144. microsoft/agents/activity/teams/tab_entity_context.py +15 -0
  145. microsoft/agents/activity/teams/tab_request.py +22 -0
  146. microsoft/agents/activity/teams/tab_response.py +16 -0
  147. microsoft/agents/activity/teams/tab_response_card.py +14 -0
  148. microsoft/agents/activity/teams/tab_response_cards.py +17 -0
  149. microsoft/agents/activity/teams/tab_response_payload.py +25 -0
  150. microsoft/agents/activity/teams/tab_submit.py +23 -0
  151. microsoft/agents/activity/teams/tab_submit_data.py +18 -0
  152. microsoft/agents/activity/teams/tab_suggested_actions.py +17 -0
  153. microsoft/agents/activity/teams/targeted_meeting_notification.py +19 -0
  154. microsoft/agents/activity/teams/targeted_meeting_notification_value.py +19 -0
  155. microsoft/agents/activity/teams/task_module_card_response.py +15 -0
  156. microsoft/agents/activity/teams/task_module_continue_response.py +19 -0
  157. microsoft/agents/activity/teams/task_module_message_response.py +18 -0
  158. microsoft/agents/activity/teams/task_module_request.py +25 -0
  159. microsoft/agents/activity/teams/task_module_request_context.py +15 -0
  160. microsoft/agents/activity/teams/task_module_response.py +20 -0
  161. microsoft/agents/activity/teams/task_module_response_base.py +17 -0
  162. microsoft/agents/activity/teams/task_module_task_info.py +30 -0
  163. microsoft/agents/activity/teams/team_details.py +29 -0
  164. microsoft/agents/activity/teams/team_info.py +20 -0
  165. microsoft/agents/activity/teams/teams_batch_operation_response.py +19 -0
  166. microsoft/agents/activity/teams/teams_channel_account.py +44 -0
  167. microsoft/agents/activity/teams/teams_channel_data.py +43 -0
  168. microsoft/agents/activity/teams/teams_channel_data_settings.py +15 -0
  169. microsoft/agents/activity/teams/teams_meeting_info.py +14 -0
  170. microsoft/agents/activity/teams/teams_meeting_member.py +19 -0
  171. microsoft/agents/activity/teams/teams_meeting_participant.py +24 -0
  172. microsoft/agents/activity/teams/teams_member.py +14 -0
  173. microsoft/agents/activity/teams/teams_paged_members_result.py +19 -0
  174. microsoft/agents/activity/teams/tenant_info.py +14 -0
  175. microsoft/agents/activity/teams/user_meeting_details.py +17 -0
  176. microsoft/agents/activity/text_format_types.py +7 -0
  177. microsoft/agents/activity/text_highlight.py +16 -0
  178. microsoft/agents/activity/thing.py +15 -0
  179. microsoft/agents/activity/thumbnail_card.py +30 -0
  180. microsoft/agents/activity/thumbnail_url.py +15 -0
  181. microsoft/agents/activity/token_exchange_invoke_request.py +21 -0
  182. microsoft/agents/activity/token_exchange_invoke_response.py +21 -0
  183. microsoft/agents/activity/token_exchange_resource.py +13 -0
  184. microsoft/agents/activity/token_exchange_state.py +38 -0
  185. microsoft/agents/activity/token_post_resource.py +11 -0
  186. microsoft/agents/activity/token_request.py +16 -0
  187. microsoft/agents/activity/token_response.py +25 -0
  188. microsoft/agents/activity/token_status.py +32 -0
  189. microsoft/agents/activity/transcript.py +13 -0
  190. microsoft/agents/activity/turn_context_protocol.py +65 -0
  191. microsoft/agents/activity/video_card.py +54 -0
  192. microsoft_agents_activity-0.0.0.dist-info/METADATA +11 -0
  193. microsoft_agents_activity-0.0.0.dist-info/RECORD +195 -0
  194. microsoft_agents_activity-0.0.0.dist-info/WHEEL +5 -0
  195. microsoft_agents_activity-0.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,613 @@
1
+ from copy import copy
2
+ from datetime import datetime, timezone
3
+ from typing import Optional
4
+ from pydantic import Field, SerializeAsAny
5
+ from .activity_types import ActivityTypes
6
+ from .channel_account import ChannelAccount
7
+ from .conversation_account import ConversationAccount
8
+ from .mention import Mention
9
+ from .message_reaction import MessageReaction
10
+ from .resource_response import ResourceResponse
11
+ from .suggested_actions import SuggestedActions
12
+ from .attachment import Attachment
13
+ from .entity import Entity
14
+ from .conversation_reference import ConversationReference
15
+ from .text_highlight import TextHighlight
16
+ from .semantic_action import SemanticAction
17
+ from .agents_model import AgentsModel
18
+ from ._type_aliases import NonEmptyString
19
+
20
+
21
+ # TODO: A2A Agent 2 is responding with None as id, had to mark it as optional (investigate)
22
+ class Activity(AgentsModel):
23
+ """An Activity is the basic communication type for the protocol.
24
+
25
+ :param type: Contains the activity type. Possible values include:
26
+ 'message', 'contactRelationUpdate', 'conversationUpdate', 'typing',
27
+ 'endOfConversation', 'event', 'invoke', 'deleteUserData', 'messageUpdate',
28
+ 'messageDelete', 'installationUpdate', 'messageReaction', 'suggestion',
29
+ 'trace', 'handoff'
30
+ :type type: str or ~microsoft.agents.protocols.models.ActivityTypes
31
+ :param id: Contains an ID that uniquely identifies the activity on the channel.
32
+ :type id: str
33
+ :param timestamp: Contains the date and time that the message was sent, in UTC, expressed in ISO-8601 format.
34
+ :type timestamp: datetime
35
+ :param local_timestamp: Contains the local date and time of the message expressed in ISO-8601 format.
36
+ For example, 2016-09-23T13:07:49.4714686-07:00.
37
+ :type local_timestamp: datetime
38
+ :param local_timezone: Contains the name of the local timezone of the message, expressed in IANA Time Zone database format.
39
+ For example, America/Los_Angeles.
40
+ :type local_timezone: str
41
+ :param service_url: Contains the URL that specifies the channel's service endpoint. Set by the channel.
42
+ :type service_url: str
43
+ :param channel_id: Contains an ID that uniquely identifies the channel. Set by the channel.
44
+ :type channel_id: str
45
+ :param from_property: Identifies the sender of the message.
46
+ :type from_property: ~microsoft.agents.protocols.models.ChannelAccount
47
+ :param conversation: Identifies the conversation to which the activity belongs.
48
+ :type conversation: ~microsoft.agents.protocols.models.ConversationAccount
49
+ :param recipient: Identifies the recipient of the message.
50
+ :type recipient: ~microsoft.agents.protocols.models.ChannelAccount
51
+ :param text_format: Format of text fields Default:markdown. Possible values include: 'markdown', 'plain', 'xml'
52
+ :type text_format: str or ~microsoft.agents.protocols.models.TextFormatTypes
53
+ :param attachment_layout: The layout hint for multiple attachments. Default: list. Possible values include: 'list', 'carousel'
54
+ :type attachment_layout: str or ~microsoft.agents.protocols.models.AttachmentLayoutTypes
55
+ :param members_added: The collection of members added to the conversation.
56
+ :type members_added: list[~microsoft.agents.protocols.models.ChannelAccount]
57
+ :param members_removed: The collection of members removed from the conversation.
58
+ :type members_removed: list[~microsoft.agents.protocols.models.ChannelAccount]
59
+ :param reactions_added: The collection of reactions added to the conversation.
60
+ :type reactions_added: list[~microsoft.agents.protocols.models.MessageReaction]
61
+ :param reactions_removed: The collection of reactions removed from the conversation.
62
+ :type reactions_removed: list[~microsoft.agents.protocols.models.MessageReaction]
63
+ :param topic_name: The updated topic name of the conversation.
64
+ :type topic_name: str
65
+ :param history_disclosed: Indicates whether the prior history of the channel is disclosed.
66
+ :type history_disclosed: bool
67
+ :param locale: A locale name for the contents of the text field. The locale name is a combination of an ISO 639 two- or three-letter
68
+ culture code associated with a language and an ISO 3166 two-letter subculture code associated with a country or region.
69
+ The locale name can also correspond to a valid BCP-47 language tag.
70
+ :type locale: str
71
+ :param text: The text content of the message.
72
+ :type text: str
73
+ :param speak: The text to speak.
74
+ :type speak: str
75
+ :param input_hint: Indicates whether your agent is accepting, expecting, or ignoring user input after the message is delivered to the client.
76
+ Possible values include: 'acceptingInput', 'ignoringInput', 'expectingInput'
77
+ :type input_hint: str or ~microsoft.agents.protocols.models.InputHints
78
+ :param summary: The text to display if the channel cannot render cards.
79
+ :type summary: str
80
+ :param suggested_actions: The suggested actions for the activity.
81
+ :type suggested_actions: ~microsoft.agents.protocols.models.SuggestedActions
82
+ :param attachments: Attachments
83
+ :type attachments: list[~microsoft.agents.protocols.models.Attachment]
84
+ :param entities: Represents the entities that were mentioned in the message.
85
+ :type entities: list[~microsoft.agents.protocols.models.Entity]
86
+ :param channel_data: Contains channel-specific content.
87
+ :type channel_data: object
88
+ :param action: Indicates whether the recipient of a contactRelationUpdate was added or removed from the sender's contact list.
89
+ :type action: str
90
+ :param reply_to_id: Contains the ID of the message to which this message is a reply.
91
+ :type reply_to_id: str
92
+ :param label: A descriptive label for the activity.
93
+ :type label: str
94
+ :param value_type: The type of the activity's value object.
95
+ :type value_type: str
96
+ :param value: A value that is associated with the activity.
97
+ :type value: object
98
+ :param name: The name of the operation associated with an invoke or event activity.
99
+ :type name: str
100
+ :param relates_to: A reference to another conversation or activity.
101
+ :type relates_to: ~microsoft.agents.protocols.models.ConversationReference
102
+ :param code: The a code for endOfConversation activities that indicates why the conversation ended. Possible values include: 'unknown',
103
+ 'completedSuccessfully', 'userCancelled', 'botTimedOut', 'botIssuedInvalidMessage', 'channelFailed'
104
+ :type code: str or ~microsoft.agents.protocols.models.EndOfConversationCodes
105
+ :param expiration: The time at which the activity should be considered to be "expired" and should not be presented to the recipient.
106
+ :type expiration: datetime
107
+ :param importance: The importance of the activity. Possible values include: 'low', 'normal', 'high'
108
+ :type importance: str or ~microsoft.agents.protocols.models.ActivityImportance
109
+ :param delivery_mode: A delivery hint to signal to the recipient alternate delivery paths for the activity.
110
+ The default delivery mode is "default". Possible values include: 'normal', 'notification', 'expectReplies', 'ephemeral'
111
+ :type delivery_mode: str or ~microsoft.agents.protocols.models.DeliveryModes
112
+ :param listen_for: List of phrases and references that speech and language priming systems should listen for
113
+ :type listen_for: list[str]
114
+ :param text_highlights: The collection of text fragments to highlight when the activity contains a ReplyToId value.
115
+ :type text_highlights: list[~microsoft.agents.protocols.models.TextHighlight]
116
+ :param semantic_action: An optional programmatic action accompanying this request
117
+ :type semantic_action: ~microsoft.agents.protocols.models.SemanticAction
118
+ :param caller_id: A string containing an IRI identifying the caller of an agent. This field is not intended to be transmitted over the wire,
119
+ but is instead populated by agents and clients based on cryptographically verifiable data that asserts the identity of the callers (e.g. tokens).
120
+ :type caller_id: str
121
+ """
122
+
123
+ type: NonEmptyString
124
+ id: Optional[NonEmptyString] = None
125
+ timestamp: datetime = None
126
+ local_timestamp: datetime = None
127
+ local_timezone: NonEmptyString = None
128
+ service_url: NonEmptyString = None
129
+ channel_id: NonEmptyString = None
130
+ from_property: ChannelAccount = Field(None, alias="from")
131
+ conversation: ConversationAccount = None
132
+ recipient: ChannelAccount = None
133
+ text_format: NonEmptyString = None
134
+ attachment_layout: NonEmptyString = None
135
+ members_added: list[ChannelAccount] = None
136
+ members_removed: list[ChannelAccount] = None
137
+ reactions_added: list[MessageReaction] = None
138
+ reactions_removed: list[MessageReaction] = None
139
+ topic_name: NonEmptyString = None
140
+ history_disclosed: bool = None
141
+ locale: NonEmptyString = None
142
+ text: str = None
143
+ speak: str = None
144
+ input_hint: NonEmptyString = None
145
+ summary: NonEmptyString = None
146
+ suggested_actions: SuggestedActions = None
147
+ attachments: list[Attachment] = None
148
+ entities: list[SerializeAsAny[Entity]] = None
149
+ channel_data: object = None
150
+ action: NonEmptyString = None
151
+ reply_to_id: NonEmptyString = None
152
+ label: NonEmptyString = None
153
+ value_type: NonEmptyString = None
154
+ value: object = None
155
+ name: NonEmptyString = None
156
+ relates_to: ConversationReference = None
157
+ code: NonEmptyString = None
158
+ expiration: datetime = None
159
+ importance: NonEmptyString = None
160
+ delivery_mode: NonEmptyString = None
161
+ listen_for: list[NonEmptyString] = None
162
+ text_highlights: list[TextHighlight] = None
163
+ semantic_action: SemanticAction = None
164
+ caller_id: NonEmptyString = None
165
+
166
+ def apply_conversation_reference(
167
+ self, reference: ConversationReference, is_incoming: bool = False
168
+ ):
169
+ """
170
+ Updates this activity with the delivery information from an existing ConversationReference.
171
+
172
+ :param reference: The existing conversation reference.
173
+ :param is_incoming: Optional, True to treat the activity as an incoming activity, where the agent is the recipient; otherwise, False.
174
+ Default is False, and the activity will show the agent as the sender.
175
+
176
+ :returns: This activity, updated with the delivery information.
177
+
178
+ .. remarks::
179
+ Call GetConversationReference on an incoming activity to get a conversation reference that you can then use to update an
180
+ outgoing activity with the correct delivery information.
181
+ """
182
+ self.channel_id = reference.channel_id
183
+ self.service_url = reference.service_url
184
+ self.conversation = reference.conversation
185
+
186
+ if reference.locale is not None:
187
+ self.locale = reference.locale
188
+
189
+ if is_incoming:
190
+ self.from_property = reference.user
191
+ self.recipient = reference.agent
192
+
193
+ if reference.activity_id is not None:
194
+ self.id = reference.activity_id
195
+ else:
196
+ self.from_property = reference.agent
197
+ self.recipient = reference.user
198
+
199
+ if reference.activity_id is not None:
200
+ self.reply_to_id = reference.activity_id
201
+
202
+ return self
203
+
204
+ def as_contact_relation_update_activity(self):
205
+ """
206
+ Returns this activity as a ContactRelationUpdateActivity object; or None, if this is not that type of activity.
207
+
208
+ :returns: This activity as a message activity; or None.
209
+ """
210
+ return (
211
+ self if self.__is_activity(ActivityTypes.contact_relation_update) else None
212
+ )
213
+
214
+ def as_conversation_update_activity(self):
215
+ """
216
+ Returns this activity as a ConversationUpdateActivity object; or None, if this is not that type of activity.
217
+
218
+ :returns: This activity as a conversation update activity; or None.
219
+ """
220
+ return self if self.__is_activity(ActivityTypes.conversation_update) else None
221
+
222
+ def as_end_of_conversation_activity(self):
223
+ """
224
+ Returns this activity as an EndOfConversationActivity object; or None, if this is not that type of activity.
225
+
226
+ :returns: This activity as an end of conversation activity; or None.
227
+ """
228
+ return self if self.__is_activity(ActivityTypes.end_of_conversation) else None
229
+
230
+ def as_event_activity(self):
231
+ """
232
+ Returns this activity as an EventActivity object; or None, if this is not that type of activity.
233
+
234
+ :returns: This activity as an event activity; or None.
235
+ """
236
+ return self if self.__is_activity(ActivityTypes.event) else None
237
+
238
+ def as_handoff_activity(self):
239
+ """
240
+ Returns this activity as a HandoffActivity object; or None, if this is not that type of activity.
241
+
242
+ :returns: This activity as a handoff activity; or None.
243
+ """
244
+ return self if self.__is_activity(ActivityTypes.handoff) else None
245
+
246
+ def as_installation_update_activity(self):
247
+ """
248
+ Returns this activity as an InstallationUpdateActivity object; or None, if this is not that type of activity.
249
+
250
+ :returns: This activity as an installation update activity; or None.
251
+ """
252
+ return self if self.__is_activity(ActivityTypes.installation_update) else None
253
+
254
+ def as_invoke_activity(self):
255
+ """
256
+ Returns this activity as an InvokeActivity object; or None, if this is not that type of activity.
257
+
258
+ :returns: This activity as an invoke activity; or None.
259
+ """
260
+ return self if self.__is_activity(ActivityTypes.invoke) else None
261
+
262
+ def as_message_activity(self):
263
+ """
264
+ Returns this activity as a MessageActivity object; or None, if this is not that type of activity.
265
+
266
+ :returns: This activity as a message activity; or None.
267
+ """
268
+ return self if self.__is_activity(ActivityTypes.message) else None
269
+
270
+ def as_message_delete_activity(self):
271
+ """
272
+ Returns this activity as a MessageDeleteActivity object; or None, if this is not that type of activity.
273
+
274
+ :returns: This activity as a message delete request; or None.
275
+ """
276
+ return self if self.__is_activity(ActivityTypes.message_delete) else None
277
+
278
+ def as_message_reaction_activity(self):
279
+ """
280
+ Returns this activity as a MessageReactionActivity object; or None, if this is not that type of activity.
281
+
282
+ :return: This activity as a message reaction activity; or None.
283
+ """
284
+ return self if self.__is_activity(ActivityTypes.message_reaction) else None
285
+
286
+ def as_message_update_activity(self):
287
+ """
288
+ Returns this activity as an MessageUpdateActivity object; or None, if this is not that type of activity.
289
+
290
+ :returns: This activity as a message update request; or None.
291
+ """
292
+ return self if self.__is_activity(ActivityTypes.message_update) else None
293
+
294
+ def as_suggestion_activity(self):
295
+ """
296
+ Returns this activity as a SuggestionActivity object; or None, if this is not that type of activity.
297
+
298
+ :returns: This activity as a suggestion activity; or None.
299
+ """
300
+ return self if self.__is_activity(ActivityTypes.suggestion) else None
301
+
302
+ def as_trace_activity(self):
303
+ """
304
+ Returns this activity as a TraceActivity object; or None, if this is not that type of activity.
305
+
306
+ :returns: This activity as a trace activity; or None.
307
+ """
308
+ return self if self.__is_activity(ActivityTypes.trace) else None
309
+
310
+ def as_typing_activity(self):
311
+ """
312
+ Returns this activity as a TypingActivity object; or null, if this is not that type of activity.
313
+
314
+ :returns: This activity as a typing activity; or null.
315
+ """
316
+ return self if self.__is_activity(ActivityTypes.typing) else None
317
+
318
+ @staticmethod
319
+ def create_contact_relation_update_activity():
320
+ """
321
+ Creates an instance of the :class:`Activity` class as a ContactRelationUpdateActivity object.
322
+
323
+ :returns: The new contact relation update activity.
324
+ """
325
+ return Activity(type=ActivityTypes.contact_relation_update)
326
+
327
+ @staticmethod
328
+ def create_conversation_update_activity():
329
+ """
330
+ Creates an instance of the :class:`Activity` class as a ConversationUpdateActivity object.
331
+
332
+ :returns: The new conversation update activity.
333
+ """
334
+ return Activity(type=ActivityTypes.conversation_update)
335
+
336
+ @staticmethod
337
+ def create_end_of_conversation_activity():
338
+ """
339
+ Creates an instance of the :class:`Activity` class as an EndOfConversationActivity object.
340
+
341
+ :returns: The new end of conversation activity.
342
+ """
343
+ return Activity(type=ActivityTypes.end_of_conversation)
344
+
345
+ @staticmethod
346
+ def create_event_activity():
347
+ """
348
+ Creates an instance of the :class:`Activity` class as an EventActivity object.
349
+
350
+ :returns: The new event activity.
351
+ """
352
+ return Activity(type=ActivityTypes.event)
353
+
354
+ @staticmethod
355
+ def create_handoff_activity():
356
+ """
357
+ Creates an instance of the :class:`Activity` class as a HandoffActivity object.
358
+
359
+ :returns: The new handoff activity.
360
+ """
361
+ return Activity(type=ActivityTypes.handoff)
362
+
363
+ @staticmethod
364
+ def create_invoke_activity():
365
+ """
366
+ Creates an instance of the :class:`Activity` class as an InvokeActivity object.
367
+
368
+ :returns: The new invoke activity.
369
+ """
370
+ return Activity(type=ActivityTypes.invoke)
371
+
372
+ @staticmethod
373
+ def create_message_activity():
374
+ """
375
+ Creates an instance of the :class:`Activity` class as a MessageActivity object.
376
+
377
+ :returns: The new message activity.
378
+ """
379
+ return Activity(type=ActivityTypes.message)
380
+
381
+ def create_reply(self, text: str = None, locale: str = None):
382
+ """
383
+ Creates a new message activity as a response to this activity.
384
+
385
+ :param text: The text of the reply.
386
+ :param locale: The language code for the text.
387
+
388
+ :returns: The new message activity.
389
+
390
+ .. remarks::
391
+ The new activity sets up routing information based on this activity.
392
+ """
393
+ return Activity(
394
+ type=ActivityTypes.message,
395
+ timestamp=datetime.now(timezone.utc),
396
+ from_property=ChannelAccount(
397
+ id=self.recipient.id if self.recipient else None,
398
+ name=self.recipient.name if self.recipient else None,
399
+ ),
400
+ recipient=ChannelAccount(
401
+ id=self.from_property.id if self.from_property else None,
402
+ name=self.from_property.name if self.from_property else None,
403
+ ),
404
+ reply_to_id=(
405
+ self.id
406
+ if type != ActivityTypes.conversation_update
407
+ or self.channel_id not in ["directline", "webchat"]
408
+ else None
409
+ ),
410
+ service_url=self.service_url,
411
+ channel_id=self.channel_id,
412
+ conversation=ConversationAccount(
413
+ is_group=self.conversation.is_group,
414
+ id=self.conversation.id,
415
+ name=self.conversation.name,
416
+ ),
417
+ text=text if text else "",
418
+ locale=locale if locale else self.locale,
419
+ attachments=[],
420
+ entities=[],
421
+ )
422
+
423
+ def create_trace(
424
+ self, name: str, value: object = None, value_type: str = None, label: str = None
425
+ ):
426
+ """
427
+ Creates a new trace activity based on this activity.
428
+
429
+ :param name: The name of the trace operation to create.
430
+ :param value: Optional, the content for this trace operation.
431
+ :param value_type: Optional, identifier for the format of the value. Default is the name of type of the value.
432
+ :param label: Optional, a descriptive label for this trace operation.
433
+
434
+ :returns: The new trace activity.
435
+ """
436
+ if not value_type and value:
437
+ value_type = type(value)
438
+
439
+ return Activity(
440
+ type=ActivityTypes.trace,
441
+ timestamp=datetime.now(timezone.utc),
442
+ from_property=ChannelAccount(
443
+ id=self.recipient.id if self.recipient else None,
444
+ name=self.recipient.name if self.recipient else None,
445
+ ),
446
+ recipient=ChannelAccount(
447
+ id=self.from_property.id if self.from_property else None,
448
+ name=self.from_property.name if self.from_property else None,
449
+ ),
450
+ reply_to_id=(
451
+ self.id
452
+ if type != ActivityTypes.conversation_update
453
+ or self.channel_id not in ["directline", "webchat"]
454
+ else None
455
+ ),
456
+ service_url=self.service_url,
457
+ channel_id=self.channel_id,
458
+ conversation=ConversationAccount(
459
+ is_group=self.conversation.is_group,
460
+ id=self.conversation.id,
461
+ name=self.conversation.name,
462
+ ),
463
+ name=name,
464
+ label=label,
465
+ value_type=value_type,
466
+ value=value,
467
+ ).as_trace_activity()
468
+
469
+ @staticmethod
470
+ def create_trace_activity(
471
+ name: str, value: object = None, value_type: str = None, label: str = None
472
+ ):
473
+ """
474
+ Creates an instance of the :class:`Activity` class as a TraceActivity object.
475
+
476
+ :param name: The name of the trace operation to create.
477
+ :param value: Optional, the content for this trace operation.
478
+ :param value_type: Optional, identifier for the format of the value. Default is the name of type of the value.
479
+ :param label: Optional, a descriptive label for this trace operation.
480
+
481
+ :returns: The new trace activity.
482
+ """
483
+ if not value_type and value:
484
+ value_type = type(value)
485
+
486
+ return Activity(
487
+ type=ActivityTypes.trace,
488
+ name=name,
489
+ label=label,
490
+ value_type=value_type,
491
+ value=value,
492
+ )
493
+
494
+ @staticmethod
495
+ def create_typing_activity() -> "Activity":
496
+ """
497
+ Creates an instance of the :class:`Activity` class as a TypingActivity object.
498
+
499
+ :returns: The new typing activity.
500
+ """
501
+ return Activity(type=ActivityTypes.typing)
502
+
503
+ def get_conversation_reference(self) -> ConversationReference:
504
+ """
505
+ Creates a ConversationReference based on this activity.
506
+
507
+ :returns: A conversation reference for the conversation that contains this activity.
508
+ """
509
+
510
+ return ConversationReference(
511
+ activity_id=(
512
+ self.id
513
+ if self.type != ActivityTypes.conversation_update
514
+ or self.channel_id not in ["directline", "webchat"]
515
+ else None
516
+ ),
517
+ user=copy(self.from_property),
518
+ agent=copy(self.recipient),
519
+ conversation=copy(self.conversation),
520
+ channel_id=self.channel_id,
521
+ locale=self.locale,
522
+ service_url=self.service_url,
523
+ )
524
+
525
+ def get_mentions(self) -> list[Mention]:
526
+ """
527
+ Resolves the mentions from the entities of this activity.
528
+
529
+ :returns: The array of mentions; or an empty array, if none are found.
530
+
531
+ .. remarks::
532
+ This method is defined on the :class:`Activity` class, but is only intended for use with a message activity,
533
+ where the activity Activity.Type is set to ActivityTypes.Message.
534
+ """
535
+ _list = self.entities
536
+ return [x for x in _list if str(x.type).lower() == "mention"]
537
+
538
+ def get_reply_conversation_reference(
539
+ self, reply: ResourceResponse
540
+ ) -> ConversationReference:
541
+ """
542
+ Create a ConversationReference based on this Activity's Conversation info and the ResourceResponse from sending an activity.
543
+
544
+ :param reply: ResourceResponse returned from send_activity.
545
+
546
+ :return: A ConversationReference that can be stored and used later to delete or update the activity.
547
+ """
548
+ reference = self.get_conversation_reference()
549
+ reference.activity_id = reply.id
550
+ return reference
551
+
552
+ def has_content(self) -> bool:
553
+ """
554
+ Indicates whether this activity has content.
555
+
556
+ :returns: True, if this activity has any content to send; otherwise, false.
557
+
558
+ .. remarks::
559
+ This method is defined on the :class:`Activity` class, but is only intended for use with a message activity,
560
+ where the activity Activity.Type is set to ActivityTypes.Message.
561
+ """
562
+ if self.text and self.text.strip():
563
+ return True
564
+
565
+ if self.summary and self.summary.strip():
566
+ return True
567
+
568
+ if self.attachments and len(self.attachments) > 0:
569
+ return True
570
+
571
+ if self.channel_data:
572
+ return True
573
+
574
+ return False
575
+
576
+ def is_from_streaming_connection(self) -> bool:
577
+ """
578
+ Determine if the Activity was sent via an Http/Https connection or Streaming.
579
+ This can be determined by looking at the service_url property:
580
+ (1) All channels that send messages via http/https are not streaming.
581
+ (2) Channels that send messages via streaming have a ServiceUrl that does not begin with http/https.
582
+
583
+ :returns: True if the Activity originated from a streaming connection.
584
+ """
585
+ if self.service_url:
586
+ return not self.service_url.lower().startswith("http")
587
+ return False
588
+
589
+ def __is_activity(self, activity_type: str) -> bool:
590
+ """
591
+ Indicates whether this activity is of a specified activity type.
592
+
593
+ :param activity_type: The activity type to check for.
594
+ :return: True if this activity is of the specified activity type; otherwise, False.
595
+ """
596
+ if self.type is None:
597
+ return False
598
+
599
+ type_attribute = str(self.type).lower()
600
+ activity_type = str(activity_type).lower()
601
+
602
+ result = type_attribute.startswith(activity_type)
603
+
604
+ if result:
605
+ result = len(type_attribute) == len(activity_type)
606
+
607
+ if not result:
608
+ result = (
609
+ len(type_attribute) > len(activity_type)
610
+ and type_attribute[len(activity_type)] == "/"
611
+ )
612
+
613
+ return result
@@ -0,0 +1,6 @@
1
+ from enum import Enum
2
+
3
+
4
+ class ActivityEventNames(str, Enum):
5
+ continue_conversation = "ContinueConversation"
6
+ create_conversation = "CreateConversation"
@@ -0,0 +1,7 @@
1
+ from enum import Enum
2
+
3
+
4
+ class ActivityImportance(str, Enum):
5
+ low = "low"
6
+ normal = "normal"
7
+ high = "high"
@@ -0,0 +1,22 @@
1
+ from enum import Enum
2
+
3
+
4
+ class ActivityTypes(str, Enum):
5
+ message = "message"
6
+ contact_relation_update = "contactRelationUpdate"
7
+ conversation_update = "conversationUpdate"
8
+ typing = "typing"
9
+ end_of_conversation = "endOfConversation"
10
+ event = "event"
11
+ invoke = "invoke"
12
+ invoke_response = "invokeResponse"
13
+ delete_user_data = "deleteUserData"
14
+ message_update = "messageUpdate"
15
+ message_delete = "messageDelete"
16
+ installation_update = "installationUpdate"
17
+ message_reaction = "messageReaction"
18
+ suggestion = "suggestion"
19
+ trace = "trace"
20
+ handoff = "handoff"
21
+ command = "command"
22
+ command_result = "commandResult"
@@ -0,0 +1,24 @@
1
+ from .agents_model import AgentsModel
2
+ from ._type_aliases import NonEmptyString
3
+
4
+
5
+ class AdaptiveCardInvokeAction(AgentsModel):
6
+ """AdaptiveCardInvokeAction.
7
+
8
+ Defines the structure that arrives in the Activity.Value.Action for Invoke activity with
9
+ name of 'adaptiveCard/action'.
10
+
11
+ :param type: The Type of this Adaptive Card Invoke Action.
12
+ :type type: str
13
+ :param id: The Id of this Adaptive Card Invoke Action.
14
+ :type id: str
15
+ :param verb: The Verb of this Adaptive Card Invoke Action.
16
+ :type verb: str
17
+ :param data: The data of this Adaptive Card Invoke Action.
18
+ :type data: dict[str, object]
19
+ """
20
+
21
+ type: NonEmptyString = None
22
+ id: NonEmptyString = None
23
+ verb: NonEmptyString = None
24
+ data: dict[NonEmptyString, object] = None