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+ #:
33+ #: .. code-block:: python
34+ #:
35+ #: async def handle_email(
36+ #: context: TurnContext,
37+ #: state: TurnState,
38+ #: notification: AgentNotificationActivity,
39+ #: ) -> None:
40+ #: email = notification.email
41+ #: if email:
42+ #: print(f"Processing email: {email.id}")
4243AgentHandler = Callable [[TContext , TState , AgentNotificationActivity ], Awaitable [None ]]
4344
4445
@@ -57,19 +58,19 @@ class AgentNotification:
5758 defaults to all values in the AgentLifecycleEvent enum.
5859
5960 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- ```
61+ .. code-block:: python
62+
63+ from microsoft_agents.hosting import Application
64+ from microsoft_agents_a365.notifications import AgentNotification
65+
66+ app = Application( )
67+ notifications = AgentNotification(app)
68+
69+ @notifications.on_email()
70+ async def handle_email(context, state, notification):
71+ email = notification.email
72+ if email:
73+ await context.send_activity(f"Received email: {email.id}")
7374 """
7475
7576 def __init__ (
@@ -126,15 +127,15 @@ def on_agent_notification(
126127 A decorator function that registers the handler with the application.
127128
128129 Example:
129- ```python
130- from microsoft_agents.activity import ChannelId
130+ .. code-block:: python
131131
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- ```
132+ from microsoft_agents.activity import ChannelId
133+
134+ @notifications.on_agent_notification(
135+ ChannelId(channel="agents", sub_channel="email")
136+ )
137+ async def handle_custom_channel(context, state, notification):
138+ print(f"Received notification on {notification.channel}/{notification.sub_channel}")
138139 """
139140 registered_channel = channel_id .channel .lower ()
140141 registered_subchannel = (channel_id .sub_channel or "*" ).lower ()
@@ -184,11 +185,11 @@ def on_agent_lifecycle_notification(
184185 A decorator function that registers the handler with the application.
185186
186187 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- ```
188+ .. code-block:: python
189+
190+ @notifications.on_agent_lifecycle_notification("agenticuseridentitycreated")
191+ async def handle_user_created(context, state, notification):
192+ print("New user created")
192193 """
193194
194195 def route_selector (context : TurnContext ) -> bool :
@@ -234,18 +235,17 @@ def on_email(
234235 A decorator function that registers the handler with the application.
235236
236237 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- ```
238+ .. code-block:: python
239+
240+ @notifications.on_email()
241+ async def handle_email(context, state, notification):
242+ email = notification.email
243+ if email:
244+ print(f"Received email: {email.id}")
245+ response = EmailResponse.create_email_response_activity(
246+ "<p>Thank you for your email.</p>"
247+ )
248+ await context.send_activity(response)
249249 """
250250 return self .on_agent_notification (
251251 ChannelId (channel = "agents" , sub_channel = AgentSubChannel .EMAIL ), ** kwargs
@@ -266,13 +266,13 @@ def on_word(
266266 A decorator function that registers the handler with the application.
267267
268268 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- ```
269+ .. code-block:: python
270+
271+ @notifications.on_word()
272+ async def handle_word_comment(context, state, notification):
273+ comment = notification.wpx_comment
274+ if comment:
275+ print(f"Received Word comment: {comment.comment_id}")
276276 """
277277 return self .on_agent_notification (
278278 ChannelId (channel = "agents" , sub_channel = AgentSubChannel .WORD ), ** kwargs
@@ -293,13 +293,13 @@ def on_excel(
293293 A decorator function that registers the handler with the application.
294294
295295 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- ```
296+ .. code-block:: python
297+
298+ @notifications.on_excel()
299+ async def handle_excel_comment(context, state, notification):
300+ comment = notification.wpx_comment
301+ if comment:
302+ print(f"Received Excel comment: {comment.comment_id}")
303303 """
304304 return self .on_agent_notification (
305305 ChannelId (channel = "agents" , sub_channel = AgentSubChannel .EXCEL ), ** kwargs
@@ -320,13 +320,13 @@ def on_powerpoint(
320320 A decorator function that registers the handler with the application.
321321
322322 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- ```
323+ .. code-block:: python
324+
325+ @notifications.on_powerpoint()
326+ async def handle_powerpoint_comment(context, state, notification):
327+ comment = notification.wpx_comment
328+ if comment:
329+ print(f"Received PowerPoint comment: {comment.comment_id}")
330330 """
331331 return self .on_agent_notification (
332332 ChannelId (channel = "agents" , sub_channel = AgentSubChannel .POWERPOINT ), ** kwargs
@@ -347,11 +347,11 @@ def on_lifecycle(
347347 A decorator function that registers the handler with the application.
348348
349349 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- ```
350+ .. code-block:: python
351+
352+ @notifications.on_lifecycle()
353+ async def handle_any_lifecycle_event(context, state, notification):
354+ print(f"Lifecycle event type: {notification.notification_type}")
355355 """
356356 return self .on_lifecycle_notification ("*" , ** kwargs )
357357
@@ -370,11 +370,11 @@ def on_user_created(
370370 A decorator function that registers the handler with the application.
371371
372372 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- ```
373+ .. code-block:: python
374+
375+ @notifications.on_user_created()
376+ async def handle_user_created(context, state, notification):
377+ print("New agentic user identity created")
378378 """
379379 return self .on_lifecycle_notification (AgentLifecycleEvent .USERCREATED , ** kwargs )
380380
@@ -393,11 +393,11 @@ def on_user_workload_onboarding(
393393 A decorator function that registers the handler with the application.
394394
395395 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- ```
396+ .. code-block:: python
397+
398+ @notifications.on_user_workload_onboarding()
399+ async def handle_onboarding_update(context, state, notification):
400+ print("User workload onboarding status updated")
401401 """
402402 return self .on_lifecycle_notification (
403403 AgentLifecycleEvent .USERWORKLOADONBOARDINGUPDATED , ** kwargs
@@ -418,11 +418,11 @@ def on_user_deleted(
418418 A decorator function that registers the handler with the application.
419419
420420 Example:
421- ``` python
422- @notifications.on_user_deleted()
423- async def handle_user_deleted(context, state, notification):
424- print("Agentic user identity deleted")
425- ```
421+ .. code-block:: python
422+
423+ @notifications.on_user_deleted()
424+ async def handle_user_deleted(context, state, notification):
425+ print("Agentic user identity deleted")
426426 """
427427 return self .on_lifecycle_notification (AgentLifecycleEvent .USERDELETED , ** kwargs )
428428
0 commit comments