BotAdapter Class

Inheritance
BotAdapter

Constructor

BotAdapter(on_turn_error: Callable[[TurnContext, Exception], Awaitable] = None)

Parameters

Name Description
on_turn_error
default value: None

Methods

continue_conversation

Sends a proactive message to a conversation. Call this method to proactively send a message to a conversation. Most channels require a user to initiate a conversation with a bot before the bot can send activities to the user.

single tenant the Adapters (Console, Test, etc) but is critical to the BotFrameworkAdapter which is multi-tenant aware. :param reference: A reference to the conversation to continue. :type reference: ConversationReference :param callback: The method to call for the resulting bot turn. :type callback: Callable :param claims_identity: A <xref:botframework.connector.auth.ClaimsIdentity> for the conversation. :type claims_identity: <xref:botframework.connector.auth.ClaimsIdentity> :param audience:A value signifying the recipient of the proactive message. :type audience: str

create_conversation

Starts a new conversation with a user. Used to direct message to a member of a group.

delete_activity

Deletes an existing activity.

run_pipeline

Called by the parent class to run the adapters middleware set and calls the passed in callback() handler at the end of the chain.

send_activities

Sends a set of activities to the user. An array of responses from the server will be returned.

update_activity

Replaces an existing activity.

use

Registers a middleware handler with the adapter.

continue_conversation

Sends a proactive message to a conversation. Call this method to proactively send a message to a conversation. Most channels require a user to initiate a conversation with a bot before the bot can send activities to the user.

single tenant the Adapters (Console, Test, etc) but is critical to the BotFrameworkAdapter which is multi-tenant aware. :param reference: A reference to the conversation to continue. :type reference: ConversationReference :param callback: The method to call for the resulting bot turn. :type callback: Callable :param claims_identity: A <xref:botframework.connector.auth.ClaimsIdentity> for the conversation. :type claims_identity: <xref:botframework.connector.auth.ClaimsIdentity> :param audience:A value signifying the recipient of the proactive message. :type audience: str

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

Parameters

Name Description
bot_id

The application ID of the bot. This parameter is ignored in

default value: None
reference
Required
callback
Required
claims_identity
default value: None
audience
default value: None

create_conversation

Starts a new conversation with a user. Used to direct message to a member of a group.

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)

Parameters

Name Description
reference
Required

The conversation reference that contains the tenant

logic

The logic to use for the creation of the conversation

default value: None
conversation_parameters

The information to use to create the conversation

default value: None
channel_id
<xref:typing.str>

The ID for the channel.

default value: None
service_url
<xref:typing.str>

The channel's service URL endpoint.

default value: None
credentials
<xref:botframework.connector.auth.AppCredentials>

The application credentials for the bot.

default value: None

Returns

Type Description

A task representing the work queued to execute.

Exceptions

Type Description
It raises a generic exception error.

Remarks

To start a conversation, your bot must know its account information and the user's account information on that channel. Most channels only support initiating a direct message (non-group) conversation. The adapter attempts to create a new conversation on the channel, and then sends a conversation update activity through its middleware pipeline to the the callback method. If the conversation is established with the specified users, the ID of the activity will contain the ID of the new conversation.

delete_activity

Deletes an existing activity.

abstract async delete_activity(context: TurnContext, reference: ConversationReference)

Parameters

Name Description
context
Required

The context object for the turn.

reference
Required

Conversation reference for the activity to delete.

run_pipeline

Called by the parent class to run the adapters middleware set and calls the passed in callback() handler at the end of the chain.

async run_pipeline(context: TurnContext, callback: Callable[[TurnContext], Awaitable] = None)

Parameters

Name Description
context
Required

The context object for the turn.

callback
Callable[[<xref:TurnContext>],<xref: Awaitable>]

A callback method to run at the end of the pipeline.

default value: None

send_activities

Sends a set of activities to the user. An array of responses from the server will be returned.

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

Parameters

Name Description
context
Required

The context object for the turn.

activities
Required
List[<xref:Activity>]

The activities to send.

update_activity

Replaces an existing activity.

abstract async update_activity(context: TurnContext, activity: Activity)

Parameters

Name Description
context
Required

The context object for the turn.

activity
Required

New replacement activity.

use

Registers a middleware handler with the adapter.

use(middleware)

Parameters

Name Description
middleware
Required

The middleware to register.

Attributes

BOT_CALLBACK_HANDLER_KEY

BOT_CALLBACK_HANDLER_KEY = 'BotCallbackHandler'

BOT_CONNECTOR_CLIENT_KEY

BOT_CONNECTOR_CLIENT_KEY = 'ConnectorClient'

BOT_IDENTITY_KEY

BOT_IDENTITY_KEY = 'BotIdentity'

BOT_OAUTH_SCOPE_KEY

BOT_OAUTH_SCOPE_KEY = 'botbuilder.core.BotAdapter.OAuthScope'