2929#: notification: The typed notification activity with parsed entities.
3030#:
3131#: Example:
32- #: ```python
33- #: async def handle_email(
34- #: context: TurnContext,
35- #: state: TurnState,
36- #: notification: AgentNotificationActivity
37- #: ) -> None:
38- #: email = notification.email
39- #: if email:
40- #: print(f"Processing email: {email.id}")
41- #: ```
32+ #: >>> async def handle_email(
33+ #: ... context: TurnContext,
34+ #: ... state: TurnState,
35+ #: ... notification: AgentNotificationActivity,
36+ #: ... ) -> None:
37+ #: ... email = notification.email
38+ #: ... if email:
39+ #: ... print(f"Processing email: {email.id}")
4240AgentHandler = Callable [[TContext , TState , AgentNotificationActivity ], Awaitable [None ]]
4341
4442
@@ -57,19 +55,15 @@ class AgentNotification:
5755 defaults to all values in the AgentLifecycleEvent enum.
5856
5957 Example:
60- ```python
61- from microsoft_agents.hosting import Application
62- from microsoft_agents_a365.notifications import AgentNotification
63-
64- app = Application()
65- notifications = AgentNotification(app)
66-
67- @notifications.on_email()
68- async def handle_email(context, state, notification):
69- email = notification.email
70- if email:
71- await context.send_activity(f"Received email: {email.id}")
72- ```
58+ >>> from microsoft_agents.hosting import Application
59+ >>> from microsoft_agents_a365.notifications import AgentNotification
60+ >>> app = Application()
61+ >>> notifications = AgentNotification(app)
62+ >>> @notifications.on_email()
63+ ... async def handle_email(context, state, notification):
64+ ... email = notification.email
65+ ... if email:
66+ ... await context.send_activity(f"Received email: {email.id}")
7367 """
7468
7569 def __init__ (
@@ -126,15 +120,12 @@ def on_agent_notification(
126120 A decorator function that registers the handler with the application.
127121
128122 Example:
129- ```python
130- from microsoft_agents.activity import ChannelId
131-
132- @notifications.on_agent_notification(
133- ChannelId(channel="agents", sub_channel="email")
134- )
135- async def handle_custom_channel(context, state, notification):
136- print(f"Received notification on {notification.channel}/{notification.sub_channel}")
137- ```
123+ >>> from microsoft_agents.activity import ChannelId
124+ >>> @notifications.on_agent_notification(
125+ ... ChannelId(channel="agents", sub_channel="email")
126+ ... )
127+ ... async def handle_custom_channel(context, state, notification):
128+ ... print(f"Received notification on {notification.channel}/{notification.sub_channel}")
138129 """
139130 registered_channel = channel_id .channel .lower ()
140131 registered_subchannel = (channel_id .sub_channel or "*" ).lower ()
@@ -184,11 +175,9 @@ def on_agent_lifecycle_notification(
184175 A decorator function that registers the handler with the application.
185176
186177 Example:
187- ```python
188- @notifications.on_agent_lifecycle_notification("agenticuseridentitycreated")
189- async def handle_user_created(context, state, notification):
190- print("New user created")
191- ```
178+ >>> @notifications.on_agent_lifecycle_notification("agenticuseridentitycreated")
179+ ... async def handle_user_created(context, state, notification):
180+ ... print("New user created")
192181 """
193182
194183 def route_selector (context : TurnContext ) -> bool :
@@ -234,18 +223,15 @@ def on_email(
234223 A decorator function that registers the handler with the application.
235224
236225 Example:
237- ```python
238- @notifications.on_email()
239- async def handle_email(context, state, notification):
240- email = notification.email
241- if email:
242- print(f"Received email: {email.id}")
243- # Send a response
244- response = EmailResponse.create_email_response_activity(
245- "<p>Thank you for your email.</p>"
246- )
247- await context.send_activity(response)
248- ```
226+ >>> @notifications.on_email()
227+ ... async def handle_email(context, state, notification):
228+ ... email = notification.email
229+ ... if email:
230+ ... print(f"Received email: {email.id}")
231+ ... response = EmailResponse.create_email_response_activity(
232+ ... "<p>Thank you for your email.</p>"
233+ ... )
234+ ... await context.send_activity(response)
249235 """
250236 return self .on_agent_notification (
251237 ChannelId (channel = "agents" , sub_channel = AgentSubChannel .EMAIL ), ** kwargs
@@ -266,13 +252,11 @@ def on_word(
266252 A decorator function that registers the handler with the application.
267253
268254 Example:
269- ```python
270- @notifications.on_word()
271- async def handle_word_comment(context, state, notification):
272- comment = notification.wpx_comment
273- if comment:
274- print(f"Received Word comment: {comment.comment_id}")
275- ```
255+ >>> @notifications.on_word()
256+ ... async def handle_word_comment(context, state, notification):
257+ ... comment = notification.wpx_comment
258+ ... if comment:
259+ ... print(f"Received Word comment: {comment.comment_id}")
276260 """
277261 return self .on_agent_notification (
278262 ChannelId (channel = "agents" , sub_channel = AgentSubChannel .WORD ), ** kwargs
@@ -293,13 +277,11 @@ def on_excel(
293277 A decorator function that registers the handler with the application.
294278
295279 Example:
296- ```python
297- @notifications.on_excel()
298- async def handle_excel_comment(context, state, notification):
299- comment = notification.wpx_comment
300- if comment:
301- print(f"Received Excel comment: {comment.comment_id}")
302- ```
280+ >>> @notifications.on_excel()
281+ ... async def handle_excel_comment(context, state, notification):
282+ ... comment = notification.wpx_comment
283+ ... if comment:
284+ ... print(f"Received Excel comment: {comment.comment_id}")
303285 """
304286 return self .on_agent_notification (
305287 ChannelId (channel = "agents" , sub_channel = AgentSubChannel .EXCEL ), ** kwargs
@@ -320,13 +302,11 @@ def on_powerpoint(
320302 A decorator function that registers the handler with the application.
321303
322304 Example:
323- ```python
324- @notifications.on_powerpoint()
325- async def handle_powerpoint_comment(context, state, notification):
326- comment = notification.wpx_comment
327- if comment:
328- print(f"Received PowerPoint comment: {comment.comment_id}")
329- ```
305+ >>> @notifications.on_powerpoint()
306+ ... async def handle_powerpoint_comment(context, state, notification):
307+ ... comment = notification.wpx_comment
308+ ... if comment:
309+ ... print(f"Received PowerPoint comment: {comment.comment_id}")
330310 """
331311 return self .on_agent_notification (
332312 ChannelId (channel = "agents" , sub_channel = AgentSubChannel .POWERPOINT ), ** kwargs
@@ -347,11 +327,9 @@ def on_lifecycle(
347327 A decorator function that registers the handler with the application.
348328
349329 Example:
350- ```python
351- @notifications.on_lifecycle()
352- async def handle_any_lifecycle_event(context, state, notification):
353- print(f"Lifecycle event type: {notification.notification_type}")
354- ```
330+ >>> @notifications.on_lifecycle()
331+ ... async def handle_any_lifecycle_event(context, state, notification):
332+ ... print(f"Lifecycle event type: {notification.notification_type}")
355333 """
356334 return self .on_lifecycle_notification ("*" , ** kwargs )
357335
@@ -370,11 +348,9 @@ def on_user_created(
370348 A decorator function that registers the handler with the application.
371349
372350 Example:
373- ```python
374- @notifications.on_user_created()
375- async def handle_user_created(context, state, notification):
376- print("New agentic user identity created")
377- ```
351+ >>> @notifications.on_user_created()
352+ ... async def handle_user_created(context, state, notification):
353+ ... print("New agentic user identity created")
378354 """
379355 return self .on_lifecycle_notification (AgentLifecycleEvent .USERCREATED , ** kwargs )
380356
@@ -393,11 +369,9 @@ def on_user_workload_onboarding(
393369 A decorator function that registers the handler with the application.
394370
395371 Example:
396- ```python
397- @notifications.on_user_workload_onboarding()
398- async def handle_onboarding_update(context, state, notification):
399- print("User workload onboarding status updated")
400- ```
372+ >>> @notifications.on_user_workload_onboarding()
373+ ... async def handle_onboarding_update(context, state, notification):
374+ ... print("User workload onboarding status updated")
401375 """
402376 return self .on_lifecycle_notification (
403377 AgentLifecycleEvent .USERWORKLOADONBOARDINGUPDATED , ** kwargs
@@ -418,11 +392,9 @@ def on_user_deleted(
418392 A decorator function that registers the handler with the application.
419393
420394 Example:
421- ```python
422- @notifications.on_user_deleted()
423- async def handle_user_deleted(context, state, notification):
424- print("Agentic user identity deleted")
425- ```
395+ >>> @notifications.on_user_deleted()
396+ ... async def handle_user_deleted(context, state, notification):
397+ ... print("Agentic user identity deleted")
426398 """
427399 return self .on_lifecycle_notification (AgentLifecycleEvent .USERDELETED , ** kwargs )
428400
0 commit comments