Simple Counter using Dialogflow Conv.Data or Conv.User.Storage









up vote
1
down vote

favorite












I am looking to create a super simple counter in a conversation in a firebase function using actions for google.



the documentation recommends:



app.intent('Default Welcome Intent', conv => 
conv.data.someProperty = 'someValue'
)


However, typescript does not recognise any kind of dot notation after conv.data as a value, and does not allow the code to deploy.



however, as far as I can determine, using



app.intent('Default Welcome Intent', conv => 
conv.data["someProperty"] = 1;
)


Does, but doesn't seem to permit counting the int...



I have tried:



conv.data['currentIndex'] = parseInt(conv.data['currentIndex']) + 1;


conv.data['currentIndex'] = parseInt(conv.data['currentIndex'])++;


conv.data['currentIndex'] += 1;


I feel I am missing something super fundamental here.



Thanks










share|improve this question

























    up vote
    1
    down vote

    favorite












    I am looking to create a super simple counter in a conversation in a firebase function using actions for google.



    the documentation recommends:



    app.intent('Default Welcome Intent', conv => 
    conv.data.someProperty = 'someValue'
    )


    However, typescript does not recognise any kind of dot notation after conv.data as a value, and does not allow the code to deploy.



    however, as far as I can determine, using



    app.intent('Default Welcome Intent', conv => 
    conv.data["someProperty"] = 1;
    )


    Does, but doesn't seem to permit counting the int...



    I have tried:



    conv.data['currentIndex'] = parseInt(conv.data['currentIndex']) + 1;


    conv.data['currentIndex'] = parseInt(conv.data['currentIndex'])++;


    conv.data['currentIndex'] += 1;


    I feel I am missing something super fundamental here.



    Thanks










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I am looking to create a super simple counter in a conversation in a firebase function using actions for google.



      the documentation recommends:



      app.intent('Default Welcome Intent', conv => 
      conv.data.someProperty = 'someValue'
      )


      However, typescript does not recognise any kind of dot notation after conv.data as a value, and does not allow the code to deploy.



      however, as far as I can determine, using



      app.intent('Default Welcome Intent', conv => 
      conv.data["someProperty"] = 1;
      )


      Does, but doesn't seem to permit counting the int...



      I have tried:



      conv.data['currentIndex'] = parseInt(conv.data['currentIndex']) + 1;


      conv.data['currentIndex'] = parseInt(conv.data['currentIndex'])++;


      conv.data['currentIndex'] += 1;


      I feel I am missing something super fundamental here.



      Thanks










      share|improve this question













      I am looking to create a super simple counter in a conversation in a firebase function using actions for google.



      the documentation recommends:



      app.intent('Default Welcome Intent', conv => 
      conv.data.someProperty = 'someValue'
      )


      However, typescript does not recognise any kind of dot notation after conv.data as a value, and does not allow the code to deploy.



      however, as far as I can determine, using



      app.intent('Default Welcome Intent', conv => 
      conv.data["someProperty"] = 1;
      )


      Does, but doesn't seem to permit counting the int...



      I have tried:



      conv.data['currentIndex'] = parseInt(conv.data['currentIndex']) + 1;


      conv.data['currentIndex'] = parseInt(conv.data['currentIndex'])++;


      conv.data['currentIndex'] += 1;


      I feel I am missing something super fundamental here.



      Thanks







      node.js typescript google-cloud-functions dialogflow actions-on-google






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 9 at 18:48









      Tristram Tolliday

      376




      376






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          I think you need to explicitly specify types of variables you want to use.



          Try defining interfaces like:



          //use this in conv.data

          interface ConvData
          counter?: number


          // use in conv.user.storage
          interface UserStorage
          location?: string
          name?: string



          and initializing the app as:



          const app = dialogflow<ConvData, UserStorage>( debug: true )


          and then using



          app.intent('Default Welcome Intent', conv => 
          conv.data.counter = 1
          )


          Reference: Actions on Google TS sample



          https://github.com/actions-on-google/actions-on-google-nodejs/blob/935d0f9adfe78a4f9eb83ab4bb0fb9f6a7db2001/samples/ts/app/name-psychic/functions/src/index.tsx



          Hope that helps!






          share|improve this answer


















          • 1




            Perfect, that's worked a treat. thanks @sai-raj
            – Tristram Tolliday
            Nov 10 at 22:02











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53231680%2fsimple-counter-using-dialogflow-conv-data-or-conv-user-storage%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote



          accepted










          I think you need to explicitly specify types of variables you want to use.



          Try defining interfaces like:



          //use this in conv.data

          interface ConvData
          counter?: number


          // use in conv.user.storage
          interface UserStorage
          location?: string
          name?: string



          and initializing the app as:



          const app = dialogflow<ConvData, UserStorage>( debug: true )


          and then using



          app.intent('Default Welcome Intent', conv => 
          conv.data.counter = 1
          )


          Reference: Actions on Google TS sample



          https://github.com/actions-on-google/actions-on-google-nodejs/blob/935d0f9adfe78a4f9eb83ab4bb0fb9f6a7db2001/samples/ts/app/name-psychic/functions/src/index.tsx



          Hope that helps!






          share|improve this answer


















          • 1




            Perfect, that's worked a treat. thanks @sai-raj
            – Tristram Tolliday
            Nov 10 at 22:02















          up vote
          2
          down vote



          accepted










          I think you need to explicitly specify types of variables you want to use.



          Try defining interfaces like:



          //use this in conv.data

          interface ConvData
          counter?: number


          // use in conv.user.storage
          interface UserStorage
          location?: string
          name?: string



          and initializing the app as:



          const app = dialogflow<ConvData, UserStorage>( debug: true )


          and then using



          app.intent('Default Welcome Intent', conv => 
          conv.data.counter = 1
          )


          Reference: Actions on Google TS sample



          https://github.com/actions-on-google/actions-on-google-nodejs/blob/935d0f9adfe78a4f9eb83ab4bb0fb9f6a7db2001/samples/ts/app/name-psychic/functions/src/index.tsx



          Hope that helps!






          share|improve this answer


















          • 1




            Perfect, that's worked a treat. thanks @sai-raj
            – Tristram Tolliday
            Nov 10 at 22:02













          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          I think you need to explicitly specify types of variables you want to use.



          Try defining interfaces like:



          //use this in conv.data

          interface ConvData
          counter?: number


          // use in conv.user.storage
          interface UserStorage
          location?: string
          name?: string



          and initializing the app as:



          const app = dialogflow<ConvData, UserStorage>( debug: true )


          and then using



          app.intent('Default Welcome Intent', conv => 
          conv.data.counter = 1
          )


          Reference: Actions on Google TS sample



          https://github.com/actions-on-google/actions-on-google-nodejs/blob/935d0f9adfe78a4f9eb83ab4bb0fb9f6a7db2001/samples/ts/app/name-psychic/functions/src/index.tsx



          Hope that helps!






          share|improve this answer














          I think you need to explicitly specify types of variables you want to use.



          Try defining interfaces like:



          //use this in conv.data

          interface ConvData
          counter?: number


          // use in conv.user.storage
          interface UserStorage
          location?: string
          name?: string



          and initializing the app as:



          const app = dialogflow<ConvData, UserStorage>( debug: true )


          and then using



          app.intent('Default Welcome Intent', conv => 
          conv.data.counter = 1
          )


          Reference: Actions on Google TS sample



          https://github.com/actions-on-google/actions-on-google-nodejs/blob/935d0f9adfe78a4f9eb83ab4bb0fb9f6a7db2001/samples/ts/app/name-psychic/functions/src/index.tsx



          Hope that helps!







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 10 at 2:02

























          answered Nov 10 at 1:56









          sai.raj

          517




          517







          • 1




            Perfect, that's worked a treat. thanks @sai-raj
            – Tristram Tolliday
            Nov 10 at 22:02













          • 1




            Perfect, that's worked a treat. thanks @sai-raj
            – Tristram Tolliday
            Nov 10 at 22:02








          1




          1




          Perfect, that's worked a treat. thanks @sai-raj
          – Tristram Tolliday
          Nov 10 at 22:02





          Perfect, that's worked a treat. thanks @sai-raj
          – Tristram Tolliday
          Nov 10 at 22:02


















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53231680%2fsimple-counter-using-dialogflow-conv-data-or-conv-user-storage%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Use pre created SQLite database for Android project in kotlin

          Darth Vader #20

          Ondo