I'm trying to use the Java DialogFlow API to build a webhook response for Google Assistant. My responses work fine in DialogFlow's 'Try It Now' feature, but Google Assistant keeps saying "isn't responding right now. Try again later".
As an experiment, I managed to get Google Assistant working by using a non-webhook response (i.e. through the normal DialogFlow Intent UI). When I looked in my History, I see the working response looked like this:
"queryText": "GOOGLE_ASSISTANT_WELCOME",
"action": "input.welcome",
"fulfillmentMessages": [
{
"text": {
"text": [
"[{\"type\":\"simple_response\",\"platform\":\"google\",\"textToSpeech\":\"Hello\"}]"
]
}
}
This seems very strange to me, as the text body is actually a further JSON encoded object (containing textToSpeech amongst other fields). When I use the Java DialogFlow API like this:
List<String> texts = new ArrayList<>();
texts.add( "Foo" );
message.setText( new GoogleCloudDialogflowV2IntentMessageText().setText( texts ));
I get a different format:
"fulfillmentMessages": [
{
"text": {
"text": [ "Foo" ]
}
}
That Google Assistant says:
MalformedResponse: Failed to parse Dialogflow response into AppResponse because of empty speech response"
Even if I try forcing an encoded JSON string as my text body, it still doesn't seem to work.
What is the correct way to return a default message format so that Google Assistant can read it? I tried simpleResponse
and that didn't work either