TurnContext Class
Constructor
TurnContext()
Parameters
| Name | Description |
|---|---|
|
adapter_or_context
Required
|
|
|
request
|
Default value: None
|
|
identity
|
Default value: None
|
Methods
| __init__ |
Creates a new TurnContext instance. :param adapter_or_context: :param request: |
| __new__ | |
| 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_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 |
TODO: manual test for this function as it was replaced from manual code to re.escape Previously: This was a copy of the re.escape function in Python 3.8. This was done because the 3.6.x version didn't escape in the same way and handling agent names with regex characters in it would fail in TurnContext.remove_mention_text without escaping the 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: |
__init__
Creates a new TurnContext instance. :param adapter_or_context: :param request:
__init__(adapter_or_context, request: Activity = None, identity: ClaimsIdentity = None)
Parameters
| Name | Description |
|---|---|
|
request
|
Default value: None
|
|
identity
|
Default value: None
|
|
adapter_or_context
Required
|
|
__new__
__new__(**kwargs)
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
|
Returns
| Type | Description |
|---|---|
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
|
|
Returns
| Type | Description |
|---|---|
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_mentions
get_reply_conversation_reference
static get_reply_conversation_reference(activity: Activity, reply: ResourceResponse) -> ConversationReference
Parameters
| Name | Description |
|---|---|
|
activity
Required
|
|
|
reply
Required
|
|
Returns
| Type | Description |
|---|---|
has
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
|
|
Returns
| Type | Description |
|---|---|
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
|
|
Returns
| Type | Description |
|---|---|
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
|
|
Returns
| Type | Description |
|---|---|
remove_mention_text
TODO: manual test for this function as it was replaced from manual code to re.escape
Previously: This was a copy of the re.escape function in Python 3.8. This was done because the 3.6.x version didn't escape in the same way and handling agent names with regex characters in it would fail in TurnContext.remove_mention_text without escaping the text.
static remove_mention_text(activity: Activity, identifier: str) -> str
Parameters
| Name | Description |
|---|---|
|
activity
Required
|
|
|
identifier
Required
|
|
Returns
| Type | Description |
|---|---|
remove_recipient_mention
send_activities
async send_activities(activities: list[Activity]) -> list[ResourceResponse]
Parameters
| Name | Description |
|---|---|
|
activities
Required
|
|
Returns
| Type | Description |
|---|---|
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 | None
Parameters
| Name | Description |
|---|---|
|
activity_or_text
Required
|
|
|
speak
|
Default value: None
|
|
input_hint
|
Default value: None
|
Returns
| Type | Description |
|---|---|
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
|
Returns
| Type | Description |
|---|---|
set
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:
identity
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:
streaming_response
Gets a StreamingResponse instance for this turn context. This allows for streaming partial responses to the client.
turn_state
adapter
adapter: ChannelAdapterProtocol