TeamsAdapter class

An adapter that implements the Bot Framework Protocol and can be hosted in different cloud environments both public and private.

Extends

CloudAdapter

Constructors

TeamsAdapter({ BotOpenIdMetadata?: string, CallerId?: string, CertificatePrivateKey?: string, CertificateThumbprint?: string, ChannelService?: string, MicrosoftAppId?: string, MicrosoftAppTenantId?: string, OAuthApiEndpoint?: string, OAuthUrl?: string, ToBotFromChannelOpenIdMetadataUrl?: string, ToBotFromChannelTokenIssuer?: string, ToBotFromEmulatorOpenIdMetadataUrl?: string, ToChannelFromBotLoginUrl?: string, ToChannelFromBotOAuthScope?: string, ValidateAuthority?: string | boolean }, ServiceClientCredentialsFactory, AuthenticationConfiguration, ConnectorClientOptions)

Properties

botFrameworkAuthConfig
credentialsFactory

The credentials factory used by the bot adapter to create a ServiceClientCredentials object.

onTurnError

Gets or sets an error handler that can catch exceptions in the middleware or application.

userAgent

Inherited Properties

BotIdentityKey
ConnectorClientKey
ConnectorFactoryKey
OAuthScopeKey
UserTokenClientKey

Methods

process(Request<Record<string, unknown>, Record<string, undefined | string | string[]>>, INodeSocket, INodeBuffer, (context: TurnContext) => Promise<void>)
process(Request<Record<string, unknown>, Record<string, undefined | string | string[]>>, Response, (context: TurnContext) => Promise<void>)

Inherited Methods

connectNamedPipe(string, (context: TurnContext) => Promise<void>, string, string, string, number)

Used to connect the adapter to a named pipe.

continueConversation(Partial<ConversationReference>, (context: TurnContext) => Promise<void>)
createConversationAsync(string, string, string, string, ConversationParameters, (context: TurnContext) => Promise<void>)
deleteActivity(TurnContext, Partial<ConversationReference>)
processActivityDirect(string | AuthenticateRequestResult, Activity, (context: TurnContext) => Promise<void>)

Asynchronously process an activity running the provided logic function.

sendActivities(TurnContext, Partial<Activity>[])
updateActivity(TurnContext, Partial<Activity>)
use((MiddlewareHandler | Middleware)[])

Adds middleware to the adapter's pipeline.

Constructor Details

TeamsAdapter({ BotOpenIdMetadata?: string, CallerId?: string, CertificatePrivateKey?: string, CertificateThumbprint?: string, ChannelService?: string, MicrosoftAppId?: string, MicrosoftAppTenantId?: string, OAuthApiEndpoint?: string, OAuthUrl?: string, ToBotFromChannelOpenIdMetadataUrl?: string, ToBotFromChannelTokenIssuer?: string, ToBotFromEmulatorOpenIdMetadataUrl?: string, ToChannelFromBotLoginUrl?: string, ToChannelFromBotOAuthScope?: string, ValidateAuthority?: string | boolean }, ServiceClientCredentialsFactory, AuthenticationConfiguration, ConnectorClientOptions)

new TeamsAdapter(botFrameworkAuthConfig?: { BotOpenIdMetadata?: string, CallerId?: string, CertificatePrivateKey?: string, CertificateThumbprint?: string, ChannelService?: string, MicrosoftAppId?: string, MicrosoftAppTenantId?: string, OAuthApiEndpoint?: string, OAuthUrl?: string, ToBotFromChannelOpenIdMetadataUrl?: string, ToBotFromChannelTokenIssuer?: string, ToBotFromEmulatorOpenIdMetadataUrl?: string, ToChannelFromBotLoginUrl?: string, ToChannelFromBotOAuthScope?: string, ValidateAuthority?: string | boolean }, credentialsFactory?: ServiceClientCredentialsFactory, authConfiguration?: AuthenticationConfiguration, connectorClientOptions?: ConnectorClientOptions)

Parameters

botFrameworkAuthConfig

{ BotOpenIdMetadata?: string, CallerId?: string, CertificatePrivateKey?: string, CertificateThumbprint?: string, ChannelService?: string, MicrosoftAppId?: string, MicrosoftAppTenantId?: string, OAuthApiEndpoint?: string, OAuthUrl?: string, ToBotFromChannelOpenIdMetadataUrl?: string, ToBotFromChannelTokenIssuer?: string, ToBotFromEmulatorOpenIdMetadataUrl?: string, ToChannelFromBotLoginUrl?: string, ToChannelFromBotOAuthScope?: string, ValidateAuthority?: string | boolean }

credentialsFactory

ServiceClientCredentialsFactory

authConfiguration

AuthenticationConfiguration

connectorClientOptions

ConnectorClientOptions

Property Details

botFrameworkAuthConfig

botFrameworkAuthConfig?: { BotOpenIdMetadata?: string, CallerId?: string, CertificatePrivateKey?: string, CertificateThumbprint?: string, ChannelService?: string, MicrosoftAppId?: string, MicrosoftAppTenantId?: string, OAuthApiEndpoint?: string, OAuthUrl?: string, ToBotFromChannelOpenIdMetadataUrl?: string, ToBotFromChannelTokenIssuer?: string, ToBotFromEmulatorOpenIdMetadataUrl?: string, ToChannelFromBotLoginUrl?: string, ToChannelFromBotOAuthScope?: string, ValidateAuthority?: string | boolean }

Property Value

{ BotOpenIdMetadata?: string, CallerId?: string, CertificatePrivateKey?: string, CertificateThumbprint?: string, ChannelService?: string, MicrosoftAppId?: string, MicrosoftAppTenantId?: string, OAuthApiEndpoint?: string, OAuthUrl?: string, ToBotFromChannelOpenIdMetadataUrl?: string, ToBotFromChannelTokenIssuer?: string, ToBotFromEmulatorOpenIdMetadataUrl?: string, ToChannelFromBotLoginUrl?: string, ToChannelFromBotOAuthScope?: string, ValidateAuthority?: string | boolean }

credentialsFactory

The credentials factory used by the bot adapter to create a ServiceClientCredentials object.

credentialsFactory: ServiceClientCredentialsFactory

Property Value

ServiceClientCredentialsFactory

onTurnError

Gets or sets an error handler that can catch exceptions in the middleware or application.

(context: TurnContext, error: Error) => Promise<void> onTurnError

Property Value

(context: TurnContext, error: Error) => Promise<void>

A promise representing the async operation.

userAgent

string userAgent

Property Value

string

Inherited Property Details

BotIdentityKey

BotIdentityKey: symbol

Property Value

symbol

Inherited From CloudAdapter.BotIdentityKey

ConnectorClientKey

ConnectorClientKey: symbol

Property Value

symbol

Inherited From CloudAdapter.ConnectorClientKey

ConnectorFactoryKey

ConnectorFactoryKey: symbol

Property Value

symbol

Inherited From CloudAdapter.ConnectorFactoryKey

OAuthScopeKey

OAuthScopeKey: symbol

Property Value

symbol

Inherited From CloudAdapter.OAuthScopeKey

UserTokenClientKey

UserTokenClientKey: symbol

Property Value

symbol

Inherited From CloudAdapter.UserTokenClientKey

Method Details

process(Request<Record<string, unknown>, Record<string, undefined | string | string[]>>, INodeSocket, INodeBuffer, (context: TurnContext) => Promise<void>)

function process(req: Request<Record<string, unknown>, Record<string, undefined | string | string[]>>, socket: INodeSocket, head: INodeBuffer, logic: (context: TurnContext) => Promise<void>): Promise<void>

Parameters

req

Request<Record<string, unknown>, Record<string, undefined | string | string[]>>

socket

INodeSocket

head

INodeBuffer

logic

(context: TurnContext) => Promise<void>

Returns

Promise<void>

process(Request<Record<string, unknown>, Record<string, undefined | string | string[]>>, Response, (context: TurnContext) => Promise<void>)

function process(req: Request<Record<string, unknown>, Record<string, undefined | string | string[]>>, res: Response, logic: (context: TurnContext) => Promise<void>): Promise<void>

Parameters

req

Request<Record<string, unknown>, Record<string, undefined | string | string[]>>

res

Response

logic

(context: TurnContext) => Promise<void>

Returns

Promise<void>

Inherited Method Details

connectNamedPipe(string, (context: TurnContext) => Promise<void>, string, string, string, number)

Used to connect the adapter to a named pipe.

function connectNamedPipe(pipeName: string, logic: (context: TurnContext) => Promise<void>, appId: string, audience: string, callerId?: string, retryCount?: number): Promise<void>

Parameters

pipeName

string

Pipe name to connect to (note: yields two named pipe servers by appending ".incoming" and ".outgoing" to this name)

logic

(context: TurnContext) => Promise<void>

The logic function to call for resulting bot turns.

appId

string

The Bot application ID

audience

string

The audience to use for outbound communication. The will vary by cloud environment.

callerId

string

Optional, the caller ID

retryCount

number

Optional, the number of times to retry a failed connection (defaults to 7)

Returns

Promise<void>

Inherited From CloudAdapter.connectNamedPipe

continueConversation(Partial<ConversationReference>, (context: TurnContext) => Promise<void>)

Warning

This API is now deprecated.

function continueConversation(_reference: Partial<ConversationReference>, _logic: (context: TurnContext) => Promise<void>): Promise<void>

Parameters

_reference

Partial<ConversationReference>

_logic

(context: TurnContext) => Promise<void>

Returns

Promise<void>

Inherited From CloudAdapter.continueConversation

createConversationAsync(string, string, string, string, ConversationParameters, (context: TurnContext) => Promise<void>)

function createConversationAsync(botAppId: string, channelId: string, serviceUrl: string, audience: string, conversationParameters: ConversationParameters, logic: (context: TurnContext) => Promise<void>): Promise<void>

Parameters

botAppId

string

channelId

string

serviceUrl

string

audience

string

conversationParameters

ConversationParameters

logic

(context: TurnContext) => Promise<void>

Returns

Promise<void>

Inherited From CloudAdapter.createConversationAsync

deleteActivity(TurnContext, Partial<ConversationReference>)

function deleteActivity(context: TurnContext, reference: Partial<ConversationReference>): Promise<void>

Parameters

context

TurnContext

reference

Partial<ConversationReference>

Returns

Promise<void>

Inherited From CloudAdapter.deleteActivity

processActivityDirect(string | AuthenticateRequestResult, Activity, (context: TurnContext) => Promise<void>)

Asynchronously process an activity running the provided logic function.

function processActivityDirect(authorization: string | AuthenticateRequestResult, activity: Activity, logic: (context: TurnContext) => Promise<void>): Promise<void>

Parameters

authorization

string | AuthenticateRequestResult

The authorization header in the format: "Bearer [longString]" or the AuthenticateRequestResult for this turn.

activity

Activity

The activity to process.

logic

(context: TurnContext) => Promise<void>

The logic function to apply.

Returns

Promise<void>

a promise representing the asynchronous operation.

Inherited From CloudAdapter.processActivityDirect

sendActivities(TurnContext, Partial<Activity>[])

function sendActivities(context: TurnContext, activities: Partial<Activity>[]): Promise<ResourceResponse[]>

Parameters

context

TurnContext

activities

Partial<Activity>[]

Returns

Promise<ResourceResponse[]>

Inherited From CloudAdapter.sendActivities

updateActivity(TurnContext, Partial<Activity>)

function updateActivity(context: TurnContext, activity: Partial<Activity>): Promise<void | ResourceResponse>

Parameters

context

TurnContext

activity

Partial<Activity>

Returns

Promise<void | ResourceResponse>

Inherited From CloudAdapter.updateActivity

use((MiddlewareHandler | Middleware)[])

Adds middleware to the adapter's pipeline.

function use(middlewares: (MiddlewareHandler | Middleware)[]): TeamsAdapter

Parameters

middlewares

(MiddlewareHandler | Middleware)[]

The middleware or middleware handlers to add.

Returns

The updated adapter object.

Remarks

Middleware is added to the adapter at initialization time. Each turn, the adapter calls its middleware in the order in which you added it.

Inherited From CloudAdapter.use