Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the lifetime of Dialog flow session?

I am developing a chat bot, where the user need to continue the chat after some days. So I am planning to store the session ID, to make make sure that the user can start the conversation form where he left. Any solution for this?

like image 866
Sarath Avatar asked Dec 11 '18 05:12

Sarath


2 Answers

According to the dialogflow documentation a context has a lifetime of 20 mins. Which indirectly means that the session has the same lifetime. But when I was trying this out I felt this is less than 20 mins. Which is more like 10-20 mins. Only storing the session ID won't help. You will have to save the contexts of the response received and send it with the request next time.

like image 82
Ershadi Avatar answered Sep 30 '22 19:09

Ershadi


so i also tried this for a chatbot, here is what i did,i stored the dialog flow response context in db , and sent the last context stored in db with the request to dialogflow detectIntent after 30 min. and it worked fine .instead of hitting default fallback. it gave the expected intent response.

// request to dialogflow detect intent
const request = {
      session: session,
      queryInput: {
                  input
      },
      context:"last received context from dialogflow" //recent context from db
    }; 
    detectIntent(request).then(response=>{
    const context = response.context; //response context
    db.save(context); // save this in db
    return response;
});
like image 41
david Avatar answered Sep 30 '22 20:09

david