BotFrameworkAdapter クラス

ボットをサービス エンドポイントに接続するためのアダプターを定義します。

BotFrameworkAdapter クラスの新しいインスタンスを初期化します。

継承
BotFrameworkAdapter
BotFrameworkAdapter
BotFrameworkAdapter

コンストラクター

BotFrameworkAdapter(settings: BotFrameworkAdapterSettings)

パラメーター

名前 説明
settings
必須

アダプターを初期化するための設定

注釈

ボット アダプターでは、認証プロセスのカプセル化、および Bot Connector Service との間でのアクティビティの送受信が行われます。 ボットがアクティビティを受信すると、アダプターによってコンテキスト オブジェクトが作成され、ボットのアプリケーション ロジックに渡され、応答がユーザーのチャネルに返されます。 アダプターは、ボット ミドルウェア パイプラインを介して受信アクティビティを処理し、ボットのロジックに転送してから、もう一度やり直します。 各アクティビティがボットを出入りして流れる際、ボット ロジックの実行前と実行後のどちらでも、各ミドルウェアがアクティビティを検査または操作できます。

メソッド

can_process_outgoing_activity
continue_conversation

ユーザーとの会話を続行します。

と は、通常、config.pyMicrosoftAppId パラメーターにあります。 :type bot_id: <xref:typing.str> :p aram claims_identity: ボット要求 ID :type claims_identity: <xref:botframework.connector.auth.ClaimsIdentity> :p aram 対象ユーザー: :type audience: <xref:typing.str>

create_connector_client

ConnectorClientProvider.create_connector_clientの実装。

create_conversation

ユーザーとの新しい会話を開始します。 グループのメンバーにメッセージを送信するために使用されます。

delete_activity

以前にチャネルに送信されたアクティビティを削除します。 すべてのチャネルがこの機能をサポートしているわけではないことに注意してください。

注意

のactivity_idは ConversationReference 、削除するアクティビティを識別します。

delete_conversation_member

現在の会話からメンバーを削除します。

exchange_token
exchange_token_from_credentials
get_aad_tokens

構成された接続上の特定のリソースの Azure Active Directory トークンを取得します。

TurnContext のアクティビティから。 :type user_id: str :p aram oauth_app_credentials: (省略可能) OAuth の AppCredentials。 :type oauth_app_credentials: <xref:botframework.connector.auth.AppCredential>

get_activity_members

特定のアクティビティのメンバーをListsします。

指定しない場合は、現在のアクティビティ ID が使用されます。

get_conversation_member

現在の会話のメンバーを取得します。

get_conversation_members

現在の会話のメンバーをListsします。

get_conversations

このボットが特定のチャネル サーバーに参加した会話をListsします。

context.activity.serviceUrl :type service_url: str

get_oauth_sign_in_link

接続名のサインインのためにユーザーに送信される未加工のサインイン リンクを取得します。

get_sign_in_resource_from_user
get_sign_in_resource_from_user_and_credentials
get_token_status

指定されたユーザーに対して構成された各接続のトークンの状態を取得します。

空白にすると、構成されているすべての接続のトークンの状態が返されます。 :type include_filter: str :p aram oauth_app_credentials: (省略可能) OAuth の AppCredentials。 :type oauth_app_credentials: <xref:botframework.connector.auth.AppCredential>

get_user_token

ログイン フロー内のユーザーのトークンの取得を試みます。

:p aram magic_code" (省略可能) ユーザーは、:str magic_code" str :p aram oauth_app_credentials: (省略可能) OAuth の AppCredentials を検証するコードを入力しました。 :type oauth_app_credentials: <xref:botframework.connector.auth.AppCredential>

key_for_app_credentials
key_for_connector_client
parse_request

要求 :p aram req: :return を解析して検証します。

process_activity

ターン コンテキストを作成し、受信アクティビティのミドルウェア パイプラインを実行します。

process_activity_with_identity
process_outgoing_activity
send_activities
sign_out_user

トークン サーバーを使用してユーザーをサインアウトします。

update_activity

以前にチャネルに送信されたアクティビティを置き換えます。 すべてのチャネルがこの機能をサポートしているわけではないことに注意してください。

can_process_outgoing_activity

can_process_outgoing_activity(activity: Activity) -> bool

パラメーター

名前 説明
activity
必須

continue_conversation

ユーザーとの会話を続行します。

と は、通常、config.pyMicrosoftAppId パラメーターにあります。 :type bot_id: <xref:typing.str> :p aram claims_identity: ボット要求 ID :type claims_identity: <xref:botframework.connector.auth.ClaimsIdentity> :p aram 対象ユーザー: :type audience: <xref:typing.str>

async continue_conversation(reference: ConversationReference, callback: Callable, bot_id: str = None, claims_identity: ClaimsIdentity = None, audience: str = None)

パラメーター

名前 説明
reference
必須
callback
必須
bot_id
既定値: None
claims_identity
既定値: None
audience
既定値: None

戻り値

説明

実行するキューに登録された作業を表すタスク。

例外

説明
It raises an argument null exception.

注釈

これは、ボットが既に通信中の会話またはユーザーにメッセージをプロアクティブに送信できるため、多くの場合、ボットプロアクティブ メッセージング フローと呼ばれます。 この関数では、通知やクーポンをユーザーに送信するなどのシナリオが有効になります。

create_connector_client

ConnectorClientProvider.create_connector_clientの実装。

async create_connector_client(service_url: str, identity: ClaimsIdentity = None, audience: str = None) -> ConnectorClient

パラメーター

名前 説明
service_url
必須

サービス URL

identity

要求 ID

既定値: None
audience
既定値: None

戻り値

説明

<xref:botbuilder.core.ConnectorClient> クラスのインスタンス。

create_conversation

ユーザーとの新しい会話を開始します。 グループのメンバーにメッセージを送信するために使用されます。

async create_conversation(reference: ConversationReference, logic: Callable[[TurnContext], Awaitable] = None, conversation_parameters: ConversationParameters = None, channel_id: str = None, service_url: str = None, credentials: AppCredentials = None)

パラメーター

名前 説明
reference
必須

テナントを含む会話参照

logic

会話の作成に使用するロジック

既定値: None
conversation_parameters

会話の作成に使用する情報

既定値: None
channel_id
<xref:typing.str>

チャネルの ID。

既定値: None
service_url
<xref:typing.str>

チャネルのサービス URL エンドポイント。

既定値: None
credentials
<xref:botframework.connector.auth.AppCredentials>

ボットのアプリケーション資格情報。

既定値: None

戻り値

説明

実行するキューに登録された作業を表すタスク。

例外

説明
It raises a generic exception error.

注釈

会話を開始するには、ボットがそのアカウント情報と、そのチャネル上のユーザーのアカウント情報を知っている必要があります。 ほとんどのチャネルでは、直接メッセージ (グループ以外) の会話の開始のみがサポートされます。 アダプターはチャネルで新しい会話を作成し、ミドルウェア パイプラインを介してコールバック メソッドに会話更新アクティビティを送信します。 指定したユーザーとの会話が確立されている場合、アクティビティの ID には新しい会話の ID が含まれます。

delete_activity

以前にチャネルに送信されたアクティビティを削除します。 すべてのチャネルがこの機能をサポートしているわけではないことに注意してください。

注意

のactivity_idは ConversationReference 、削除するアクティビティを識別します。

async delete_activity(context: TurnContext, reference: ConversationReference)

パラメーター

名前 説明
context
必須

ターンのコンテキスト オブジェクト

reference
必須

削除するアクティビティの会話参照

戻り値

説明

実行するキューに登録された作業を表すタスク

例外

説明
A exception error

delete_conversation_member

現在の会話からメンバーを削除します。

async delete_conversation_member(context: TurnContext, member_id: str) -> None

パラメーター

名前 説明
context
必須

ターンのコンテキスト オブジェクト

member_id
必須
str

会話から削除するメンバーの ID

戻り値

説明

実行するキューに登録された作業を表すタスク。</返します

例外

説明
A exception error

exchange_token

async exchange_token(turn_context: TurnContext, connection_name: str, user_id: str, exchange_request: TokenExchangeRequest) -> TokenResponse

パラメーター

名前 説明
turn_context
必須
connection_name
必須
user_id
必須
exchange_request
必須

exchange_token_from_credentials

async exchange_token_from_credentials(turn_context: TurnContext, oauth_app_credentials: AppCredentials, connection_name: str, user_id: str, exchange_request: TokenExchangeRequest) -> TokenResponse

パラメーター

名前 説明
turn_context
必須
oauth_app_credentials
必須
connection_name
必須
user_id
必須
exchange_request
必須

get_aad_tokens

構成された接続上の特定のリソースの Azure Active Directory トークンを取得します。

TurnContext のアクティビティから。 :type user_id: str :p aram oauth_app_credentials: (省略可能) OAuth の AppCredentials。 :type oauth_app_credentials: <xref:botframework.connector.auth.AppCredential>

async get_aad_tokens(context: TurnContext, connection_name: str, resource_urls: List[str], user_id: str = None, oauth_app_credentials: AppCredentials = None) -> Dict[str, TokenResponse]

パラメーター

名前 説明
context
必須
connection_name
必須
resource_urls
必須
user_id
既定値: None
oauth_app_credentials
既定値: None

戻り値

説明

対応する :class:'botbuilder.schema.TokenResponse' へのリソース URL のディクショナリ

get_activity_members

特定のアクティビティのメンバーをListsします。

指定しない場合は、現在のアクティビティ ID が使用されます。

async get_activity_members(context: TurnContext, activity_id: str)

パラメーター

名前 説明
context
必須
activity_id
必須

戻り値

説明

アクティビティのメンバーの一覧

例外

説明
An exception error

get_conversation_member

現在の会話のメンバーを取得します。

async get_conversation_member(context: TurnContext, member_id: str) -> ChannelAccount

パラメーター

名前 説明
context
必須

ターンのコンテキスト オブジェクト

member_id
必須
str

メンバー ID

戻り値

説明

現在の会話のメンバー

例外

説明
<xref:A TypeError if missing member_id>, <xref:service_url>, <xref:or conversation.id>

get_conversation_members

現在の会話のメンバーをListsします。

async get_conversation_members(context: TurnContext)

パラメーター

名前 説明
context
必須

ターンのコンテキスト オブジェクト

戻り値

説明

現在の会話のメンバーの一覧

例外

説明
TypeError if missing service_url or conversation.id

get_conversations

このボットが特定のチャネル サーバーに参加した会話をListsします。

context.activity.serviceUrl :type service_url: str

async get_conversations(service_url: str, credentials: AppCredentials, continuation_token: str = None)

パラメーター

名前 説明
continuation_token
str

結果の前のページからの継続トークン

既定値: None
service_url
必須
credentials
必須

戻り値

説明

実行するキューに登録された作業を表すタスク

例外

説明
A generic exception error

注釈

チャネル サーバーはページで結果を返し、各ページには、サーバーから結果の次のページをフェッチするために使用できる continuationToken が含まれます。 タスクが正常に完了すると、結果には現在の会話のメンバーのページが含まれます。 このオーバーロードは、ボットのサービス URL と資格情報のみが必要とされるため、会話のコンテキスト外から呼び出される場合があります。

接続名のサインインのためにユーザーに送信される未加工のサインイン リンクを取得します。

async get_oauth_sign_in_link(context: TurnContext, connection_name: str, final_redirect: str = None, oauth_app_credentials: AppCredentials = None) -> str

パラメーター

名前 説明
context
必須

ユーザーとの会話の現在のターンのコンテキスト

connection_name
必須
str

使用する認証接続の名前

final_redirect

OAuth フローがリダイレクトする最後の URL。

既定値: None
oauth_app_credentials
<xref:botframework.connector.auth.AppCredential>

(省略可能)OAuth の AppCredentials。

既定値: None

戻り値

説明

タスクが正常に完了すると、結果に生のサインイン リンクが含まれます

get_sign_in_resource_from_user

async get_sign_in_resource_from_user(turn_context: TurnContext, connection_name: str, user_id: str, final_redirect: str = None) -> SignInUrlResponse

パラメーター

名前 説明
turn_context
必須
connection_name
必須
user_id
必須
final_redirect
既定値: None

get_sign_in_resource_from_user_and_credentials

async get_sign_in_resource_from_user_and_credentials(turn_context: TurnContext, oauth_app_credentials: AppCredentials, connection_name: str, user_id: str, final_redirect: str = None) -> SignInUrlResponse

パラメーター

名前 説明
turn_context
必須
oauth_app_credentials
必須
connection_name
必須
user_id
必須
final_redirect
既定値: None

get_token_status

指定されたユーザーに対して構成された各接続のトークンの状態を取得します。

空白にすると、構成されているすべての接続のトークンの状態が返されます。 :type include_filter: str :p aram oauth_app_credentials: (省略可能) OAuth の AppCredentials。 :type oauth_app_credentials: <xref:botframework.connector.auth.AppCredential>

async get_token_status(context: TurnContext, connection_name: str = None, user_id: str = None, include_filter: str = None, oauth_app_credentials: AppCredentials = None) -> List[TokenStatus]

パラメーター

名前 説明
context
必須
connection_name
既定値: None
user_id
既定値: None
include_filter
既定値: None
oauth_app_credentials
既定値: None

戻り値

説明

<xref:botframework.connector.token_api.modelsTokenStatus> の配列

get_user_token

ログイン フロー内のユーザーのトークンの取得を試みます。

:p aram magic_code" (省略可能) ユーザーは、:str magic_code" str :p aram oauth_app_credentials: (省略可能) OAuth の AppCredentials を検証するコードを入力しました。 :type oauth_app_credentials: <xref:botframework.connector.auth.AppCredential>

async get_user_token(context: TurnContext, connection_name: str, magic_code: str = None, oauth_app_credentials: AppCredentials = None) -> TokenResponse

パラメーター

名前 説明
context
必須
connection_name
必須
magic_code
既定値: None
oauth_app_credentials
既定値: None

戻り値

説明
:<xref:class>:’TokenResponse`

トークン応答

例外

説明
An exception error

key_for_app_credentials

static key_for_app_credentials(app_id: str, scope: str)

パラメーター

名前 説明
app_id
必須
scope
必須

key_for_connector_client

static key_for_connector_client(service_url: str, app_id: str, scope: str)

パラメーター

名前 説明
service_url
必須
app_id
必須
scope
必須

parse_request

要求 :p aram req: :return を解析して検証します。

async static parse_request(req)

パラメーター

名前 説明
req
必須

process_activity

ターン コンテキストを作成し、受信アクティビティのミドルウェア パイプラインを実行します。

async process_activity(req, auth_header: str, logic: Callable)

パラメーター

名前 説明
req
必須
<xref:typing.str>

受信アクティビティ

auth_header
必須
<xref:typing.str>

要求の HTTP 認証ヘッダー

logic
必須

アダプターのミドルウェア パイプラインの最後に実行するロジック。

戻り値

説明

実行するキューに登録された作業を表すタスク。

注釈

このクラスは、ボット Web サーバーによって受信されたアクティビティを処理します。 これには、ユーザーから送信されたメッセージが含まれます。これは、ボット の事後対応型メッセージング フローと呼ばれるものを駆動するメソッドです。 このメソッドを呼び出して、メッセージを会話に反応的に送信します。 タスクが正常に完了すると、 InvokeResponse が返されます。それ以外の場合は 。 null が返されます。

process_activity_with_identity

async process_activity_with_identity(activity: Activity, identity: ClaimsIdentity, logic: Callable)

パラメーター

名前 説明
activity
必須
identity
必須
logic
必須

process_outgoing_activity

async process_outgoing_activity(turn_context: TurnContext, activity: Activity) -> ResourceResponse

パラメーター

名前 説明
turn_context
必須
activity
必須

send_activities

async send_activities(context: TurnContext, activities: List[Activity]) -> List[ResourceResponse]

パラメーター

名前 説明
context
必須
activities
必須

sign_out_user

トークン サーバーを使用してユーザーをサインアウトします。

async sign_out_user(context: TurnContext, connection_name: str = None, user_id: str = None, oauth_app_credentials: AppCredentials = None)

パラメーター

名前 説明
context
必須

ユーザーとの会話の現在のターンのコンテキスト

connection_name
str

使用する認証接続の名前

既定値: None
user_id
str

サインアウトするユーザーのユーザー ID

既定値: None
oauth_app_credentials
<xref:botframework.connector.auth.AppCredential>

(省略可能)OAuth の AppCredentials。

既定値: None

update_activity

以前にチャネルに送信されたアクティビティを置き換えます。 すべてのチャネルがこの機能をサポートしているわけではないことに注意してください。

async update_activity(context: TurnContext, activity: Activity)

パラメーター

名前 説明
context
必須

ターンのコンテキスト オブジェクト

activity
必須

新しい置換アクティビティ

戻り値

説明

実行するキューに登録された作業を表すタスク

例外

説明
A generic exception error

注釈

アクティビティが正常に送信された場合、タスクの結果には、受信チャネルがアクティビティに割り当てた ID を含むオブジェクトが含まれます ResourceResponse 。 この関数を呼び出す前に、置換アクティビティの ID を置換するアクティビティの ID に設定します。