TurnContext Interface
public interface TurnContext
Provides context for a turn of a bot.
Context provides information needed to process an incoming activity. The context object is created by a BotAdapter and persists for the length of the turn.
Field Summary
| Modifier and Type | Field and Description |
|---|---|
| static final java.lang.String | STATE_TURN_LOCALE |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
| abstract java.util.concurrent.CompletableFuture<java.lang.Void> |
deleteActivity(ConversationReference conversationReference)
Deletes an existing activity. |
| abstract java.util.concurrent.CompletableFuture<java.lang.Void> |
deleteActivity(String activityId)
Deletes an existing activity. |
| abstract Activity |
getActivity()
Gets the activity for this turn of the bot. |
|
abstract
Bot |
getAdapter()
Gets the bot adapter that created this context object. |
| abstract java.lang.String |
getLocale()
Gets the locale on this context object. |
| abstract boolean |
getResponded()
Gets a value indicating whether at least one response was sent for the current turn. |
|
abstract
Turn |
getTurnState()
Gets the collection of values cached with the context object for the lifetime of the turn. |
|
abstract
Turn |
onDeleteActivity(DeleteActivityHandler handler)
Adds a response handler for delete activity operations. |
|
abstract
Turn |
onSendActivities(SendActivitiesHandler handler)
Adds a response handler for send activity operations. |
|
abstract
Turn |
onUpdateActivity(UpdateActivityHandler handler)
Adds a response handler for update activity operations. |
|
default
java.util.concurrent.CompletableFuture<Resource |
sendActivities(Activity[] activities)
Helper method to send an array of Activities. |
|
abstract
java.util.concurrent.CompletableFuture<Resource |
sendActivities(List<Activity> activities)
Sends a list of activities to the sender of the incoming activity. |
|
abstract
java.util.concurrent.CompletableFuture<Resource |
sendActivity(Activity activity)
Sends an activity to the sender of the incoming activity. |
|
abstract
java.util.concurrent.CompletableFuture<Resource |
sendActivity(String textReplyToSend)
Sends a message activity to the sender of the incoming activity. |
|
abstract
java.util.concurrent.CompletableFuture<Resource |
sendActivity(String textReplyToSend, String speak)
Sends a message activity to the sender of the incoming activity. |
|
abstract
java.util.concurrent.CompletableFuture<Resource |
sendActivity(String textReplyToSend, String speak, InputHints inputHint)
Sends a message activity to the sender of the incoming activity. |
| default java.util.concurrent.CompletableFuture<java.lang.Void> |
sendActivityBlind(Activity activity)
Sends an Activity to the sender of the incoming Activity without returning a Resource |
| abstract void |
setLocale(String withLocale)
Set the locale on this context object. |
|
static
java.util.concurrent.CompletableFuture<Resource |
traceActivity(TurnContext turnContext, String name) |
|
static
java.util.concurrent.CompletableFuture<Resource |
traceActivity(TurnContext turnContext, String name, Object value, String valueType, String label)
Sends a trace activity to the BotAdapter for logging purposes. |
|
abstract
java.util.concurrent.CompletableFuture<Resource |
updateActivity(Activity withActivity)
Replaces an existing activity. |
Field Details
STATE_TURN_LOCALE
public static final String STATE_TURN_LOCALE
Method Details
deleteActivity
public abstract CompletableFuture
Deletes an existing activity.
Parameters:
Returns:
deleteActivity
public abstract CompletableFuture
Deletes an existing activity.
Parameters:
Returns:
getActivity
public abstract Activity getActivity()
Gets the activity for this turn of the bot.
Returns:
getAdapter
public abstract BotAdapter getAdapter()
Gets the bot adapter that created this context object.
Returns:
getLocale
public abstract String getLocale()
Gets the locale on this context object.
Returns:
getResponded
public abstract boolean getResponded()
Gets a value indicating whether at least one response was sent for the current turn.
Returns:
true if at least one response was sent for the current turn;
otherwise, false.getTurnState
public abstract TurnContextStateCollection getTurnState()
Gets the collection of values cached with the context object for the lifetime of the turn.
Returns:
onDeleteActivity
public abstract TurnContext onDeleteActivity(DeleteActivityHandler handler)
Adds a response handler for delete activity operations.
When the context's deleteActivity(String activityId) is called, the adapter calls the registered handlers in the order in which they were added to the context object.
Parameters:
Returns:
onSendActivities
public abstract TurnContext onSendActivities(SendActivitiesHandler handler)
Adds a response handler for send activity operations.
When the context's sendActivity(Activity activity) or sendActivities(List<Activity> activities) methods are called, the adapter calls the registered handlers in the order in which they were added to the context object.
Parameters:
Returns:
onUpdateActivity
public abstract TurnContext onUpdateActivity(UpdateActivityHandler handler)
Adds a response handler for update activity operations.
When the context's updateActivity(Activity withActivity) is called, the adapter calls the registered handlers in the order in which they were added to the context object.
Parameters:
Returns:
sendActivities
public default CompletableFuture
Helper method to send an array of Activities. This calls sendActivities(List<Activity> activities).
Parameters:
Returns:
sendActivities
public abstract CompletableFuture
Sends a list of activities to the sender of the incoming activity.
If the activities are successfully sent, the task result contains an array of ResourceResponse objects containing the IDs that the receiving channel assigned to the activities.
Parameters:
Returns:
sendActivity
public abstract CompletableFuture
Sends an activity to the sender of the incoming activity.
Parameters:
Returns:
sendActivity
public abstract CompletableFuture
Sends a message activity to the sender of the incoming activity.
If the activity is successfully sent, the task result contains a ResourceResponse object containing the ID that the receiving channel assigned to the activity.
See the channel's documentation for limits imposed upon the contents of textReplyToSend.
Parameters:
Returns:
sendActivity
public abstract CompletableFuture
Sends a message activity to the sender of the incoming activity.
If the activity is successfully sent, the task result contains a ResourceResponse object containing the ID that the receiving channel assigned to the activity.
See the channel's documentation for limits imposed upon the contents of textReplyToSend.
To control various characteristics of your bot's speech such as voice, rate, volume, pronunciation, and pitch, specify speak in Speech Synthesis Markup Language (SSML) format.
Parameters:
Returns:
sendActivity
public abstract CompletableFuture
Sends a message activity to the sender of the incoming activity.
If the activity is successfully sent, the task result contains a ResourceResponse object containing the ID that the receiving channel assigned to the activity.
See the channel's documentation for limits imposed upon the contents of textReplyToSend.
To control various characteristics of your bot's speech such as voice, rate, volume, pronunciation, and pitch, specify speak in Speech Synthesis Markup Language (SSML) format.
Parameters:
Returns:
sendActivityBlind
public default CompletableFuture
Sends an Activity to the sender of the incoming Activity without returning a ResourceResponse.
Parameters:
Returns:
setLocale
public abstract void setLocale(String withLocale)
Set the locale on this context object.
Parameters:
traceActivity
public static CompletableFuture
Parameters:
Returns:
traceActivity
public static CompletableFuture
Sends a trace activity to the BotAdapter for logging purposes.
Parameters:
Returns:
updateActivity
public abstract CompletableFuture
Replaces an existing activity.
If the activity is successfully sent, the task result contains a ResourceResponse object containing the ID that the receiving channel assigned to the activity.
Before calling this, set the ID of the replacement activity to the ID of the activity to replace.
Parameters:
Returns: