问题
I am trying to use the conv.user.storage to save information across sessions for my user, namely I want to give him an ID.
When I invoke my action via keyboard, it will save my user storage ID fine, and when I run the action again from my developer console, it will console.log the saved ID in the session. However, when I invoke the action via speech, it will not save the storage value for the next session.
const generateRandomId = require('uuid/v4');
app.intent('Default Welcome Intent',(conv) =>{
if(conv.user.storage["id"] ==undefined){
conv.user.storage.id = generateRandomId();
}
console.log(conv.user.storage.id);
conv.close(`your user id is ${conv.user.storage.id});
});
so this intent will generate a new value every time for conv.user.storage.id when using the action via speech with my google home device, I want it to be the same every time, this is so I can save my user ID in the database to track their highscore.
EDIT
This is also occurs when I try to track the ID using conv.user.id, so when i use my action with keyboard it will always be the same ID of:
ABwppHGgFSnon5unUNjikof_5G-m_8lldEd_LIokoqYlOsCSFm96--UHDJ_GOHHo6hFOQUZVoMTT6TvfT_edklKbaPm
whereas the id which is produced by conv.user.id when using the app via speech is just a bunch of numbers like this:
1539765602273384238765
来源:https://stackoverflow.com/questions/52853576/conv-user-storage-value-not-saving-across-sessions-when-invoking-via-speech