Search code examples
google-cloud-functionsdialogflow-estelegram-botdialogflow-es-fulfillment

save local data fulfillment dialogflow nodejs


when I use dialogflow + google assistant, I usually save a temporary data with conv.data and save to user storage with conv.user.storage in webhook cloud function javascript

but, when I use dialogflow + telegram, I didn't find that. so I want to save a score in quiz, so in 10 question, the system able to store like a temporary storage to save the score and calculate after the quiz is finish


Solution

  • Both conv.data and conv.user.storage are Actions on Google concepts, so are only available with that integration.

    The rough equivalent of conv.data would be to have a Context with a long lifespan. Your webhook would save the data you're interested in preserving for the session in this context and then retrieve it in a later webhook call.

    This is only maintained for a session, however. Any longer-term storage would require you to have a unique identifier for the user which you can use as a key into a database or data store you maintain.