Skip to content
This repository was archived by the owner on Jun 26, 2025. It is now read-only.

Commit ae043b9

Browse files
committed
add sign_in response docstring
1 parent e07dcea commit ae043b9

File tree

2 files changed

+51
-6
lines changed

2 files changed

+51
-6
lines changed

flask_assistant/response.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,11 @@ def build_item(
209209
}
210210

211211
if img_url:
212-
img_payload = {"imageUri": img_url, "accessibilityText": alt_text or "{} img".format(title)}
213-
item["image"] = img_payload
212+
img_payload = {
213+
"imageUri": img_url,
214+
"accessibilityText": alt_text or "{} img".format(title),
215+
}
216+
item["image"] = img_payload
214217

215218
return item
216219

@@ -355,17 +358,27 @@ def __init__(self, permissions, context=None, update_intent=None):
355358
},
356359
}
357360

361+
358362
class sign_in(_Response):
363+
"""Initiates the authentication flow for Account Linking
359364
360-
def __init__(self, context=None):
361-
super(sign_in, self).__init__(speech=None)
365+
After the user authorizes the action to access their profile, a Google ID token
366+
will be received and validated by the flask-assistant and expose user profile information
367+
with the `user.profile` local
368+
369+
In order to complete the sign in process, you will need to create an intent with
370+
the `actions_intent_SIGN)IN` event
371+
"""
362372

373+
def __init__(self, reason=None):
374+
super(sign_in, self).__init__(speech=None)
363375

364376
self._messages[:] = []
365377
self._response["payload"]["google"]["systemIntent"] = {
366378
"intent": "actions.intent.SIGN_IN",
367379
"data": {
368-
"optContext": context,
380+
"optContext": reason,
369381
"@type": "type.googleapis.com/google.actions.v2.SignInValueSpec",
370-
}
382+
},
371383
}
384+

samples/account_linking/webhook.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from flask import Flask
2+
from flask_assistant import Assistant, ask, profile, sign_in
3+
4+
5+
app = Flask(__name__)
6+
7+
app.config['INTEGRATIONS'] = ['ACTIONS_ON_GOOGLE']
8+
app.config['AOG_CLIENT_ID'] = "CLIENT_ID OBTAINED BY SETTING UP ACCOUNT LINKING IN AOG CONSOLE"
9+
10+
11+
assist = Assistant(app=app, route="/", project_id="YOUR_GCP_PROJECT_ID")
12+
13+
@assist.action("Default Welcome Intent")
14+
def welcome():
15+
if profile:
16+
return ask(f"Welcome back {profile['name']}")
17+
18+
return sign_in("To learn more about you")
19+
20+
# this intent must have the actions_intent_SIGN_IN event
21+
# and will be invoked once the user has
22+
@assist.action("Complete-Sign-In")
23+
def complete_sign_in():
24+
if profile:
25+
return ask(f"Welcome aboard {profile['name']}, thanks for signing up!")
26+
else:
27+
return ask("Hope you sign up soon! Would love to get to know you!")
28+
29+
30+
if __name__ == "__main__":
31+
app.run(debug=True)
32+

0 commit comments

Comments
 (0)