TurnContext Class
Creates a new TurnContext instance. :param adapter_or_context: :param request:
- Inheritance
-
builtins.objectTurnContext
Constructor
TurnContext(adapter_or_context, request: Activity = None)
Parameters
Name | Description |
---|---|
adapter_or_context
Required
|
|
request
|
Default value: None
|
Methods
apply_conversation_reference |
Updates an activity with the delivery information from a conversation reference. Calling this after get_conversation_reference on an incoming activity will properly address the reply to a received activity. :param activity: :param reference: :param is_incoming: :return: |
copy_to |
Called when this TurnContext instance is passed into the constructor of a new TurnContext instance. Can be overridden in derived classes. :param context: :return: |
delete_activity |
Deletes an existing activity. :param id_or_reference: :return: |
get | |
get_conversation_reference |
Returns the conversation reference for an activity. This can be saved as a plain old JSON object and then later used to message the user proactively. Usage Example: reference = TurnContext.get_conversation_reference(context.request) :param activity: :return: |
get_mentions | |
get_reply_conversation_reference | |
has |
Returns True is set() has been called for a key. The cached value may be of type 'None'. :param key: :return: |
on_delete_activity |
Registers a handler to be notified of and potentially intercept an activity being deleted. :param handler: :return: |
on_send_activities |
Registers a handler to be notified of and potentially intercept the sending of activities. :param handler: :return: |
on_update_activity |
Registers a handler to be notified of and potentially intercept an activity being updated. :param handler: :return: |
remove_mention_text | |
remove_recipient_mention | |
send_activities | |
send_activity |
Sends a single activity or message to the user. :param activity_or_text: :return: |
send_trace_activity | |
set |
Caches a value for the lifetime of the current turn. :param key: :param value: :return: |
update_activity |
Replaces an existing activity. :param activity: :return: |
apply_conversation_reference
Updates an activity with the delivery information from a conversation reference. Calling this after get_conversation_reference on an incoming activity will properly address the reply to a received activity. :param activity: :param reference: :param is_incoming: :return:
static apply_conversation_reference(activity: Activity, reference: ConversationReference, is_incoming: bool = False) -> Activity
Parameters
Name | Description |
---|---|
activity
Required
|
|
reference
Required
|
|
is_incoming
|
Default value: False
|
copy_to
Called when this TurnContext instance is passed into the constructor of a new TurnContext instance. Can be overridden in derived classes. :param context: :return:
copy_to(context: TurnContext) -> None
Parameters
Name | Description |
---|---|
context
Required
|
|
delete_activity
Deletes an existing activity. :param id_or_reference: :return:
async delete_activity(id_or_reference: str | ConversationReference)
Parameters
Name | Description |
---|---|
id_or_reference
Required
|
|
get
get(key: str) -> object
Parameters
Name | Description |
---|---|
key
Required
|
|
get_conversation_reference
Returns the conversation reference for an activity. This can be saved as a plain old JSON object and then later used to message the user proactively.
Usage Example: reference = TurnContext.get_conversation_reference(context.request) :param activity: :return:
static get_conversation_reference(activity: Activity) -> ConversationReference
Parameters
Name | Description |
---|---|
activity
Required
|
|
get_mentions
static get_mentions(activity: Activity) -> List[Mention]
Parameters
Name | Description |
---|---|
activity
Required
|
|
get_reply_conversation_reference
static get_reply_conversation_reference(activity: Activity, reply: ResourceResponse) -> ConversationReference
Parameters
Name | Description |
---|---|
activity
Required
|
|
reply
Required
|
|
has
Returns True is set() has been called for a key. The cached value may be of type 'None'. :param key: :return:
has(key: str) -> bool
Parameters
Name | Description |
---|---|
key
Required
|
|
on_delete_activity
Registers a handler to be notified of and potentially intercept an activity being deleted. :param handler: :return:
on_delete_activity(handler) -> TurnContext
Parameters
Name | Description |
---|---|
handler
Required
|
|
on_send_activities
Registers a handler to be notified of and potentially intercept the sending of activities. :param handler: :return:
on_send_activities(handler) -> TurnContext
Parameters
Name | Description |
---|---|
handler
Required
|
|
on_update_activity
Registers a handler to be notified of and potentially intercept an activity being updated. :param handler: :return:
on_update_activity(handler) -> TurnContext
Parameters
Name | Description |
---|---|
handler
Required
|
|
remove_mention_text
static remove_mention_text(activity: Activity, identifier: str) -> str
Parameters
Name | Description |
---|---|
activity
Required
|
|
identifier
Required
|
|
remove_recipient_mention
static remove_recipient_mention(activity: Activity) -> str
Parameters
Name | Description |
---|---|
activity
Required
|
|
send_activities
async send_activities(activities: List[Activity]) -> List[ResourceResponse]
Parameters
Name | Description |
---|---|
activities
Required
|
|
send_activity
Sends a single activity or message to the user. :param activity_or_text: :return:
async send_activity(activity_or_text: Activity | str, speak: str = None, input_hint: str = None) -> ResourceResponse
Parameters
Name | Description |
---|---|
activity_or_text
Required
|
|
speak
|
Default value: None
|
input_hint
|
Default value: None
|
send_trace_activity
async send_trace_activity(name: str, value: object = None, value_type: str = None, label: str = None) -> ResourceResponse
Parameters
Name | Description |
---|---|
name
Required
|
|
value
|
Default value: None
|
value_type
|
Default value: None
|
label
|
Default value: None
|
set
Caches a value for the lifetime of the current turn. :param key: :param value: :return:
set(key: str, value: object) -> None
Parameters
Name | Description |
---|---|
key
Required
|
|
value
Required
|
|
update_activity
Replaces an existing activity. :param activity: :return:
async update_activity(activity: Activity)
Parameters
Name | Description |
---|---|
activity
Required
|
|
Attributes
activity
The received activity. :return:
responded
If true at least one response has been sent for the current turn of conversation. :return:
services
Map of services and other values cached for the lifetime of the turn. :return: