Search code examples
javascriptdialogflow-esactions-on-google

Catch up text from voice Interactive Canvas?


I am designing a web screen with Interactive Canvas. I want to capture the text from the voice of the user speaking in the input box. It's similar to conv.input.raw in functions / index.js but I don't know what to do in public / index.html enter image description here


Solution

  • Once you have text in conv.input.raw in functions / index.js you need to pass it to website using interactiveCanvas api.

    conv.ask(new HtmlResponse({
      data: {
        userEnteredData: conv.input.raw
      }
    }));
    

    And from website you will get it in callback of interactive canvas

    interactiveCanvas.ready({
       onUpdate(data) {
           console.log('user entered text = ', data.userEnteredData);
           document.getElementById("textBox").value = data.userEnteredData;
       }
    });