type2docfx
Version:
A tool to convert json format output from TypeDoc to universal reference model for DocFx to consume.
625 lines (575 loc) • 21 kB
YAML
### YamlMime:UniversalReference
items:
- uid: botbuilder.BotFrameworkAdapter
name: BotFrameworkAdapter
fullName: BotFrameworkAdapter
children:
- botbuilder.BotFrameworkAdapter.constructor
- botbuilder.BotFrameworkAdapter.continueConversation
- botbuilder.BotFrameworkAdapter.createConversation
- botbuilder.BotFrameworkAdapter.deleteActivity
- botbuilder.BotFrameworkAdapter.deleteConversationMember
- botbuilder.BotFrameworkAdapter.emulateOAuthCards
- botbuilder.BotFrameworkAdapter.getActivityMembers
- botbuilder.BotFrameworkAdapter.getConversationMembers
- botbuilder.BotFrameworkAdapter.getConversations
- botbuilder.BotFrameworkAdapter.getSignInLink
- botbuilder.BotFrameworkAdapter.getUserToken
- botbuilder.BotFrameworkAdapter.processActivity
- botbuilder.BotFrameworkAdapter.sendActivities
- botbuilder.BotFrameworkAdapter.signOutUser
- botbuilder.BotFrameworkAdapter.updateActivity
langs:
- typeScript
type: class
summary: >-
ActivityAdapter class needed to communicate with a Bot Framework channel
or the Emulator.
extends:
name: botbuilder.BotFrameworkAdapter
package: botbuilder
remarks: |-
The following example shows the typical adapter setup:
```JavaScript
const { BotFrameworkAdapter } = require('botbuilder');
const adapter = new BotFrameworkAdapter({
appId: process.env.MICROSOFT_APP_ID,
appPassword: process.env.MICROSOFT_APP_PASSWORD
});
```
- uid: botbuilder.BotFrameworkAdapter.constructor
name: BotFrameworkAdapter
children: []
type: constructor
langs:
- typeScript
summary: Creates a new BotFrameworkAdapter instance.
syntax:
content: 'new BotFrameworkAdapter(settings?: Partial<BotFrameworkAdapterSettings>)'
parameters:
- id: settings
type:
- Partial<botbuilder.BotFrameworkAdapterSettings>
description: |
(optional) configuration settings for the adapter.
optional: true
- uid: botbuilder.BotFrameworkAdapter.continueConversation
name: continueConversation
children: []
type: method
langs:
- typeScript
summary: >-
Continues a conversation with a user. This is often referred to as the
bots "Proactive Messaging"
flow as its lets the bot proactively send messages to a conversation or
user that its already
communicated with. Scenarios like sending notifications or coupons to a
user are enabled by this
method.
syntax:
content: >-
function continueConversation(reference: Partial<ConversationReference>,
logic: (context: TurnContext) => Promiseable<void>)
parameters:
- id: reference
type:
- Partial<ConversationReference>
description: >-
A `ConversationReference` saved during a previous message from a
user. This can be calculated for any incoming activity using
`TurnContext.getConversationReference(context.activity)`.
- id: logic
type:
- '(context: TurnContext) => Promiseable<void>'
description: >
A function handler that will be called to perform the bots logic
after the the adapters middleware has been run.
return:
type:
- Promise<void>
remarks: >-
The processing steps for this method are very similar to
[processActivity()](#processactivity)
in that a `TurnContext` will be created which is then routed through the
adapters middleware
before calling the passed in logic handler. The key difference being that
since an activity
wasn't actually received it has to be created. The created activity will
have its address
related fields populated but will have a `context.activity.type ===
undefined`.
```JavaScript
server.post('/api/notifyUser', async (req, res) => {
// Lookup previously saved conversation reference
const reference = await findReference(req.body.refId);
// Proactively notify the user
if (reference) {
await adapter.continueConversation(reference, async (context) => {
await context.sendActivity(req.body.message);
});
res.send(200);
} else {
res.send(404);
}
});
```
- uid: botbuilder.BotFrameworkAdapter.createConversation
name: createConversation
children: []
type: method
langs:
- typeScript
summary: >-
Starts a new conversation with a user. This is typically used to Direct
Message (DM) a member
of a group.
syntax:
content: >-
function createConversation(reference: Partial<ConversationReference>,
logic: (context: TurnContext) => Promiseable<void>)
parameters:
- id: reference
type:
- Partial<ConversationReference>
description: >-
A `ConversationReference` of the user to start a new conversation
with. This can be calculated for any incoming activity using
`TurnContext.getConversationReference(context.activity)`.
- id: logic
type:
- '(context: TurnContext) => Promiseable<void>'
description: >
A function handler that will be called to perform the bots logic
after the the adapters middleware has been run.
return:
type:
- Promise<void>
remarks: >-
The processing steps for this method are very similar to
[processActivity()](#processactivity)
in that a `TurnContext` will be created which is then routed through the
adapters middleware
before calling the passed in logic handler. The key difference being that
since an activity
wasn't actually received it has to be created. The created activity will
have its address
related fields populated but will have a `context.activity.type ===
undefined`.
```JavaScript
// Get group members conversation reference
const reference = TurnContext.getConversationReference(context.activity);
// Start a new conversation with the user
await adapter.createConversation(reference, async (ctx) => {
await ctx.sendActivity(`Hi (in private)`);
});
```
- uid: botbuilder.BotFrameworkAdapter.deleteActivity
name: deleteActivity
children: []
type: method
langs:
- typeScript
summary: >-
Deletes an activity that was previously sent to a channel. It should be
noted that not all
channels support this feature.
syntax:
content: >-
function deleteActivity(context: TurnContext, reference:
Partial<ConversationReference>)
parameters:
- id: context
type:
- TurnContext
description: Context for the current turn of conversation with the user.
- id: reference
type:
- Partial<ConversationReference>
description: |
Conversation reference information for the activity being deleted.
return:
type:
- Promise<void>
remarks: >-
Calling `TurnContext.deleteActivity()` is the preferred way of deleting
activities as that
will ensure that any interested middleware has been notified.
- uid: botbuilder.BotFrameworkAdapter.deleteConversationMember
name: deleteConversationMember
children: []
type: method
langs:
- typeScript
summary: Deletes a member from the current conversation.
syntax:
content: >-
function deleteConversationMember(context: TurnContext, memberId:
string)
parameters:
- id: context
type:
- TurnContext
description: Context for the current turn of conversation with the user.
- id: memberId
type:
- string
description: |
ID of the member to delete from the conversation.
return:
type:
- Promise<void>
- uid: botbuilder.BotFrameworkAdapter.emulateOAuthCards
name: emulateOAuthCards
children: []
type: method
langs:
- typeScript
summary: >-
Tells the token service to emulate the sending of OAuthCards for a
channel.
syntax:
content: >-
function emulateOAuthCards(contextOrServiceUrl: TurnContext | string,
emulate: boolean)
parameters:
- id: contextOrServiceUrl
type:
- TurnContext | string
description: >-
The URL of the channel server to query or a TurnContext. This can
be retrieved from `context.activity.serviceUrl`.
- id: emulate
type:
- boolean
description: |
If `true` the token service will emulate the sending of OAuthCards.
return:
type:
- Promise<void>
- uid: botbuilder.BotFrameworkAdapter.getActivityMembers
name: getActivityMembers
children: []
type: method
langs:
- typeScript
summary: Lists the members of a given activity.
syntax:
content: 'function getActivityMembers(context: TurnContext, activityId?: string)'
parameters:
- id: context
type:
- TurnContext
description: Context for the current turn of conversation with the user.
- id: activityId
type:
- string
description: >
(Optional) activity ID to enumerate. If not specified the current
activities ID will be used.
optional: true
return:
type:
- 'Promise<ChannelAccount[]>'
- uid: botbuilder.BotFrameworkAdapter.getConversationMembers
name: getConversationMembers
children: []
type: method
langs:
- typeScript
summary: Lists the members of the current conversation.
syntax:
content: 'function getConversationMembers(context: TurnContext)'
parameters:
- id: context
type:
- TurnContext
description: |
Context for the current turn of conversation with the user.
return:
type:
- 'Promise<ChannelAccount[]>'
- uid: botbuilder.BotFrameworkAdapter.getConversations
name: getConversations
children: []
type: method
langs:
- typeScript
summary: >-
Lists the Conversations in which this bot has participated for a given
channel server. The
channel server returns results in pages and each page will include a
`continuationToken`
that can be used to fetch the next page of results from the server.
syntax:
content: >-
function getConversations(contextOrServiceUrl: TurnContext | string,
continuationToken?: string)
parameters:
- id: contextOrServiceUrl
type:
- TurnContext | string
description: >-
The URL of the channel server to query or a TurnContext. This can
be retrieved from `context.activity.serviceUrl`.
- id: continuationToken
type:
- string
description: >
(Optional) token used to fetch the next page of results from the
channel server. This should be left as `undefined` to retrieve the
first page of results.
optional: true
return:
type:
- Promise<ConversationsResult>
- uid: botbuilder.BotFrameworkAdapter.getSignInLink
name: getSignInLink
children: []
type: method
langs:
- typeScript
summary: >-
Gets a signin link from the token server that can be sent as part of a
SigninCard.
syntax:
content: 'function getSignInLink(context: TurnContext, connectionName: string)'
parameters:
- id: context
type:
- TurnContext
description: Context for the current turn of conversation with the user.
- id: connectionName
type:
- string
description: |
Name of the auth connection to use.
return:
type:
- Promise<string>
- uid: botbuilder.BotFrameworkAdapter.getUserToken
name: getUserToken
children: []
type: method
langs:
- typeScript
summary: Attempts to retrieve the token for a user that's in a signin flow.
syntax:
content: >-
function getUserToken(context: TurnContext, connectionName: string,
magicCode?: string)
parameters:
- id: context
type:
- TurnContext
description: Context for the current turn of conversation with the user.
- id: connectionName
type:
- string
description: Name of the auth connection to use.
- id: magicCode
type:
- string
description: |
(Optional) Optional user entered code to validate.
optional: true
return:
type:
- Promise<TokenResponse>
- uid: botbuilder.BotFrameworkAdapter.processActivity
name: processActivity
children: []
type: method
langs:
- typeScript
summary: >-
Processes an activity received by the bots web server. This includes any
messages sent from a
user and is the method that drives what's often referred to as the bots
"Reactive Messaging"
flow.
syntax:
content: >-
function processActivity(req: WebRequest, res: WebResponse, logic:
(context: TurnContext) => Promiseable<any>)
parameters:
- id: req
type:
- botbuilder.WebRequest
description: An Express or Restify style Request object.
- id: res
type:
- botbuilder.WebResponse
description: An Express or Restify style Response object.
- id: logic
type:
- '(context: TurnContext) => Promiseable<any>'
description: >
A function handler that will be called to perform the bots logic
after the received activity has been pre-processed by the adapter
and routed through any middleware for processing.
return:
type:
- Promise<void>
remarks: >-
The following steps will be taken to process the activity:
- The identity of the sender will be verified to be either the Emulator or
a valid Microsoft
server. The bots `appId` and `appPassword` will be used during this process and the request
will be rejected if the senders identity can't be verified.
- The activity will be parsed from the body of the incoming request. An
error will be returned
if the activity can't be parsed.
- A `TurnContext` instance will be created for the received activity and
wrapped with a
[Revocable Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable).
- The context will be routed through any middleware registered with the
adapter using
[use()](#use). Middleware is executed in the order in which it's added and any middleware
can intercept or prevent further routing of the context by simply not calling the passed
in `next()` function. This is called the "Leading Edge" of the request and middleware will
get a second chance to run on the "Trailing Edge" of the request after the bots logic has run.
- Assuming the context hasn't been intercepted by a piece of middleware,
the context will be
passed to the logic handler passed in. The bot may perform an additional routing or
processing at this time. Returning a promise (or providing an `async` handler) will cause the
adapter to wait for any asynchronous operations to complete.
- Once the bots logic completes the promise chain setup by the middleware
stack will be resolved
giving middleware a second chance to run on the "Trailing Edge" of the request.
- After the middleware stacks promise chain has been fully resolved the
context object will be
`revoked()` and any future calls to the context will result in a `TypeError: Cannot perform
'set' on a proxy that has been revoked` being thrown.
```JavaScript
server.post('/api/messages', (req, res) => {
// Route received request to adapter for processing
adapter.processActivity(req, res, async (context) => {
// Process any messages received
if (context.activity.type === 'message') {
await context.sendActivity(`Hello World`);
}
});
});
```
- uid: botbuilder.BotFrameworkAdapter.sendActivities
name: sendActivities
children: []
type: method
langs:
- typeScript
summary: >-
Sends a set of activities to a channels server(s). The activities will be
sent one after
another in the order in which they're received. A response object will be
returned for each
sent activity. For `message` activities this will contain the ID of the
delivered message.
syntax:
content: >-
function sendActivities(context: TurnContext, activities:
Partial<Activity>[])
parameters:
- id: context
type:
- TurnContext
description: Context for the current turn of conversation with the user.
- id: activities
type:
- 'Partial<Activity>[]'
description: |
List of activities to send.
return:
type:
- 'Promise<ResourceResponse[]>'
remarks: >-
Calling `TurnContext.sendActivities()` or `TurnContext.sendActivity()` is
the preferred way of
sending activities as that will ensure that outgoing activities have been
properly addressed
and that any interested middleware has been notified.
The primary scenario for calling this method directly is when you want to
explicitly bypass
going through any middleware. For instance, periodically sending a
`typing` activity might
be a good reason to call this method directly as it would avoid any false
signals from being
logged.
- uid: botbuilder.BotFrameworkAdapter.signOutUser
name: signOutUser
children: []
type: method
langs:
- typeScript
summary: Signs the user out with the token server.
syntax:
content: 'function signOutUser(context: TurnContext, connectionName: string)'
parameters:
- id: context
type:
- TurnContext
description: Context for the current turn of conversation with the user.
- id: connectionName
type:
- string
description: |
Name of the auth connection to use.
return:
type:
- Promise<void>
- uid: botbuilder.BotFrameworkAdapter.updateActivity
name: updateActivity
children: []
type: method
langs:
- typeScript
summary: >-
Replaces an activity that was previously sent to a channel. It should be
noted that not all
channels support this feature.
syntax:
content: >-
function updateActivity(context: TurnContext, activity:
Partial<Activity>)
parameters:
- id: context
type:
- TurnContext
description: Context for the current turn of conversation with the user.
- id: activity
type:
- Partial<Activity>
description: |
New activity to replace a current activity with.
return:
type:
- Promise<void>
remarks: >-
Calling `TurnContext.updateActivity()` is the preferred way of updating
activities as that
will ensure that any interested middleware has been notified.
references:
- uid: botbuilder.BotFrameworkAdapter
spec.typeScript:
- name: BotFrameworkAdapter
fullName: BotFrameworkAdapter
uid: botbuilder.BotFrameworkAdapter
- uid: Partial<botbuilder.BotFrameworkAdapterSettings>
spec.typeScript:
- name: Partial<
fullName: Partial<
- name: BotFrameworkAdapterSettings
fullName: BotFrameworkAdapterSettings
uid: botbuilder.BotFrameworkAdapterSettings
- name: '>'
fullName: '>'
- uid: botbuilder.WebRequest
spec.typeScript:
- name: WebRequest
fullName: WebRequest
uid: botbuilder.WebRequest
- uid: botbuilder.WebResponse
spec.typeScript:
- name: WebResponse
fullName: WebResponse
uid: botbuilder.WebResponse