-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get user info #115
Comments
I believe that my answer is related with the comment at the end of issue #26 But it's not clear to me how to do this exactly... someone know a howto or tutorial? Also the userID will be deprecated... so here goes the actual way to configure the Actions: |
Hi @wtavares thanks for the kind words. Unfortunately it seems like the only user info provided is "lastSeen", "locale", userId (which will be deprecated), and any permissions granted. However you can store information to be persisted across sessions in And as for the soon-to-be deprecated userID, take a look at Migrating to Webhook-generated IDs. You can create your own unique ID and store in in userStorage. import uuid
from flask_assistant import ask, user
...
@assist.action('Default Welcome Intent')
def welcome():
if user.get('userStorage') is None:
user['userStorage'] = {}
uid = uuid.uuid4()
user['userStorage']['ID'] = str(uid)
return ask('Looks like you're new here')
elif user['userStorage'].get('ID') is not None:
last_seen = user['lastSeen']
return ask('welcome back! Haven't seen you since {}'.format(last_seen)) |
Hi there, I just tried adding this snippet below to my script and it keeps returning else: error when I test it out in the simulator. Am I missing somthing? Thanks! from flask import Flask
from flask_assistant import Assistant, user, request, ask, tell, event
import uuid
...
@assist.action('Usersettings')
def usersettings():
if user.get('userStorage') is None:
user['userStorage'] = {}
uid = uuid.uuid4()
user['userStorage']['ID'] = str(uid)
return ask('new here?')
elif user['userStorage'].get('ID') is not None:
return ask('welcome back!')
else:
return ask('error') |
Same @diedezp . Storing a new generated uuid in user['userStorage'] is not working (no persistence). |
@diedezp @davidalbertonogueira due to the changes in how user storage is handled, you can now simply use the using @diedezp's example, you would adapt it like so: from flask import Flask
from flask_assistant import Assistant, request, ask, tell, event, storage
import uuid
...
@assist.action("Usersettings")
def usersettings():
if storage.get('ID') is None:
uid = uuid.uuid4()
storage['ID'] = str(uid)
return ask('new here?')
elif storage.get('ID') is not None:
return ask('welcome back!')
else:
return ask('error') |
@treethought I'm sorry, but using that code above, the storage variable is not saving the ID. Whenever I get a new request, storage is an empty dict. |
hi @davidalbertonogueira i have seen a lot of reports with user storage not persisting on actions on google (across multiple clients/languages etc). can you please take a look at this comment and ensure you have the proper options set in your google account? Unfortunately, User storage appears to only be applicable when the user has enabled "Include Chrome history..." |
Hi @treethought . I already had a tick in "Include Chrome history", so that wouldn't fix it for me... |
any news? @treethought |
There are two definitions in flask_assistant "core.py" (class Assistant)
but none of them are storing user's data persistently, for every new session on the same user userStorage gets empty. |
Hi,
A very simple doubt: How can I can the user info comming from Google Assistant?
I could see the the Assintant.request brings the user list and there is a userId coming from the request.
There is a way to get another info like email?
Thanks in advance and congrats by the project... it is awesome!
The text was updated successfully, but these errors were encountered: