actions-on-googleactions-builder

Google Action How to add a parameter to the userresponse sent to my webhook


I am working with google action on the google action console. i am able to communicate with my server and get some response with webhook. i am also able to send parameter using intent. But those parameter are prerecorded. it's can ether be a name that i choses before or a system predefined type like Date or number. But i would like to send a number that i can increment every time i call the webhook.

What i am trying to do is a list of video red with the media player. Problem is that i can use a playlist with the mediaobject but when i do that at the end of a video the next one start. But what i want to do is to ask to the user if he want to read the next video / replay this video or review the previous before starting it. So i would like to have a parameter videonumber that would be a int and after the first video end i would send it to the webhook and my server would send me the second video, at the end of the second video i would send 2 to the server. and so on to always get the next video...

More generally is there a way to send parameter to webhook for exemple is it possible to send a Boolean? I tried to add a parameter in intent but if the parameter is not said by the user, it would not be added to my Json sent to my server.

Is there a way to achieve this with google action?


Solution

  • It seems like what you are looking for is some sort of session storage. For the duration of the conversational session you will be able to set a collection of fields and properties in a JSON format which would include Number and Boolean types.

    Between turns, you can set a field in session storage:

    // Assign color to session storage
    app.handle('storeColor', conv => {
      let color = 'red';
      conv.session.params.exampleColor = color;
    });
    

    And in a later intent, perhaps a follow-up intent, you can retrieve the value from the same place:

    // Retrieve color from session storage
    app.handle('getStoredColor', conv => {
      let color = conv.session.params.exampleColor;
    });