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?
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.
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;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With