BotFrameworkAdapter 類別
- java.
lang. Object - com.
microsoft. bot. builder. BotAdapter - com.
microsoft. bot. builder. BotFrameworkAdapter
- com.
- com.
實作
public class BotFrameworkAdapter
extends BotAdapter
implements AdapterIntegration, UserTokenProvider, ConnectorClientBuilder
可將 Bot 連線至服務端點的 Bot 配接器。 Bot 配接器會封裝驗證程式,並將活動傳送至 Bot Connector Service 並從中接收活動。 當 Bot 收到活動時,配接器會建立內容物件、將它傳遞給 Bot 的應用程式邏輯,並將回應傳回使用者的通道。
使用 use(Middleware middleware) 將 Middleware 物件新增至配接器\u2019中間件集合。 配接器會透過 Bot 中間件管線將傳入的活動處理並導向至 Bot\u2019邏輯,然後再次返回。 當每個活動進出 Bot 時,每個中間件都可以在 Bot 邏輯執行前後檢查或處理活動。
欄位摘要
| 修飾詞與類型 | 欄位與描述 |
|---|---|
| static final java.lang.String |
CONNECTOR_CLIENT_KEY
用來儲存連接器 |
| static final java.lang.String |
INVOKE_RESPONSE_KEY
儲存 Invoke |
| static final java.lang.String |
TEAMSCONNECTOR_CLIENT_KEY
儲存 Teams |
建構函式摘要
方法摘要
方法繼承來源 BotAdapter
方法繼承來源 java.lang.Object
欄位詳細資料
CONNECTOR_CLIENT_KEY
public static final String CONNECTOR_CLIENT_KEY
儲存 ConnectorClient 的金鑰。
INVOKE_RESPONSE_KEY
public static final String INVOKE_RESPONSE_KEY
儲存 InvokeResponse 的金鑰。
TEAMSCONNECTOR_CLIENT_KEY
public static final String TEAMSCONNECTOR_CLIENT_KEY
儲存 TeamsConnectorClient 的金鑰。 僅適用於測試。
建構函式詳細資料
BotFrameworkAdapter
public BotFrameworkAdapter(AppCredentials withCredentials, AuthenticationConfiguration withAuthConfig, ChannelProvider withChannelProvider, RetryStrategy withRetryStrategy, Middleware withMiddleware)
使用認證提供者,初始化 BotFrameworkAdapter 類別的新實例。
參數:
BotFrameworkAdapter
public BotFrameworkAdapter(CredentialProvider withCredentialProvider)
使用認證提供者,初始化 BotFrameworkAdapter 類別的新實例。
參數:
BotFrameworkAdapter
public BotFrameworkAdapter(CredentialProvider withCredentialProvider, AuthenticationConfiguration withAuthConfig, ChannelProvider withChannelProvider, RetryStrategy withRetryStrategy, Middleware withMiddleware)
使用認證提供者,初始化 BotFrameworkAdapter 類別的新實例。
參數:
BotFrameworkAdapter
public BotFrameworkAdapter(CredentialProvider withCredentialProvider, ChannelProvider withChannelProvider, RetryStrategy withRetryStrategy, Middleware withMiddleware)
使用認證提供者,初始化 BotFrameworkAdapter 類別的新實例。
參數:
方法詳細資料
addConnectorClientToCache
protected void addConnectorClientToCache(String serviceUrl, String appId, String scope, ConnectorClient client)
將 ConnectorClient 插入快取中。 僅適用於單元測試。
參數:
buildAppCredentials
protected CompletableFuture
為指定的 appId 和範圍建立 AppCredentials 物件。
參數:
傳回:
continueConversation
public CompletableFuture
將主動式訊息傳送至交談。
呼叫此方法,以主動將訊息傳送至交談。 大部分的通道都需要使用者起始與 Bot 的交談,Bot 才能將活動傳送給使用者。
覆寫:
BotFrameworkAdapter.continueConversation(ClaimsIdentity claimsIdentity, ConversationReference reference, BotCallbackHandler callback)參數:
傳回:
continueConversation
public CompletableFuture
將主動式訊息傳送至交談。
呼叫此方法,以主動將訊息傳送至交談。 大部分的通道都需要使用者起始與 Bot 的交談,Bot 才能將活動傳送給使用者。
覆寫:
BotFrameworkAdapter.continueConversation(ClaimsIdentity claimsIdentity, ConversationReference reference, String audience, BotCallbackHandler callback)參數:
傳回:
continueConversation
public CompletableFuture
將主動式訊息從 Bot 傳送至交談。
呼叫此方法,以主動將訊息傳送至交談。 大部分的通道都需要使用者起始與 Bot 的交談,Bot 才能將活動傳送給使用者。
此多載會要求傳入 BotId,而與 Node 實作不同。 .Net 程式代碼可讓多個 Bot 裝載在節點不支援的單一配接器中。
processActivity(String authHeader, Activity activity, BotCallbackHandler callback) runPipeline(TurnContext context, BotCallbackHandler callback)
覆寫:
BotFrameworkAdapter.continueConversation(String botAppId, ConversationReference reference, BotCallbackHandler callback)參數:
傳回:
createConnectorClient
public CompletableFuture
建立連接器用戶端異步。
參數:
傳回:
createConversation
public CompletableFuture
在指定的通道上建立交談。 若要開始交談,您的 Bot 必須知道其帳戶資訊和該通道上的用戶帳戶資訊。 大部分的通道都只支援起始直接訊息(非群組)交談。
配接器會嘗試在通道上建立新的交談,然後透過中間件管線將 conversationUpdate 活動傳送至 callback 方法。
如果與指定的使用者建立對話,活動的 Activity#getConversation 標識碼將會包含新交談的標識碼。
參數:
傳回:
createConversation
public CompletableFuture
在指定的通道上建立交談。 若要開始交談,您的 Bot 必須知道其帳戶資訊和該通道上的用戶帳戶資訊。 大部分的通道都只支援起始直接訊息(非群組)交談。
配接器會嘗試在通道上建立新的交談,然後透過中間件管線將 conversationUpdate 活動傳送至 callback 方法。
如果與指定的使用者建立對話,活動的 Activity#getConversation 標識碼將會包含新交談的標識碼。
參數:
傳回:
createOAuthAPIClient
protected CompletableFuture
建立 Bot 的 OAuth 用戶端。
注意:此保護主要是讓單元測試可以覆寫以提供模擬 OAuthClient。
參數:
傳回:
deleteActivity
public CompletableFuture
刪除交談中的現有活動。
覆寫:
BotFrameworkAdapter.deleteActivity(TurnContext context, ConversationReference reference)參數:
傳回:
deleteConversationMember
public CompletableFuture
從目前的交談中刪除成員。
參數:
傳回:
exchangeToken
public CompletableFuture
執行令牌交換作業,例如單一登錄。
參數:
傳回:
exchangeToken
public CompletableFuture
執行令牌交換作業,例如單一登錄。
參數:
傳回:
getAadTokens
public CompletableFuture
使用自定義的 AppCredentials,擷取已設定連線上特定資源的 Azure Active Directory 令牌。
參數:
傳回:
getAadTokens
public CompletableFuture
擷取已設定連線上特定資源的 Azure Active Directory 令牌。
參數:
傳回:
getActivityMembers
public CompletableFuture> getActivityMembers(TurnContextImpl context)
列出指定活動的成員。
參數:
傳回:
getActivityMembers
public CompletableFuture> getActivityMembers(TurnContextImpl context, String activityId)
列出指定活動的成員。
參數:
傳回:
getConnectorClientCache
protected Map
取得 ConnectorClient 快取。 針對單元測試。
傳回:
getConversationMembers
public CompletableFuture> getConversationMembers(TurnContextImpl context)
列出目前交談的成員。
參數:
傳回:
getConversations
public CompletableFuture
列出此 Bot 參與指定通道伺服器的交談。 通道伺服器會傳回頁面的結果,而且每個頁面都會包含 'continuationToken',可用來從伺服器擷取下一頁的結果。 此多載可能會在標準活動處理期間呼叫,此時將使用屬於目前活動處理管線一部分的 Bot 服務 URL 和認證。
參數:
傳回:
getConversations
public CompletableFuture
列出此 Bot 參與指定通道伺服器的交談。 通道伺服器會傳回頁面的結果,而且每個頁面都會包含 'continuationToken',可用來從伺服器擷取下一頁的結果。 此多載可能會在標準活動處理期間呼叫,此時將使用屬於目前活動處理管線一部分的 Bot 服務 URL 和認證。
參數:
傳回:
getConversations
public CompletableFuture
列出此 Bot 參與指定通道伺服器的交談。 通道伺服器會傳回頁面的結果,而且每個頁面都會包含 'continuationToken',可用來從伺服器擷取下一頁的結果。
參數:
context.activity.serviceUrl擷取。
傳回:
此多載可以從交談內容外部呼叫,因為只需要 Bot 的 ServiceUrl 和認證。
getConversations
public CompletableFuture
列出此 Bot 參與指定通道伺服器的交談。 通道伺服器會傳回頁面的結果,而且每個頁面都會包含 'continuationToken',可用來從伺服器擷取下一頁的結果。 此多載可以從交談內容外部呼叫,因為只需要 Bot 的 ServiceUrl 和認證。
參數:
context.activity.serviceUrl擷取。
傳回:
getCredentialsCache
protected Map
取得 AppCredentials 快取。 用於單元測試。
傳回:
getOAuthSignInLink
public CompletableFuture
使用自定義的 AppCredentials,取得要傳送給使用者以登入連線名稱的原始登入連結。
參數:
傳回:
If the task completes successfully, the result contains the raw
signin link.
getOAuthSignInLink
public CompletableFuture
使用 Bot 的 AppCredentials,取得要傳送給使用者以登入連線名稱的原始登入連結。
參數:
傳回:
If the task completes successfully, the result contains the raw
signin link.
getOAuthSignInLink
public CompletableFuture
取得要傳送給使用者以登入以取得連線名稱的原始登入連結。
參數:
傳回:
getOAuthSignInLink
public CompletableFuture
取得要傳送給使用者以登入以取得連線名稱的原始登入連結。
參數:
傳回:
getOrCreateConnectorClient
protected CompletableFuture
從快取或新建立傳回 ConnectorClient。
注意:這主要是為了允許單元測試覆寫此專案,以提供模擬 ConnectorClient
參數:
傳回:
getSignInResource
public CompletableFuture
取得要傳送給使用者以登入以取得連線名稱的原始登入連結。
參數:
傳回:
If the task completes successfully, the result contains the raw
signin link.
getSignInResource
public CompletableFuture
取得要傳送給使用者以登入以取得連線名稱的原始登入連結。
參數:
傳回:
If the task completes successfully, the result contains the raw
signin link.
getSignInResource
public CompletableFuture
取得要傳送給使用者以登入以取得連線名稱的原始登入連結。
參數:
傳回:
If the task completes successfully, the result contains the raw
signin link.
getTokenStatus
public CompletableFuture> getTokenStatus(TurnContext context, AppCredentials oAuthAppCredentials, String userId, String includeFilter)
使用自定義的AppCredentials,擷取指定使用者每個已設定連線的令牌狀態。
參數:
傳回:
getTokenStatus
public CompletableFuture> getTokenStatus(TurnContext context, String userId, String includeFilter)
擷取指定使用者每個已設定連線的令牌狀態。
參數:
傳回:
getUserToken
public CompletableFuture
嘗試使用自定義的AppCredentials擷取登入流程中使用者的令牌。
參數:
傳回:
getUserToken
public CompletableFuture
嘗試擷取登入流程中之使用者的令牌。
參數:
傳回:
keyForAppCredentials
protected static String keyForAppCredentials(String appId, String scope)
產生用來存取應用程式認證快取的金鑰。
參數:
傳回:
keyForConnectorClient
protected static String keyForConnectorClient(String serviceUrl, String appId, String scope)
產生用來存取連接器用戶端快取的金鑰。
參數:
傳回:
processActivity
public CompletableFuture
建立回合內容,並執行傳入活動的中間件管線。
參數:
傳回:
processActivity
public CompletableFuture
建立回合內容,並執行傳入活動的中間件管線。
參數:
傳回:
sendActivities
public CompletableFuture
將活動傳送至交談。
覆寫:
BotFrameworkAdapter.sendActivities(TurnContext context, List<Activity> activities)參數:
傳回:
<xref uid="com.microsoft.bot.builder.TurnContext.onSendActivities(com.microsoft.bot.builder.SendActivitiesHandler)" data-throw-if-not-resolved="false" data-raw-source="TurnContext#onSendActivities(SendActivitiesHandler)"></xref>
signOutUser
public CompletableFuture
使用自定義的 AppCredentials,以令牌伺服器將用戶登出。
參數:
傳回:
signOutUser
public CompletableFuture
使用令牌伺服器將用戶註銷。
參數:
傳回:
updateActivity
public CompletableFuture
取代交談中的現有活動。
覆寫:
BotFrameworkAdapter.updateActivity(TurnContext context, Activity activity)參數:
傳回:
呼叫此專案之前,請將取代活動的標識碼設定為要取代之活動的標識碼。 onUpdateActivity(UpdateActivityHandler handler)
use
public BotFrameworkAdapter use(Middleware middleware)
將中間件新增至配接器的管線。 中間件會在初始化時新增至配接器。 針對每個回合,配接器會依您新增中間件的順序呼叫中間件。
覆寫:
BotFrameworkAdapter.use(Middleware middleware)參數:
傳回: