UNPKG

2.6 kBTypeScriptView Raw
1/**
2 * Copyright 2018 Google Inc. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import * as Api from '../../api/v2';
17import { SoloHelper } from './helper';
18/** @public */
19export declare type SignInArgument = Api.GoogleActionsV2SignInValue;
20/**
21 * Hands the user off to a web sign in flow. App sign in and OAuth credentials
22 * are set in the {@link https://console.actions.google.com|Actions Console}.
23 * Retrieve the access token in subsequent intents using
24 * {@link Access#token|conv.user.access.token}.
25 *
26 * @example
27 * ```javascript
28 *
29 * // Actions SDK
30 * const app = actionssdk()
31 *
32 * app.intent('actions.intent.MAIN', conv => {
33 * conv.ask(new SignIn())
34 * })
35 *
36 * app.intent('actions.intent.SIGN_IN', (conv, input, signin) => {
37 * if (signin.status === 'OK') {
38 * const access = conv.user.access.token // possibly do something with access token
39 * conv.ask('Great, thanks for signing in! What do you want to do next?')
40 * } else {
41 * conv.ask(`I won't be able to save your data, but what do you want to do next?`)
42 * }
43 * })
44 *
45 * // Dialogflow
46 * const app = dialogflow()
47 *
48 * app.intent('actions.intent.MAIN', conv => {
49 * conv.ask(new SignIn())
50 * })
51 *
52 * // Create a Dialogflow intent with the `actions_intent_SIGN_IN` event
53 * app.intent('Get Signin', (conv, params, signin) => {
54 * if (signin.status === 'OK') {
55 * const access = conv.user.access.token // possibly do something with access token
56 * conv.ask('Great, thanks for signing in! What do you want to do next?')
57 * } else {
58 * conv.ask(`I won't be able to save your data, but what do you want to do next?`)
59 * }
60 * })
61 * ```
62 *
63 * @public
64 */
65export declare class SignIn extends SoloHelper<'actions.intent.SIGN_IN', Api.GoogleActionsV2SignInValueSpec> {
66 /**
67 * @param context The optional context why the app needs to ask the user to sign in, as a
68 * prefix of a prompt for user consent, e.g. "To track your exercise", or
69 * "To check your account balance".
70 * @public
71 */
72 constructor(context?: string);
73}