AgentNotification クラス
Microsoft 365 アプリケーションからのエージェント通知のハンドラー。
このクラスは、さまざまな Microsoft 365 チャネルとサブチャネルからの通知に応答するハンドラーを登録するためのデコレーターを提供します。 チャネル ID、サブチャネル、ライフサイクル イベントに基づくルーティングをサポートします。
コンストラクター
AgentNotification()
パラメーター
| 名前 | 説明 |
|---|---|
|
app
必須
|
ルーティング通知を処理するアプリケーション インスタンス。 |
|
known_subchannels
|
認識されたサブチャネルのオプションの iterable。 None の場合、AgentSubChannel 列挙型のすべての値が既定値になります。 規定値: None
|
|
known_lifecycle_events
|
認識されたライフサイクル イベントの省略可能。 None の場合、AgentLifecycleEvent 列挙型のすべての値が既定値になります。 規定値: None
|
例
from microsoft_agents.hosting import Application
from microsoft_agents_a365.notifications import AgentNotification
app = Application()
notifications = AgentNotification(app)
@notifications.on_email()
async def handle_email(context, state, notification):
email = notification.email
if email:
await context.send_activity(f"Received email: {email.id}")
メソッド
| __init__ | |
| __new__ | |
| on_agent_lifecycle_notification |
エージェント ライフサイクル イベント通知のハンドラーを登録します。 このデコレーターは、ユーザーの作成、削除、ワークロードオンボードの更新など、ライフサイクル イベントが発生したときに呼び出されるハンドラー関数を登録します。 |
| on_agent_notification |
特定のチャネルとサブチャネルからの通知のハンドラーを登録します。 このデコレーターは、指定されたチャネルとオプションのサブチャネルから通知を受信したときに呼び出されるハンドラー関数を登録します。 ハンドラーは、型指定された AgentNotificationActivity ラッパーを受け取ります。 |
| on_email |
Outlook メール通知のハンドラーを登録します。 これは、電子メール サブチャネルからの通知のハンドラーを登録する便利なデコレーターです。 |
| on_excel |
Microsoft Excel コメント通知のハンドラーを登録します。 これは、Excel サブチャネルからの通知のハンドラーを登録する便利なデコレーターです。 |
| on_lifecycle |
すべてのエージェント ライフサイクル イベント通知のハンドラーを登録します。 これは、ワイルドカード "*" マッチャーを使用して、すべてのライフサイクル イベントのハンドラーを登録する便利なデコレーターです。 |
| on_powerpoint |
Microsoft PowerPoint コメント通知のハンドラーを登録します。 これは、PowerPoint サブチャネルからの通知のハンドラーを登録する便利なデコレーターです。 |
| on_user_created |
ユーザー作成ライフサイクル イベントのハンドラーを登録します。 これは、エージェント ユーザー ID 作成イベント専用のハンドラーを登録する便利なデコレーターです。 |
| on_user_deleted |
ユーザー削除ライフサイクル イベントのハンドラーを登録します。 これは、エージェント ユーザー ID 削除イベント専用のハンドラーを登録する便利なデコレーターです。 |
| on_user_workload_onboarding |
ユーザー ワークロードオンボード更新イベントのハンドラーを登録します。 これは、ユーザーのワークロードオンボード状態が更新されたときに発生するイベントのハンドラーを登録する便利なデコレーターです。 |
| on_word |
Microsoft Word コメント通知のハンドラーを登録します。 これは、Word サブチャネルからの通知のハンドラーを登録する便利なデコレーターです。 |
__init__
__init__(app: Any, known_subchannels: Iterable[str | AgentSubChannel] | None = None, known_lifecycle_events: Iterable[str | AgentLifecycleEvent] | None = None)
パラメーター
| 名前 | 説明 |
|---|---|
|
app
必須
|
|
|
known_subchannels
|
規定値: None
|
|
known_lifecycle_events
|
規定値: None
|
__new__
__new__(**kwargs)
on_agent_lifecycle_notification
エージェント ライフサイクル イベント通知のハンドラーを登録します。
このデコレーターは、ユーザーの作成、削除、ワークロードオンボードの更新など、ライフサイクル イベントが発生したときに呼び出されるハンドラー関数を登録します。
on_agent_lifecycle_notification(lifecycle_event: str, **kwargs: Any)
パラメーター
| 名前 | 説明 |
|---|---|
|
lifecycle_event
必須
|
リッスンするライフサイクル イベント。 すべてのライフサイクル イベントを照合したり、AgentLifecycleEvent から特定のイベントを指定したりするには、"*" を使用します。 |
|
**kwargs
必須
|
アプリの add_route メソッドに渡される追加のキーワード引数。 |
返品
| 型 | 説明 |
|---|---|
|
ハンドラーをアプリケーションに登録するデコレーター関数。 |
例
@notifications.on_agent_lifecycle_notification("agenticuseridentitycreated")
async def handle_user_created(context, state, notification):
print("New user created")
on_agent_notification
特定のチャネルとサブチャネルからの通知のハンドラーを登録します。
このデコレーターは、指定されたチャネルとオプションのサブチャネルから通知を受信したときに呼び出されるハンドラー関数を登録します。 ハンドラーは、型指定された AgentNotificationActivity ラッパーを受け取ります。
on_agent_notification(channel_id: ChannelId, **kwargs: Any)
パラメーター
| 名前 | 説明 |
|---|---|
|
channel_id
必須
|
リッスンするチャネルと省略可能なサブチャネルを指定するチャネル ID。 サブチャネルとして "*" を使用して、すべてのサブチャネルと一致させます。 |
|
**kwargs
必須
|
アプリの add_route メソッドに渡される追加のキーワード引数。 |
返品
| 型 | 説明 |
|---|---|
|
ハンドラーをアプリケーションに登録するデコレーター関数。 |
例
from microsoft_agents.activity import ChannelId
@notifications.on_agent_notification(
ChannelId(channel="agents", sub_channel="email")
)
async def handle_custom_channel(context, state, notification):
print(f"Received notification on {notification.channel}/{notification.sub_channel}")
on_email
Outlook メール通知のハンドラーを登録します。
これは、電子メール サブチャネルからの通知のハンドラーを登録する便利なデコレーターです。
on_email(**kwargs: Any) -> Callable[[Callable[[TContext, TState, AgentNotificationActivity], Awaitable[None]]], Callable[[TurnContext, TurnState], Awaitable[None]]]
パラメーター
| 名前 | 説明 |
|---|---|
|
**kwargs
必須
|
アプリの add_route メソッドに渡される追加のキーワード引数。 |
返品
| 型 | 説明 |
|---|---|
|
Callable[[Callable[[<xref:microsoft_agents_a365.notifications.agent_notification.TContext>, <xref:microsoft_agents_a365.notifications.agent_notification.TState>, AgentNotificationActivity], Awaitable[None]]], Callable[[TurnContext, TurnState], Awaitable[None]]]
|
ハンドラーをアプリケーションに登録するデコレーター関数。 |
例
@notifications.on_email()
async def handle_email(context, state, notification):
email = notification.email
if email:
print(f"Received email: {email.id}")
response = EmailResponse.create_email_response_activity(
"<p>Thank you for your email.</p>"
)
await context.send_activity(response)
on_excel
Microsoft Excel コメント通知のハンドラーを登録します。
これは、Excel サブチャネルからの通知のハンドラーを登録する便利なデコレーターです。
on_excel(**kwargs: Any) -> Callable[[Callable[[TContext, TState, AgentNotificationActivity], Awaitable[None]]], Callable[[TurnContext, TurnState], Awaitable[None]]]
パラメーター
| 名前 | 説明 |
|---|---|
|
**kwargs
必須
|
アプリの add_route メソッドに渡される追加のキーワード引数。 |
返品
| 型 | 説明 |
|---|---|
|
Callable[[Callable[[<xref:microsoft_agents_a365.notifications.agent_notification.TContext>, <xref:microsoft_agents_a365.notifications.agent_notification.TState>, AgentNotificationActivity], Awaitable[None]]], Callable[[TurnContext, TurnState], Awaitable[None]]]
|
ハンドラーをアプリケーションに登録するデコレーター関数。 |
例
@notifications.on_excel()
async def handle_excel_comment(context, state, notification):
comment = notification.wpx_comment
if comment:
print(f"Received Excel comment: {comment.comment_id}")
on_lifecycle
すべてのエージェント ライフサイクル イベント通知のハンドラーを登録します。
これは、ワイルドカード "*" マッチャーを使用して、すべてのライフサイクル イベントのハンドラーを登録する便利なデコレーターです。
on_lifecycle(**kwargs: Any) -> Callable[[Callable[[TContext, TState, AgentNotificationActivity], Awaitable[None]]], Callable[[TurnContext, TurnState], Awaitable[None]]]
パラメーター
| 名前 | 説明 |
|---|---|
|
**kwargs
必須
|
アプリの add_route メソッドに渡される追加のキーワード引数。 |
返品
| 型 | 説明 |
|---|---|
|
Callable[[Callable[[<xref:microsoft_agents_a365.notifications.agent_notification.TContext>, <xref:microsoft_agents_a365.notifications.agent_notification.TState>, AgentNotificationActivity], Awaitable[None]]], Callable[[TurnContext, TurnState], Awaitable[None]]]
|
ハンドラーをアプリケーションに登録するデコレーター関数。 |
例
@notifications.on_lifecycle()
async def handle_any_lifecycle_event(context, state, notification):
print(f"Lifecycle event type: {notification.notification_type}")
on_powerpoint
Microsoft PowerPoint コメント通知のハンドラーを登録します。
これは、PowerPoint サブチャネルからの通知のハンドラーを登録する便利なデコレーターです。
on_powerpoint(**kwargs: Any) -> Callable[[Callable[[TContext, TState, AgentNotificationActivity], Awaitable[None]]], Callable[[TurnContext, TurnState], Awaitable[None]]]
パラメーター
| 名前 | 説明 |
|---|---|
|
**kwargs
必須
|
アプリの add_route メソッドに渡される追加のキーワード引数。 |
返品
| 型 | 説明 |
|---|---|
|
Callable[[Callable[[<xref:microsoft_agents_a365.notifications.agent_notification.TContext>, <xref:microsoft_agents_a365.notifications.agent_notification.TState>, AgentNotificationActivity], Awaitable[None]]], Callable[[TurnContext, TurnState], Awaitable[None]]]
|
ハンドラーをアプリケーションに登録するデコレーター関数。 |
例
@notifications.on_powerpoint()
async def handle_powerpoint_comment(context, state, notification):
comment = notification.wpx_comment
if comment:
print(f"Received PowerPoint comment: {comment.comment_id}")
on_user_created
ユーザー作成ライフサイクル イベントのハンドラーを登録します。
これは、エージェント ユーザー ID 作成イベント専用のハンドラーを登録する便利なデコレーターです。
on_user_created(**kwargs: Any) -> Callable[[Callable[[TContext, TState, AgentNotificationActivity], Awaitable[None]]], Callable[[TurnContext, TurnState], Awaitable[None]]]
パラメーター
| 名前 | 説明 |
|---|---|
|
**kwargs
必須
|
アプリの add_route メソッドに渡される追加のキーワード引数。 |
返品
| 型 | 説明 |
|---|---|
|
Callable[[Callable[[<xref:microsoft_agents_a365.notifications.agent_notification.TContext>, <xref:microsoft_agents_a365.notifications.agent_notification.TState>, AgentNotificationActivity], Awaitable[None]]], Callable[[TurnContext, TurnState], Awaitable[None]]]
|
ハンドラーをアプリケーションに登録するデコレーター関数。 |
例
@notifications.on_user_created()
async def handle_user_created(context, state, notification):
print("New agentic user identity created")
on_user_deleted
ユーザー削除ライフサイクル イベントのハンドラーを登録します。
これは、エージェント ユーザー ID 削除イベント専用のハンドラーを登録する便利なデコレーターです。
on_user_deleted(**kwargs: Any) -> Callable[[Callable[[TContext, TState, AgentNotificationActivity], Awaitable[None]]], Callable[[TurnContext, TurnState], Awaitable[None]]]
パラメーター
| 名前 | 説明 |
|---|---|
|
**kwargs
必須
|
アプリの add_route メソッドに渡される追加のキーワード引数。 |
返品
| 型 | 説明 |
|---|---|
|
Callable[[Callable[[<xref:microsoft_agents_a365.notifications.agent_notification.TContext>, <xref:microsoft_agents_a365.notifications.agent_notification.TState>, AgentNotificationActivity], Awaitable[None]]], Callable[[TurnContext, TurnState], Awaitable[None]]]
|
ハンドラーをアプリケーションに登録するデコレーター関数。 |
例
@notifications.on_user_deleted()
async def handle_user_deleted(context, state, notification):
print("Agentic user identity deleted")
on_user_workload_onboarding
ユーザー ワークロードオンボード更新イベントのハンドラーを登録します。
これは、ユーザーのワークロードオンボード状態が更新されたときに発生するイベントのハンドラーを登録する便利なデコレーターです。
on_user_workload_onboarding(**kwargs: Any) -> Callable[[Callable[[TContext, TState, AgentNotificationActivity], Awaitable[None]]], Callable[[TurnContext, TurnState], Awaitable[None]]]
パラメーター
| 名前 | 説明 |
|---|---|
|
**kwargs
必須
|
アプリの add_route メソッドに渡される追加のキーワード引数。 |
返品
| 型 | 説明 |
|---|---|
|
Callable[[Callable[[<xref:microsoft_agents_a365.notifications.agent_notification.TContext>, <xref:microsoft_agents_a365.notifications.agent_notification.TState>, AgentNotificationActivity], Awaitable[None]]], Callable[[TurnContext, TurnState], Awaitable[None]]]
|
ハンドラーをアプリケーションに登録するデコレーター関数。 |
例
@notifications.on_user_workload_onboarding()
async def handle_onboarding_update(context, state, notification):
print("User workload onboarding status updated")
on_word
Microsoft Word コメント通知のハンドラーを登録します。
これは、Word サブチャネルからの通知のハンドラーを登録する便利なデコレーターです。
on_word(**kwargs: Any) -> Callable[[Callable[[TContext, TState, AgentNotificationActivity], Awaitable[None]]], Callable[[TurnContext, TurnState], Awaitable[None]]]
パラメーター
| 名前 | 説明 |
|---|---|
|
**kwargs
必須
|
アプリの add_route メソッドに渡される追加のキーワード引数。 |
返品
| 型 | 説明 |
|---|---|
|
Callable[[Callable[[<xref:microsoft_agents_a365.notifications.agent_notification.TContext>, <xref:microsoft_agents_a365.notifications.agent_notification.TState>, AgentNotificationActivity], Awaitable[None]]], Callable[[TurnContext, TurnState], Awaitable[None]]]
|
ハンドラーをアプリケーションに登録するデコレーター関数。 |
例
@notifications.on_word()
async def handle_word_comment(context, state, notification):
comment = notification.wpx_comment
if comment:
print(f"Received Word comment: {comment.comment_id}")