Dealing with newlines or multi line responses from a user with a chatbot?










2















Is there a known way to deal with users writing responses over multiple lines? - is it best to handle this case on the client level? as in checking if the user is still typing and have a delay between responses, or can this be handled on Watson somehow?



An example would be:



Bot:



What's Your Name?


User:



My name is 
Nour


Those are two independent messages by the user over 2 lines.










share|improve this question


























    2















    Is there a known way to deal with users writing responses over multiple lines? - is it best to handle this case on the client level? as in checking if the user is still typing and have a delay between responses, or can this be handled on Watson somehow?



    An example would be:



    Bot:



    What's Your Name?


    User:



    My name is 
    Nour


    Those are two independent messages by the user over 2 lines.










    share|improve this question
























      2












      2








      2








      Is there a known way to deal with users writing responses over multiple lines? - is it best to handle this case on the client level? as in checking if the user is still typing and have a delay between responses, or can this be handled on Watson somehow?



      An example would be:



      Bot:



      What's Your Name?


      User:



      My name is 
      Nour


      Those are two independent messages by the user over 2 lines.










      share|improve this question














      Is there a known way to deal with users writing responses over multiple lines? - is it best to handle this case on the client level? as in checking if the user is still typing and have a delay between responses, or can this be handled on Watson somehow?



      An example would be:



      Bot:



      What's Your Name?


      User:



      My name is 
      Nour


      Those are two independent messages by the user over 2 lines.







      chatbot watson-conversation






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 14 '18 at 9:29









      NourNour

      442420




      442420






















          2 Answers
          2






          active

          oldest

          votes


















          1














          It is best to always send the full "utterance" to Assistant in one request, because the processing does not work across multiple split calls to Assistant. Otherwise you would need to do some complex logic with context variables, or ask back the user their name if they uttered "my name is" without an actual name.



          Generally the client side UI would wait for the user to press Enter before sending the utterance to Assistant. So you can be sure they have entered the full utterance.



          But perhaps if they do utter "my name is" you could have an intent which checks for a name and an entity that extracts the name, and a dialog node which if the intent is found has a slot which ensures the entity is also found. In that way, if they do say "my name is" and no name, the bot will ask them for their name.






          share|improve this answer






























            0














            DSeager's approach is potentially the right way for the example you gave. The reason being is that within your overall question you have an entity.



            What about where there is on real entity? For example:



            Two Intents.



            • Pay my speeding fine

            • Pay my parking fine

            Here you are using the intents to understand the answer without the need of an entity. Some will argue the Intent->Entity approach, but depending on your solution it can generally not scale as well versus just an intent answer.



            So now your user enters the following:



            How do I pay my 
            parking fine


            Entity solution doesn't really work here as you have no context that they want to pay.



            So one approach.



            1. Send "How do I pay my" to WA. Assuming you have trained the system well it should come back with a low confidence or irrelevant.



            2. Before you respond to the user, see if another utterance has been cached to send. If it has, then append with some kind of marker and send. For example:



            How do I pay my !! parking fine


            This will return the correct answer.




            But wait a second, what if they do this?



            How do I pay my parking fine?
            Where do I pay it?


            Both are valid questions, but the second one will fail and you can't append it to the previous.



            In this instance, when an answer displays have it set a $anaphora context variable. Then if you get a low confidence/irrelevant response try reasking with the $anaphora value appended.



            For example:



            Q: How do I pay my parking fine? 
            A: <Answer> $anaphora = "parking fine"
            Q: Where do I pay it?
            A: <Irrelevant>
            Q: parking fine !! Where do I pay it?


            Both of these require some work at the application layer.






            share|improve this answer
























              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%2f53296876%2fdealing-with-newlines-or-multi-line-responses-from-a-user-with-a-chatbot%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              It is best to always send the full "utterance" to Assistant in one request, because the processing does not work across multiple split calls to Assistant. Otherwise you would need to do some complex logic with context variables, or ask back the user their name if they uttered "my name is" without an actual name.



              Generally the client side UI would wait for the user to press Enter before sending the utterance to Assistant. So you can be sure they have entered the full utterance.



              But perhaps if they do utter "my name is" you could have an intent which checks for a name and an entity that extracts the name, and a dialog node which if the intent is found has a slot which ensures the entity is also found. In that way, if they do say "my name is" and no name, the bot will ask them for their name.






              share|improve this answer



























                1














                It is best to always send the full "utterance" to Assistant in one request, because the processing does not work across multiple split calls to Assistant. Otherwise you would need to do some complex logic with context variables, or ask back the user their name if they uttered "my name is" without an actual name.



                Generally the client side UI would wait for the user to press Enter before sending the utterance to Assistant. So you can be sure they have entered the full utterance.



                But perhaps if they do utter "my name is" you could have an intent which checks for a name and an entity that extracts the name, and a dialog node which if the intent is found has a slot which ensures the entity is also found. In that way, if they do say "my name is" and no name, the bot will ask them for their name.






                share|improve this answer

























                  1












                  1








                  1







                  It is best to always send the full "utterance" to Assistant in one request, because the processing does not work across multiple split calls to Assistant. Otherwise you would need to do some complex logic with context variables, or ask back the user their name if they uttered "my name is" without an actual name.



                  Generally the client side UI would wait for the user to press Enter before sending the utterance to Assistant. So you can be sure they have entered the full utterance.



                  But perhaps if they do utter "my name is" you could have an intent which checks for a name and an entity that extracts the name, and a dialog node which if the intent is found has a slot which ensures the entity is also found. In that way, if they do say "my name is" and no name, the bot will ask them for their name.






                  share|improve this answer













                  It is best to always send the full "utterance" to Assistant in one request, because the processing does not work across multiple split calls to Assistant. Otherwise you would need to do some complex logic with context variables, or ask back the user their name if they uttered "my name is" without an actual name.



                  Generally the client side UI would wait for the user to press Enter before sending the utterance to Assistant. So you can be sure they have entered the full utterance.



                  But perhaps if they do utter "my name is" you could have an intent which checks for a name and an entity that extracts the name, and a dialog node which if the intent is found has a slot which ensures the entity is also found. In that way, if they do say "my name is" and no name, the bot will ask them for their name.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 14 '18 at 11:15









                  DSeagerDSeager

                  994




                  994























                      0














                      DSeager's approach is potentially the right way for the example you gave. The reason being is that within your overall question you have an entity.



                      What about where there is on real entity? For example:



                      Two Intents.



                      • Pay my speeding fine

                      • Pay my parking fine

                      Here you are using the intents to understand the answer without the need of an entity. Some will argue the Intent->Entity approach, but depending on your solution it can generally not scale as well versus just an intent answer.



                      So now your user enters the following:



                      How do I pay my 
                      parking fine


                      Entity solution doesn't really work here as you have no context that they want to pay.



                      So one approach.



                      1. Send "How do I pay my" to WA. Assuming you have trained the system well it should come back with a low confidence or irrelevant.



                      2. Before you respond to the user, see if another utterance has been cached to send. If it has, then append with some kind of marker and send. For example:



                      How do I pay my !! parking fine


                      This will return the correct answer.




                      But wait a second, what if they do this?



                      How do I pay my parking fine?
                      Where do I pay it?


                      Both are valid questions, but the second one will fail and you can't append it to the previous.



                      In this instance, when an answer displays have it set a $anaphora context variable. Then if you get a low confidence/irrelevant response try reasking with the $anaphora value appended.



                      For example:



                      Q: How do I pay my parking fine? 
                      A: <Answer> $anaphora = "parking fine"
                      Q: Where do I pay it?
                      A: <Irrelevant>
                      Q: parking fine !! Where do I pay it?


                      Both of these require some work at the application layer.






                      share|improve this answer





























                        0














                        DSeager's approach is potentially the right way for the example you gave. The reason being is that within your overall question you have an entity.



                        What about where there is on real entity? For example:



                        Two Intents.



                        • Pay my speeding fine

                        • Pay my parking fine

                        Here you are using the intents to understand the answer without the need of an entity. Some will argue the Intent->Entity approach, but depending on your solution it can generally not scale as well versus just an intent answer.



                        So now your user enters the following:



                        How do I pay my 
                        parking fine


                        Entity solution doesn't really work here as you have no context that they want to pay.



                        So one approach.



                        1. Send "How do I pay my" to WA. Assuming you have trained the system well it should come back with a low confidence or irrelevant.



                        2. Before you respond to the user, see if another utterance has been cached to send. If it has, then append with some kind of marker and send. For example:



                        How do I pay my !! parking fine


                        This will return the correct answer.




                        But wait a second, what if they do this?



                        How do I pay my parking fine?
                        Where do I pay it?


                        Both are valid questions, but the second one will fail and you can't append it to the previous.



                        In this instance, when an answer displays have it set a $anaphora context variable. Then if you get a low confidence/irrelevant response try reasking with the $anaphora value appended.



                        For example:



                        Q: How do I pay my parking fine? 
                        A: <Answer> $anaphora = "parking fine"
                        Q: Where do I pay it?
                        A: <Irrelevant>
                        Q: parking fine !! Where do I pay it?


                        Both of these require some work at the application layer.






                        share|improve this answer



























                          0












                          0








                          0







                          DSeager's approach is potentially the right way for the example you gave. The reason being is that within your overall question you have an entity.



                          What about where there is on real entity? For example:



                          Two Intents.



                          • Pay my speeding fine

                          • Pay my parking fine

                          Here you are using the intents to understand the answer without the need of an entity. Some will argue the Intent->Entity approach, but depending on your solution it can generally not scale as well versus just an intent answer.



                          So now your user enters the following:



                          How do I pay my 
                          parking fine


                          Entity solution doesn't really work here as you have no context that they want to pay.



                          So one approach.



                          1. Send "How do I pay my" to WA. Assuming you have trained the system well it should come back with a low confidence or irrelevant.



                          2. Before you respond to the user, see if another utterance has been cached to send. If it has, then append with some kind of marker and send. For example:



                          How do I pay my !! parking fine


                          This will return the correct answer.




                          But wait a second, what if they do this?



                          How do I pay my parking fine?
                          Where do I pay it?


                          Both are valid questions, but the second one will fail and you can't append it to the previous.



                          In this instance, when an answer displays have it set a $anaphora context variable. Then if you get a low confidence/irrelevant response try reasking with the $anaphora value appended.



                          For example:



                          Q: How do I pay my parking fine? 
                          A: <Answer> $anaphora = "parking fine"
                          Q: Where do I pay it?
                          A: <Irrelevant>
                          Q: parking fine !! Where do I pay it?


                          Both of these require some work at the application layer.






                          share|improve this answer















                          DSeager's approach is potentially the right way for the example you gave. The reason being is that within your overall question you have an entity.



                          What about where there is on real entity? For example:



                          Two Intents.



                          • Pay my speeding fine

                          • Pay my parking fine

                          Here you are using the intents to understand the answer without the need of an entity. Some will argue the Intent->Entity approach, but depending on your solution it can generally not scale as well versus just an intent answer.



                          So now your user enters the following:



                          How do I pay my 
                          parking fine


                          Entity solution doesn't really work here as you have no context that they want to pay.



                          So one approach.



                          1. Send "How do I pay my" to WA. Assuming you have trained the system well it should come back with a low confidence or irrelevant.



                          2. Before you respond to the user, see if another utterance has been cached to send. If it has, then append with some kind of marker and send. For example:



                          How do I pay my !! parking fine


                          This will return the correct answer.




                          But wait a second, what if they do this?



                          How do I pay my parking fine?
                          Where do I pay it?


                          Both are valid questions, but the second one will fail and you can't append it to the previous.



                          In this instance, when an answer displays have it set a $anaphora context variable. Then if you get a low confidence/irrelevant response try reasking with the $anaphora value appended.



                          For example:



                          Q: How do I pay my parking fine? 
                          A: <Answer> $anaphora = "parking fine"
                          Q: Where do I pay it?
                          A: <Irrelevant>
                          Q: parking fine !! Where do I pay it?


                          Both of these require some work at the application layer.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Nov 19 '18 at 11:14

























                          answered Nov 15 '18 at 4:20









                          Simon O'DohertySimon O'Doherty

                          7,74312143




                          7,74312143



























                              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.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53296876%2fdealing-with-newlines-or-multi-line-responses-from-a-user-with-a-chatbot%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

                              Top Tejano songwriter Luis Silva dead of heart attack at 64

                              ReactJS Fetched API data displays live - need Data displayed static

                              Evgeni Malkin