2

I'm trying to understand how conv.data and conv.user.storage works. As far as I uderstand is that conv.data is used for temporary storage and conv.user.storage for longer for between conversations. When i was testing locally I noticed that conv.data doesn't really save for the next turn but only the same one. So is it tied to context?

On the other hand, user storage is pretty straight forward, you save the data and you have it in user and it is limited to 10 000 bytes but that is it.

But what I don't understand is this part:

When the Assistant can't match an identity to the user, the content of user storage is cleared at the end of the conversation. Examples of cases where the Assistant can't match an identity to the user are:

  • voice match is set up and there is no match.

  • The user disabled personal data.

Does this mean that if the user is now using the app and then someone else in the same conversation drops in to test it, does it clear the data?

TLDR - Is context related to conv.data and when context expires then conv.data is deleted? - Does your app data get deleted when another user tries to talk on your account?

WinterChilly
  • 1,549
  • 3
  • 21
  • 34

1 Answers1

1

You have things mostly correct. Let's look at a few things you say or ask.

Why doesn't conv.data save for the next turn?

It depends what you mean by a "turn". conv.data is saved during a single conversation - from the point your Action is invoked until your action "closes the microphone" with conv.close() or the equivalent. AoG maintains this as a consistent conversation model.

(There are some bugs when you're using a Media response and are playing a very long audio file. But these are exceptions.)

Is conv.data implemented using Dialogflow contexts?

If you're using AoG with Dialogflow - yes.

You can use conv.data with the Action SDK, and it does not use Dialogflow contexts.

But then won't it expire when the context does?

Yes and no. The context for conv.data is created as a long-lasting context (a lifespan of 99), so it will be a while before the context expires. The library also refreshes the context every turn, so it keeps the lifespan at 99 and resets the 20-minute timer for a context.

For conv.user.storage, if the user is now using the app and then someone else in the same conversation drops in to test it, does it clear the data?

No. User identity is determined when the user says the hotword - "OK Google" or "Hey Google". After that, multiple users can speak during the conversation and the device treats it as the same account.

The Assistant doesn't try to figure out who is saying what during a conversation - only initially.

So if it identifies the user at the beginning of the conversation, it uses their storage object. If it does not, it creates a new storage object that is disposed of when the conversation ends (when it closes the microphone after conv.close()).

Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • Thank you for the clarification. Do you maybe have any idea why when I try to use conv.data.somevariable it doesn't get saved through the whole conversation. It is only saved for that time that was saved, but when the other intent triggers, it gets undefined. That's why I'm trying to understand this. – WinterChilly Jan 15 '19 at 18:38
  • 1
    That does seem odd, and I haven't seen that. You may wish to update your original question (or post a new question) with code that provides a clear demonstration of the problem. – Prisoner Jan 15 '19 at 23:16
  • I'll post another question :) and elaborate. – WinterChilly Jan 16 '19 at 07:27
  • I went into greater details here: https://stackoverflow.com/questions/54213090/cant-get-conv-data-to-save-a-parameter-in-actions-on-google – WinterChilly Jan 16 '19 at 13:12