Compartilhar via


ConversationBot class

Warning

This API is now deprecated.

Use BotBuilderCloudAdapter.ConversationBot instead.

Constructors

ConversationBot(ConversationOptions)

Creates new instance of the ConversationBot.

Properties

adapter

The bot adapter.

cardAction

The action handler used for adaptive card universal actions.

command

The entrypoint of command and response.

notification

The entrypoint of notification.

Methods

requestHandler(WebRequest, WebResponse, (context: TurnContext) => Promise<any>)

The request handler to integrate with web request.

Example

For example, to use with Restify:

// The default/empty behavior
server.post("api/messages", conversationBot.requestHandler);

// Or, add your own logic
server.post("api/messages", async (req, res) => {
  await conversationBot.requestHandler(req, res, async (context) => {
    // your-own-context-logic
  });
});

Constructor Details

ConversationBot(ConversationOptions)

Creates new instance of the ConversationBot.

new ConversationBot(options: ConversationOptions)

Parameters

options
ConversationOptions

initialize options

Remarks

It's recommended to create your own adapter and storage for production environment instead of the default one.

Property Details

adapter

The bot adapter.

adapter: BotFrameworkAdapter

Property Value

BotFrameworkAdapter

cardAction

The action handler used for adaptive card universal actions.

cardAction?: CardActionBot

Property Value

command

The entrypoint of command and response.

command?: CommandBot

Property Value

notification

The entrypoint of notification.

notification?: NotificationBot

Property Value

Method Details

requestHandler(WebRequest, WebResponse, (context: TurnContext) => Promise<any>)

The request handler to integrate with web request.

Example

For example, to use with Restify:

// The default/empty behavior
server.post("api/messages", conversationBot.requestHandler);

// Or, add your own logic
server.post("api/messages", async (req, res) => {
  await conversationBot.requestHandler(req, res, async (context) => {
    // your-own-context-logic
  });
});
function requestHandler(req: WebRequest, res: WebResponse, logic?: (context: TurnContext) => Promise<any>): Promise<void>

Parameters

req

WebRequest

an Express or Restify style request object.

res

WebResponse

an Express or Restify style response object.

logic

(context: TurnContext) => Promise<any>

the additional function to handle bot context.

Returns

Promise<void>