actions-on-googleactions-builder

Google Action Console(Cloud function editor) How to ask something to the user


Hi i'am working with google assistant, i'am using Action Builder in the Google Action Console because it seemed easy to use. I red the documentation here https://developers.google.com/assistant/conversational/overview and i followed this tutorial https://www.youtube.com/watch?v=Z1hxvniJ18s and i was able to understand the basic of how it's work and how to use Webhook. The problem is that i can give answer to the user but i can't ask him question. here is how i do it :

    app.handle('myhandler', (conv) => {
  conv.add('Hello world from fulfillment');
});

This work and when i call my webhook from my scene i get the response from the webhook. But i couldn't find how to ask something to the user. I saw that some people could use conv.ask('my question'); But when I do and I test it in the Action Console Simulator, i get an error :
Unsuccessful webhook call due to client issue:

Error querying agent endpoint. State: URL_UNREACHABLE, reason: UNREACHABLE_5xx.

and in the webhookResponse i got :

conv.ask is not a function

I have been looking a lot of topic and it seem that is DialogFlow from google cloud, but it seemed harder to implement and i didn't know if i could link it to my Action build ...

My question is how can i ask a question (and in a second time add suggestions) using Google action Console and the Could functions editor integrated in the webhook? And if it's not possible do i have to restart all my google assistant project from 0 in Dialogflow?


Solution

  • You are following tutorials on using Actions Builder, which is slightly different from Dialogflow in a few ways. One such example is that the .ask method is not used in DF. Instead, you use the .add method. They are fundamentally equivalent for each platform. So you should keep using .add for your question and also for your suggestion chips:

    conv.add('What is your favorite color?')
    conv.add(new Suggestion({title: 'My Suggestion Title'}))
    

    EDIT

    Don't forget to add const {Suggestion} = require('@assistant/conversation'); as include