public ActionRequest
Defines requirements of an object that represents a request to the Actions webhook.
The JSON protocol for Actions on Google is described here. If Dialogflow is used as an intermediary, the JSON protocol between Dialogflow and the webhook is as described here.
The Java objects (POJO's) that represent the JSON payload are referred to as "binding classes". AppRequest and WebhookRequest (if Dialogflow is used) are binding classes that represent an Actions on Google request and Dialogflow request respectively. ActionRequest wraps these binding classes and provides additional helper methods for intuitive and easier access to frequently used features.
Modifier and Type | Method and Description |
---|---|
com.google.api.services.actions_fulfillment.v2.model.AppRequest |
getAppRequest()
The binding class (POJO) that represents an Actions on Google request.
|
com.google.api.services.actions_fulfillment.v2.model.Argument |
getArgument(java.lang.String name) |
java.util.List<com.google.api.services.actions_fulfillment.v2.model.Surface> |
getAvailableSurfaces() |
ActionContext |
getContext(java.lang.String name)
|
java.util.List<com.google.actions.api.ActionContext> |
getContexts() |
java.util.Map<java.lang.String,java.lang.Object> |
getConversationData()
Key-value pair data that is persisted across turns in the same
conversation session.
|
com.google.api.services.actions_fulfillment.v2.model.DateTime |
getDateTime() |
com.google.api.services.actions_fulfillment.v2.model.Device |
getDevice() |
java.lang.String |
getIntent() |
java.util.Locale |
getLocale()
Returns the Locale of the user.
|
java.lang.String |
getMediaStatus() |
java.lang.Object |
getParameter(java.lang.String name)
|
com.google.api.services.actions_fulfillment.v2.model.Location |
getPlace() |
com.google.api.services.actions_fulfillment.v2.model.RawInput |
getRawInput() |
java.lang.String |
getRawText() |
java.lang.Integer |
getRepromptCount()
Returns the number of subsequent reprompts related to silent input from the
user. This should be used along with the NO_INPUT intent to reprompt the
user for input in cases where the Google Assistant could not pick up any
speech or null if request has no information about reprompts.
|
java.lang.String |
getSelectedOption() |
java.lang.String |
getSessionId() |
com.google.api.services.actions_fulfillment.v2.model.Surface |
getSurface() |
com.google.api.services.actions_fulfillment.v2.model.User |
getUser() |
boolean |
getUserConfirmation() |
java.util.Map<java.lang.String,java.lang.Object> |
getUserStorage()
Key-value pair data that is persisted across conversations for a
particular user.
|
com.google.api.services.dialogflow_fulfillment.v2.model.WebhookRequest |
getWebhookRequest()
Binding class (POJO) that represents a Dialogflow request. This is set only
if the request is routed through Dialogflow.
|
boolean |
hasCapability(java.lang.String capability) |
java.lang.Boolean |
isFinalPrompt()
Returns true if it is the final reprompt related to silent input from the
user, false otherwise. This should be used along with the NO_INPUT intent
to give the final response to the user after multiple silences and should
be a response which ends the conversation.
|
boolean |
isInSandbox() |
boolean |
isPermissionGranted() |
boolean |
isSignInGranted()
Returns the status of a sign in request.
|
boolean |
isUpdateRegistered()
Returns the status of a register updates request.
|
com.google.api.services.dialogflow_fulfillment.v2.model.WebhookRequest getWebhookRequest()
Binding class (POJO) that represents a Dialogflow request. This is set only if the request is routed through Dialogflow.
com.google.api.services.actions_fulfillment.v2.model.AppRequest getAppRequest()
The binding class (POJO) that represents an Actions on Google request.
java.lang.String getIntent()
com.google.api.services.actions_fulfillment.v2.model.User getUser()
java.util.Locale getLocale()
Returns the Locale of the user.
com.google.api.services.actions_fulfillment.v2.model.RawInput getRawInput()
java.lang.String getRawText()
com.google.api.services.actions_fulfillment.v2.model.Surface getSurface()
com.google.api.services.actions_fulfillment.v2.model.Device getDevice()
java.util.List<com.google.api.services.actions_fulfillment.v2.model.Surface> getAvailableSurfaces()
java.util.Map<java.lang.String,java.lang.Object> getUserStorage()
Key-value pair data that is persisted across conversations for a particular user.
java.util.Map<java.lang.String,java.lang.Object> getConversationData()
Key-value pair data that is persisted across turns in the same conversation session.
boolean isInSandbox()
java.lang.String getSessionId()
java.lang.Integer getRepromptCount()
Returns the number of subsequent reprompts related to silent input from the user. This should be used along with the NO_INPUT intent to reprompt the user for input in cases where the Google Assistant could not pick up any speech or null if request has no information about reprompts.
int repromptCount = request.getRepromptCount();
if (repromptCount == 0) {
responseBuilder.add("What was that?").build();
} else if (repromptCount == 1) {
responseBuilder.add(
"Sorry I didn't catch that. Could you please repeat?").build();
} else if (request.isFinalReprompt()) {
responseBuilder
.add("Okay let's try this again later.")
.endConversation()
.build();
}
java.lang.Boolean isFinalPrompt()
Returns true if it is the final reprompt related to silent input from the user, false otherwise. This should be used along with the NO_INPUT intent to give the final response to the user after multiple silences and should be a response which ends the conversation.
Returns null if no information about final reprompt is available in the request.
int repromptCount = request.getRepromptCount();
if (reprmptCount == 0) {
responseBuilder.add("What was that?").build();
} else if (repromptCount == 1) {
responseBuilder.add(
"Sorry I didn't catch that. Could you please repeat?").build();
} else if (request.isFinalReprompt()) {
responseBuilder
.add("Okay let's try this again later.")
.endConversation()
.build();
}
com.google.api.services.actions_fulfillment.v2.model.Argument getArgument(java.lang.String name)
name
- Name of the argument.java.lang.Object getParameter(java.lang.String name)
name
- Name of the parameter.ActionContext getContext(java.lang.String name)
java.util.List<com.google.actions.api.ActionContext> getContexts()
boolean hasCapability(java.lang.String capability)
capability
- boolean isSignInGranted()
Returns the status of a sign in request.
boolean isUpdateRegistered()
Returns the status of a register updates request.
com.google.api.services.actions_fulfillment.v2.model.Location getPlace()
boolean isPermissionGranted()
boolean getUserConfirmation()
com.google.api.services.actions_fulfillment.v2.model.DateTime getDateTime()
java.lang.String getMediaStatus()
java.lang.String getSelectedOption()