i'm actually trying to use Dialogflow v2 with java sdk in android.
I can already make queries to dialogflow but I wanted to send some payload with my query. Because of this, I discovered the QueryParameters object and I already set it with my desired payload.
The problem is, I have both QueryInput and QueryParameters defined but there is no documentation (or code references in the source code) about how to apply the parameters to the input before trying to detect the intent.
SessionsClient.create().use { sessionsClient ->
// Set the session name using the sessionId (UUID) and projectID
val session = SessionName.of(PROJECT_ID, UUID)
System.out.println("Session Path: $session")
// Set the text (input) and language code (en) for the query
val textInput = TextInput.newBuilder().setText(text).setLanguageCode(LANGUAGE_CODE)
// Build the query with the TextInput
val queryInput = QueryInput.newBuilder().setText(textInput).build()
// Set payload
val payload = "{someid: $someid}"
val queryParameters = QueryParameters.newBuilder().setPayload(Struct.parseFrom(payload.toByteArray())).build()
// (HERE I NEED TO ADD THE PARAMETERS TO INPUT)
// Performs the detect intent request
val response = sessionsClient.detectIntent(session, queryInput)
// returns the query result
return response.queryResult
}
After hours of deep searching, I managed to find the DetectIntentRequest class.
//Build the request
val request = DetectIntentRequest.newBuilder()
.setSession(session.toString())
.setQueryInput(queryInput)
.setQueryParams(queryParameters)
.build()
// Performs the detect intent request
val response = sessionsClient.detectIntent(request)
Note: if you are using other languages probably you 'll have a third parameter in detectIntent function to place your queryParameters