DialogFlow follow up triggers empty response












1














I have a DialogFlow intent follow up that I'm having a hard time with. It's the only follow up to my main intent, and the issue I'm having is that when
the incidents.data array is empty it doesn't trigger the conv.ask statement in the else case and causes DialogFlow to throw an empty speech response error. The code looks something like this:



app.intent('metro_timetable - yes', async (conv: any) => {
const incidents = await serviceIncidents.getIncidents();
if (incidents.data.length > 0) {
conv.ask('I have incidents')
} else {
conv.ask(
`I wasn't able to understand your request, could you please say that again?`
);
}
});


incidents.data gets stored in the global scope, and is set deep within
the metro_timetable intent. It stores an incident for the follow up. Because all yes responses trigger the follow up I setup an else case so it catches it if someone says yes when metro_timetable doesn't understand their original request and asks them to repeat it. If incidents.data actually has information to share the dialog triggers correctly and I have incidents is correctly read to the user.



In DialogFlow it looks something like this. Where am I going wrong here?



enter image description here



enter image description here



enter image description here










share|improve this question



























    1














    I have a DialogFlow intent follow up that I'm having a hard time with. It's the only follow up to my main intent, and the issue I'm having is that when
    the incidents.data array is empty it doesn't trigger the conv.ask statement in the else case and causes DialogFlow to throw an empty speech response error. The code looks something like this:



    app.intent('metro_timetable - yes', async (conv: any) => {
    const incidents = await serviceIncidents.getIncidents();
    if (incidents.data.length > 0) {
    conv.ask('I have incidents')
    } else {
    conv.ask(
    `I wasn't able to understand your request, could you please say that again?`
    );
    }
    });


    incidents.data gets stored in the global scope, and is set deep within
    the metro_timetable intent. It stores an incident for the follow up. Because all yes responses trigger the follow up I setup an else case so it catches it if someone says yes when metro_timetable doesn't understand their original request and asks them to repeat it. If incidents.data actually has information to share the dialog triggers correctly and I have incidents is correctly read to the user.



    In DialogFlow it looks something like this. Where am I going wrong here?



    enter image description here



    enter image description here



    enter image description here










    share|improve this question

























      1












      1








      1







      I have a DialogFlow intent follow up that I'm having a hard time with. It's the only follow up to my main intent, and the issue I'm having is that when
      the incidents.data array is empty it doesn't trigger the conv.ask statement in the else case and causes DialogFlow to throw an empty speech response error. The code looks something like this:



      app.intent('metro_timetable - yes', async (conv: any) => {
      const incidents = await serviceIncidents.getIncidents();
      if (incidents.data.length > 0) {
      conv.ask('I have incidents')
      } else {
      conv.ask(
      `I wasn't able to understand your request, could you please say that again?`
      );
      }
      });


      incidents.data gets stored in the global scope, and is set deep within
      the metro_timetable intent. It stores an incident for the follow up. Because all yes responses trigger the follow up I setup an else case so it catches it if someone says yes when metro_timetable doesn't understand their original request and asks them to repeat it. If incidents.data actually has information to share the dialog triggers correctly and I have incidents is correctly read to the user.



      In DialogFlow it looks something like this. Where am I going wrong here?



      enter image description here



      enter image description here



      enter image description here










      share|improve this question













      I have a DialogFlow intent follow up that I'm having a hard time with. It's the only follow up to my main intent, and the issue I'm having is that when
      the incidents.data array is empty it doesn't trigger the conv.ask statement in the else case and causes DialogFlow to throw an empty speech response error. The code looks something like this:



      app.intent('metro_timetable - yes', async (conv: any) => {
      const incidents = await serviceIncidents.getIncidents();
      if (incidents.data.length > 0) {
      conv.ask('I have incidents')
      } else {
      conv.ask(
      `I wasn't able to understand your request, could you please say that again?`
      );
      }
      });


      incidents.data gets stored in the global scope, and is set deep within
      the metro_timetable intent. It stores an incident for the follow up. Because all yes responses trigger the follow up I setup an else case so it catches it if someone says yes when metro_timetable doesn't understand their original request and asks them to repeat it. If incidents.data actually has information to share the dialog triggers correctly and I have incidents is correctly read to the user.



      In DialogFlow it looks something like this. Where am I going wrong here?



      enter image description here



      enter image description here



      enter image description here







      dialogflow actions-on-google






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 27 '18 at 14:52









      James Ives

      1,3711332




      1,3711332
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Your description is a little convoluted how incidents.data actually gets set, but it sounds possible that instead of it being set to an empty array, it isn't set at all. In this case, I suspect that the following happened:





          1. incidents.data would be undefined

          2. Trying to evaluate incidents.data.length would cause an error

          3. Since the program crashes, your webhook doesn't return a result. Since you probably didn't set a result in the UI for the intent, an empty result was returned.


          You can probably solve this by doing a test such as (for example)



          incidents && incidents.data && incidents.data.length > 0


          Your other issue, however, seems to be that you have a Followup Intent set for a scenario where you don't actually want that as the followup. This is one of the reasons you probably shouldn't use Followup Intents but, instead, only set a context when you send a response where that context would make sense, and look for the "Yes" response in the context you define. Then, when metro_timetable doesn't understand the request, you don't set the context and you give an error.



          To do this, you would remove the automatically generated metro_timetable-followup context from the two Intents. You'll create your own context, which I'll name timetable for purposes of this example.



          In the fulfillment for the metro_timetable Intent, if you respond with something that needs confirmation (ie - when "yes" will be something the user says), you would set the timetable context with something like



          conv.contexts.set('timetable',2);
          conv.ask('Are you sure?');


          You can then create an Intent that checks for timetable as the Incoming Context and has training phrases that are equivalent to "yes". In that Intent, you'd do what you need to and respond.






          share|improve this answer























          • What is the correct way to set up context replies like you mentioned? You're right that it's being triggered when I don't actually want it to, but I'm not sure how to make the word yes behave differently in a follow up question for different parts of an intent.
            – James Ives
            Dec 27 '18 at 18:00










          • Answer updated to clarify.
            – Prisoner
            Dec 27 '18 at 18:18











          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',
          autoActivateHeartbeat: false,
          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%2f53946918%2fdialogflow-follow-up-triggers-empty-response%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









          1














          Your description is a little convoluted how incidents.data actually gets set, but it sounds possible that instead of it being set to an empty array, it isn't set at all. In this case, I suspect that the following happened:





          1. incidents.data would be undefined

          2. Trying to evaluate incidents.data.length would cause an error

          3. Since the program crashes, your webhook doesn't return a result. Since you probably didn't set a result in the UI for the intent, an empty result was returned.


          You can probably solve this by doing a test such as (for example)



          incidents && incidents.data && incidents.data.length > 0


          Your other issue, however, seems to be that you have a Followup Intent set for a scenario where you don't actually want that as the followup. This is one of the reasons you probably shouldn't use Followup Intents but, instead, only set a context when you send a response where that context would make sense, and look for the "Yes" response in the context you define. Then, when metro_timetable doesn't understand the request, you don't set the context and you give an error.



          To do this, you would remove the automatically generated metro_timetable-followup context from the two Intents. You'll create your own context, which I'll name timetable for purposes of this example.



          In the fulfillment for the metro_timetable Intent, if you respond with something that needs confirmation (ie - when "yes" will be something the user says), you would set the timetable context with something like



          conv.contexts.set('timetable',2);
          conv.ask('Are you sure?');


          You can then create an Intent that checks for timetable as the Incoming Context and has training phrases that are equivalent to "yes". In that Intent, you'd do what you need to and respond.






          share|improve this answer























          • What is the correct way to set up context replies like you mentioned? You're right that it's being triggered when I don't actually want it to, but I'm not sure how to make the word yes behave differently in a follow up question for different parts of an intent.
            – James Ives
            Dec 27 '18 at 18:00










          • Answer updated to clarify.
            – Prisoner
            Dec 27 '18 at 18:18
















          1














          Your description is a little convoluted how incidents.data actually gets set, but it sounds possible that instead of it being set to an empty array, it isn't set at all. In this case, I suspect that the following happened:





          1. incidents.data would be undefined

          2. Trying to evaluate incidents.data.length would cause an error

          3. Since the program crashes, your webhook doesn't return a result. Since you probably didn't set a result in the UI for the intent, an empty result was returned.


          You can probably solve this by doing a test such as (for example)



          incidents && incidents.data && incidents.data.length > 0


          Your other issue, however, seems to be that you have a Followup Intent set for a scenario where you don't actually want that as the followup. This is one of the reasons you probably shouldn't use Followup Intents but, instead, only set a context when you send a response where that context would make sense, and look for the "Yes" response in the context you define. Then, when metro_timetable doesn't understand the request, you don't set the context and you give an error.



          To do this, you would remove the automatically generated metro_timetable-followup context from the two Intents. You'll create your own context, which I'll name timetable for purposes of this example.



          In the fulfillment for the metro_timetable Intent, if you respond with something that needs confirmation (ie - when "yes" will be something the user says), you would set the timetable context with something like



          conv.contexts.set('timetable',2);
          conv.ask('Are you sure?');


          You can then create an Intent that checks for timetable as the Incoming Context and has training phrases that are equivalent to "yes". In that Intent, you'd do what you need to and respond.






          share|improve this answer























          • What is the correct way to set up context replies like you mentioned? You're right that it's being triggered when I don't actually want it to, but I'm not sure how to make the word yes behave differently in a follow up question for different parts of an intent.
            – James Ives
            Dec 27 '18 at 18:00










          • Answer updated to clarify.
            – Prisoner
            Dec 27 '18 at 18:18














          1












          1








          1






          Your description is a little convoluted how incidents.data actually gets set, but it sounds possible that instead of it being set to an empty array, it isn't set at all. In this case, I suspect that the following happened:





          1. incidents.data would be undefined

          2. Trying to evaluate incidents.data.length would cause an error

          3. Since the program crashes, your webhook doesn't return a result. Since you probably didn't set a result in the UI for the intent, an empty result was returned.


          You can probably solve this by doing a test such as (for example)



          incidents && incidents.data && incidents.data.length > 0


          Your other issue, however, seems to be that you have a Followup Intent set for a scenario where you don't actually want that as the followup. This is one of the reasons you probably shouldn't use Followup Intents but, instead, only set a context when you send a response where that context would make sense, and look for the "Yes" response in the context you define. Then, when metro_timetable doesn't understand the request, you don't set the context and you give an error.



          To do this, you would remove the automatically generated metro_timetable-followup context from the two Intents. You'll create your own context, which I'll name timetable for purposes of this example.



          In the fulfillment for the metro_timetable Intent, if you respond with something that needs confirmation (ie - when "yes" will be something the user says), you would set the timetable context with something like



          conv.contexts.set('timetable',2);
          conv.ask('Are you sure?');


          You can then create an Intent that checks for timetable as the Incoming Context and has training phrases that are equivalent to "yes". In that Intent, you'd do what you need to and respond.






          share|improve this answer














          Your description is a little convoluted how incidents.data actually gets set, but it sounds possible that instead of it being set to an empty array, it isn't set at all. In this case, I suspect that the following happened:





          1. incidents.data would be undefined

          2. Trying to evaluate incidents.data.length would cause an error

          3. Since the program crashes, your webhook doesn't return a result. Since you probably didn't set a result in the UI for the intent, an empty result was returned.


          You can probably solve this by doing a test such as (for example)



          incidents && incidents.data && incidents.data.length > 0


          Your other issue, however, seems to be that you have a Followup Intent set for a scenario where you don't actually want that as the followup. This is one of the reasons you probably shouldn't use Followup Intents but, instead, only set a context when you send a response where that context would make sense, and look for the "Yes" response in the context you define. Then, when metro_timetable doesn't understand the request, you don't set the context and you give an error.



          To do this, you would remove the automatically generated metro_timetable-followup context from the two Intents. You'll create your own context, which I'll name timetable for purposes of this example.



          In the fulfillment for the metro_timetable Intent, if you respond with something that needs confirmation (ie - when "yes" will be something the user says), you would set the timetable context with something like



          conv.contexts.set('timetable',2);
          conv.ask('Are you sure?');


          You can then create an Intent that checks for timetable as the Incoming Context and has training phrases that are equivalent to "yes". In that Intent, you'd do what you need to and respond.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 27 '18 at 18:18

























          answered Dec 27 '18 at 17:19









          Prisoner

          31.8k22552




          31.8k22552












          • What is the correct way to set up context replies like you mentioned? You're right that it's being triggered when I don't actually want it to, but I'm not sure how to make the word yes behave differently in a follow up question for different parts of an intent.
            – James Ives
            Dec 27 '18 at 18:00










          • Answer updated to clarify.
            – Prisoner
            Dec 27 '18 at 18:18


















          • What is the correct way to set up context replies like you mentioned? You're right that it's being triggered when I don't actually want it to, but I'm not sure how to make the word yes behave differently in a follow up question for different parts of an intent.
            – James Ives
            Dec 27 '18 at 18:00










          • Answer updated to clarify.
            – Prisoner
            Dec 27 '18 at 18:18
















          What is the correct way to set up context replies like you mentioned? You're right that it's being triggered when I don't actually want it to, but I'm not sure how to make the word yes behave differently in a follow up question for different parts of an intent.
          – James Ives
          Dec 27 '18 at 18:00




          What is the correct way to set up context replies like you mentioned? You're right that it's being triggered when I don't actually want it to, but I'm not sure how to make the word yes behave differently in a follow up question for different parts of an intent.
          – James Ives
          Dec 27 '18 at 18:00












          Answer updated to clarify.
          – Prisoner
          Dec 27 '18 at 18:18




          Answer updated to clarify.
          – Prisoner
          Dec 27 '18 at 18:18


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53946918%2fdialogflow-follow-up-triggers-empty-response%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

          Mossoró

          Error while reading .h5 file using the rhdf5 package in R

          Pushsharp Apns notification error: 'InvalidToken'