Search code examples
dialogflow-es

DialogFlow: if an intent is triggered three times, how to store and reuse the parameters' value of each time (1st, 2nd, and 3rd)?


In DialogFlow: I have an intent that users would possibly trigger multiple times. How can I store and reuse the parameters' value each time?

For instance, the intent name is called "progress_tracking", another intent is "get_progress_report".

First time triggering "progress_tracking" intent:

User: I have finished only 1/5 of the project in the first 10 minutes. I'm not very confident.
Chatbot: thanks for sharing the progress. You should believe in yourself!

Second time triggering "progress_tracking" intent:

User: I have finished only 1/2 of the project. It used 5 minutes. I think I can finish it on time.
Chatbot: Glad you progressed from 1/5 to 1/2. Earlier you are not very confident. How are you feeling now?

3rd time triggering "progress_tracking" intent:

User: I've done my work! It took me only 30 minutes!
Chatbot: well-done!

triggering "get_progress_report" intent:

User: can you give me a report about my progress?
Chatbot: sure! in the first session, you completed 1/5 of the work in 10 minutes. In the second session, you ...........

Looking for some guidance! Thank you in advance!


Solution

  • For your use case I used the concept of Input and Output Contexts in my Intents. I also used the concept of conversational turns.

    You can refer to the below mentioned steps:

    • I created Intents and passed the Input and output contexts into it.
    • I created one custom Entity i.e @values to store the fractional data (½,⅕ etc) as @sys.number which returns decimal values (0.2,0.5).
    • I passed the parameter value from one Intent to another by using the #context-name.parameter-name and for the same Intent I passed the parameter values by using $parameter-name as per this doc.
    • You can refer to the below output screenshot as per your requirement

    output 1 :

    enter image description here

    output 2 :

    enter image description here

    • You can use the below Agent on your end to check for the flow of contexts inside the intents. You need to import the Zip agent to your project as per this doc and it will work.

      Zip file : Agent Zip file