TurnContextImpl Class
- java.
lang. Object - com.
microsoft. bot. builder. TurnContextImpl
- com.
Implements
public class TurnContextImpl
implements TurnContext, java.lang.AutoCloseable
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. Bot Middleware
Constructor Summary
| Constructor | Description |
|---|---|
| TurnContextImpl(BotAdapter withAdapter, Activity withActivity) |
Creates a context object. |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
| void |
close()
Auto |
| java.util.concurrent.CompletableFuture<java.lang.Void> |
deleteActivity(ConversationReference conversationReference)
Deletes an existing activity. |
| java.util.concurrent.CompletableFuture<java.lang.Void> |
deleteActivity(String activityId)
Deletes an existing activity. |
| void |
finalize()
Auto call of #close. |
| Activity |
getActivity()
Gets the activity associated with this turn; or |
|
Bot |
getAdapter()
Gets the bot adapter that created this context object. |
| java.util.List<Activity> |
getBufferedReplyActivities()
Gets a list of activities to send when `context. |
| java.lang.String |
getLocale()
Gets the locale on this context object. |
| boolean |
getResponded()
Indicates whether at least one response was sent for the current turn. |
|
Turn |
getTurnState()
Gets the services registered on this context object. |
|
Turn |
onDeleteActivity(DeleteActivityHandler handler)
Adds a response handler for delete activity operations. |
|
Turn |
onSendActivities(SendActivitiesHandler handler)
Adds a response handler for send activity operations. |
|
Turn |
onUpdateActivity(UpdateActivityHandler handler)
Adds a response handler for update activity operations. |
|
java.util.concurrent.CompletableFuture<Resource |
sendActivities(List<Activity> activities)
Sends a set of activities to the sender of the incoming activity. |
|
java.util.concurrent.CompletableFuture<Resource |
sendActivity(Activity activityToSend)
Sends an activity to the sender of the incoming activity. |
|
java.util.concurrent.CompletableFuture<Resource |
sendActivity(String textReplyToSend)
Sends a message activity to the sender of the incoming activity. |
|
java.util.concurrent.CompletableFuture<Resource |
sendActivity(String textReplyToSend, String speak)
Sends a message activity to the sender of the incoming activity. |
|
java.util.concurrent.CompletableFuture<Resource |
sendActivity(String textReplyToSend, String speak, InputHints inputHint)
Sends a message activity to the sender of the incoming activity. |
| void |
setLocale(String withLocale)
Set the locale on this context object. |
|
java.util.concurrent.CompletableFuture<Resource |
updateActivity(Activity withActivity)
Replaces an existing activity. |
Methods inherited from java.lang.Object
Constructor Details
TurnContextImpl
public TurnContextImpl(BotAdapter withAdapter, Activity withActivity)
Creates a context object.
Parameters:
null for a
turn for a proactive message.
Method Details
close
public void close()
AutoClosable#close.
Throws:
deleteActivity
public CompletableFuture
Deletes an existing activity. The conversation reference's ConversationReference#getActivityId indicates the activity in the conversation to delete.
Parameters:
Returns:
deleteActivity
public CompletableFuture
Deletes an existing activity.
Parameters:
Returns:
finalize
public void finalize()
Auto call of #close.
Overrides:
TurnContextImpl.finalize()getActivity
public Activity getActivity()
Gets the activity associated with this turn; or null when processing a proactive message.
getAdapter
public BotAdapter getAdapter()
Gets the bot adapter that created this context object.
Returns:
getBufferedReplyActivities
public List
Gets a list of activities to send when `context.Activity.DeliveryMode == 'expectReplies'.
Returns:
getLocale
public String getLocale()
Gets the locale on this context object.
Returns:
getResponded
public boolean getResponded()
Indicates whether at least one response was sent for the current turn.
Returns:
true if at least one response was sent for the current turn.getTurnState
public TurnContextStateCollection getTurnState()
Gets the services registered on this context object.
Returns:
onDeleteActivity
public TurnContext onDeleteActivity(DeleteActivityHandler handler)
Adds a response handler for delete activity operations.
Parameters:
Returns:
onSendActivities
public TurnContext onSendActivities(SendActivitiesHandler handler)
Adds a response handler for send activity operations.
Parameters:
Returns:
onUpdateActivity
public TurnContext onUpdateActivity(UpdateActivityHandler handler)
Adds a response handler for update activity operations.
Parameters:
Returns:
sendActivities
public CompletableFuture
Sends a set of activities to the sender of the incoming activity.
Parameters:
Returns:
sendActivity
public CompletableFuture
Sends an activity to the sender of the incoming activity.
Parameters:
Returns:
sendActivity
public 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 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 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:
setLocale
public void setLocale(String withLocale)
Set the locale on this context object.
Parameters:
updateActivity
public CompletableFuture
Replaces an existing activity.
Parameters:
Returns: