mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Upgrade to actions-on-google 1.5
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ActionsSdkApp, ActionsSdkAppOptions, ApiAiApp, ApiAiAppOptions, AssistantApp,
|
||||
import { ActionsSdkApp, ActionsSdkAppOptions, DialogflowApp, DialogflowAppOptions, AssistantApp,
|
||||
Responses, Transactions } from 'actions-on-google';
|
||||
import * as express from 'express';
|
||||
|
||||
@@ -14,8 +14,8 @@ function testActionsSdk(request: express.Request, response: express.Response) {
|
||||
app.handleRequest(actionMap);
|
||||
}
|
||||
|
||||
function testApiAi(request: express.Request, response: express.Response) {
|
||||
const app = new ApiAiApp({request, response});
|
||||
function testDialogflow(request: express.Request, response: express.Response) {
|
||||
const app = new DialogflowApp({request, response});
|
||||
const actionMap = new Map();
|
||||
actionMap.set(app.StandardIntents.MAIN, () => {
|
||||
const order: Transactions.Order = app.buildOrder('foo');
|
||||
@@ -30,4 +30,4 @@ function testApiAi(request: express.Request, response: express.Response) {
|
||||
|
||||
const expressApp = express();
|
||||
expressApp.get('/actionssdk', testActionsSdk);
|
||||
expressApp.get('/apiai', testApiAi);
|
||||
expressApp.get('/dialogflow', testDialogflow);
|
||||
|
||||
104
types/actions-on-google/assistant-app.d.ts
vendored
104
types/actions-on-google/assistant-app.d.ts
vendored
@@ -425,7 +425,7 @@ export class AssistantApp {
|
||||
* Constructor for AssistantApp object.
|
||||
* Should not be instantiated; rather instantiate one of the subclasses
|
||||
*
|
||||
* {@link ActionsSdkApp} or {@link ApiAiApp}.
|
||||
* {@link ActionsSdkApp} or {@link DialogflowApp}.
|
||||
*
|
||||
* @param {Object} options JSON configuration.
|
||||
* @param {Object} options.request Express HTTP request object.
|
||||
@@ -473,8 +473,8 @@ export class AssistantApp {
|
||||
*
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* // API.AI
|
||||
* const app = new ApiAiApp({request: req, response: res});
|
||||
* // Dialogflow
|
||||
* const app = new DialogflowApp({request: req, response: res});
|
||||
* const NAME_ACTION = 'make_name';
|
||||
* const COLOR_ARGUMENT = 'color';
|
||||
* const NUMBER_ARGUMENT = 'number';
|
||||
@@ -493,7 +493,7 @@ export class AssistantApp {
|
||||
*
|
||||
* @param {(Function|Map)} handler The handler (or Map of handlers) for the request.
|
||||
* @actionssdk
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
handleRequest(handler?: RequestHandler | Map<string, RequestHandler>): void;
|
||||
|
||||
@@ -512,7 +512,7 @@ export class AssistantApp {
|
||||
* equivalent to just asking for DEVICE_PRECISE_LOCATION
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAIApp({request: req, response: res});
|
||||
* const app = new DialogflowApp({request: req, response: res});
|
||||
* const REQUEST_PERMISSION_ACTION = 'request_permission';
|
||||
* const GET_RIDE_ACTION = 'get_ride';
|
||||
*
|
||||
@@ -549,7 +549,7 @@ export class AssistantApp {
|
||||
* @return A response is sent to Assistant to ask for the user's permission; for any
|
||||
* invalid input, we return null.
|
||||
* @actionssdk
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
askForPermissions(context: string, permissions: string[], dialogState?: object): object;
|
||||
|
||||
@@ -557,7 +557,7 @@ export class AssistantApp {
|
||||
* Checks whether user is in transactable state.
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({request: request, response: response});
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const TXN_REQ_COMPLETE = 'txn.req.complete';
|
||||
*
|
||||
@@ -591,7 +591,7 @@ export class AssistantApp {
|
||||
* will be circulated back by Assistant. Used in {@link ActionsSdkAssistant}.
|
||||
* @return {Object} HTTP response.
|
||||
* @actionssdk
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
askForTransactionRequirements(transactionConfig?: ActionPaymentTransactionConfig | GooglePaymentTransactionConfig, dialogState?: object): object;
|
||||
|
||||
@@ -599,7 +599,7 @@ export class AssistantApp {
|
||||
* Asks user to confirm transaction information.
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({request: request, response: response});
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const TXN_COMPLETE = 'txn.complete';
|
||||
*
|
||||
@@ -631,7 +631,7 @@ export class AssistantApp {
|
||||
* options and order options.
|
||||
* @param {Object=} dialogState JSON object the app uses to hold dialog state that
|
||||
* will be circulated back by Assistant. Used in {@link ActionsSdkAssistant}.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
askForTransactionDecision(order: object, transactionConfig?: ActionPaymentTransactionConfig | GooglePaymentTransactionConfig, dialogState?: object): object;
|
||||
|
||||
@@ -655,7 +655,7 @@ export class AssistantApp {
|
||||
* * {@link AssistantApp#getUserName|getUserName}
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({request: req, response: res});
|
||||
* const app = new DialogflowApp({request: req, response: res});
|
||||
* const REQUEST_PERMISSION_ACTION = 'request_permission';
|
||||
* const GET_RIDE_ACTION = 'get_ride';
|
||||
*
|
||||
@@ -687,7 +687,7 @@ export class AssistantApp {
|
||||
* @return A response is sent to the Assistant to ask for the user's permission;
|
||||
* for any invalid input, we return null.
|
||||
* @actionssdk
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
askForPermission(context: string, permission: string, dialogState?: object): object;
|
||||
|
||||
@@ -699,7 +699,7 @@ export class AssistantApp {
|
||||
* @example
|
||||
* const app = new ActionsSdkApp({request: request, response: response});
|
||||
* // or
|
||||
* const app = new ApiAiApp({request: request, response: response});
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* app.askForPermissions("To get you a ride", [
|
||||
* app.SupportedPermissions.NAME,
|
||||
* app.SupportedPermissions.DEVICE_PRECISE_LOCATION
|
||||
@@ -711,7 +711,7 @@ export class AssistantApp {
|
||||
* }
|
||||
*
|
||||
* @return {boolean} true if permissions granted.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
isPermissionGranted(): boolean;
|
||||
@@ -720,8 +720,8 @@ export class AssistantApp {
|
||||
* Asks user for delivery address.
|
||||
*
|
||||
* @example
|
||||
* // For ApiAiApp:
|
||||
* const app = new ApiAiApp({request, response});
|
||||
* // For DialogflowApp:
|
||||
* const app = new DialogflowApp({request, response});
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const DELIVERY_INTENT = 'delivery.address';
|
||||
*
|
||||
@@ -771,7 +771,7 @@ export class AssistantApp {
|
||||
* will be circulated back by Assistant.
|
||||
* @return {Object} HTTP response.
|
||||
* @actionssdk
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
askForDeliveryAddress(reason: string, dialogState?: object): object;
|
||||
|
||||
@@ -779,7 +779,7 @@ export class AssistantApp {
|
||||
* Asks user for a confirmation.
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({ request, response });
|
||||
* const app = new DialogflowApp({ request, response });
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const CONFIRMATION = 'confirmation';
|
||||
*
|
||||
@@ -806,7 +806,7 @@ export class AssistantApp {
|
||||
* @param {Object=} dialogState JSON object the app uses to hold dialog state that
|
||||
* will be circulated back by Assistant. Used in {@link ActionsSdkAssistant}.
|
||||
* @actionssdk
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
askForConfirmation(prompt?: string, dialogState?: object): object;
|
||||
|
||||
@@ -814,7 +814,7 @@ export class AssistantApp {
|
||||
* Asks user for a timezone-agnostic date and time.
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({ request, response });
|
||||
* const app = new DialogflowApp({ request, response });
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const DATETIME = 'datetime';
|
||||
*
|
||||
@@ -850,7 +850,7 @@ export class AssistantApp {
|
||||
* @param {Object=} dialogState JSON object the app uses to hold dialog state that
|
||||
* will be circulated back by Assistant. Used in {@link ActionsSdkAssistant}.
|
||||
* @actionssdk
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
askForDateTime(initialPrompt?: string, datePrompt?: string, timePrompt?: string, dialogState?: object): object;
|
||||
|
||||
@@ -866,7 +866,7 @@ export class AssistantApp {
|
||||
* consent".
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({ request, response });
|
||||
* const app = new DialogflowApp({ request, response });
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const SIGN_IN = 'sign.in';
|
||||
*
|
||||
@@ -891,7 +891,7 @@ export class AssistantApp {
|
||||
* @param {Object=} dialogState JSON object the app uses to hold dialog state that
|
||||
* will be circulated back by Assistant. Used in {@link ActionsSdkAssistant}.
|
||||
* @actionssdk
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
askForSignIn(dialogState?: object): object;
|
||||
|
||||
@@ -899,7 +899,7 @@ export class AssistantApp {
|
||||
* Requests the user to switch to another surface during the conversation.
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({ request, response });
|
||||
* const app = new DialogflowApp({ request, response });
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const SHOW_IMAGE = 'show.image';
|
||||
*
|
||||
@@ -937,7 +937,7 @@ export class AssistantApp {
|
||||
* the surface.
|
||||
* @param {Object=} dialogState JSON object the app uses to hold dialog state that
|
||||
* will be circulated back by Assistant. Used in {@link ActionsSdkAssistant}.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
askForNewSurface(context: string, notificationTitle: string, capabilities: string[], dialogState?: object): object;
|
||||
@@ -949,14 +949,14 @@ export class AssistantApp {
|
||||
* see {@link AssistantApp#askForPermissions|askForPermissions}).
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({request: request, response: response});
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* // or
|
||||
* const app = new ActionsSdkApp({request: request, response: response});
|
||||
* const userId = app.getUser().userId;
|
||||
*
|
||||
* @return {User} Null if no value.
|
||||
* @actionssdk
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
getUser(): User;
|
||||
|
||||
@@ -966,7 +966,7 @@ export class AssistantApp {
|
||||
* returns null.
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAIApp({request: req, response: res});
|
||||
* const app = new DialogflowApp({request: req, response: res});
|
||||
* const REQUEST_PERMISSION_ACTION = 'request_permission';
|
||||
* const SAY_NAME_ACTION = 'get_name';
|
||||
*
|
||||
@@ -989,7 +989,7 @@ export class AssistantApp {
|
||||
* app.handleRequest(actionMap);
|
||||
* @return {UserName} Null if name permission is not granted.
|
||||
* @actionssdk
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
getUserName(): UserName;
|
||||
|
||||
@@ -999,12 +999,12 @@ export class AssistantApp {
|
||||
* For example, 'en-US' represents US English.
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({request, response});
|
||||
* const app = new DialogflowApp({request, response});
|
||||
* const locale = app.getUserLocale();
|
||||
*
|
||||
* @return {string} User's locale, e.g. 'en-US'. Null if no locale given.
|
||||
* @actionssdk
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
getUserLocale(): string;
|
||||
|
||||
@@ -1014,7 +1014,7 @@ export class AssistantApp {
|
||||
* If device info is unavailable, returns null.
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({request: req, response: res});
|
||||
* const app = new DialogflowApp({request: req, response: res});
|
||||
* // or
|
||||
* const app = new ActionsSdkApp({request: req, response: res});
|
||||
* app.askForPermission("To get you a ride",
|
||||
@@ -1027,7 +1027,7 @@ export class AssistantApp {
|
||||
*
|
||||
* @return {DeviceLocation} Null if location permission is not granted.
|
||||
* @actionssdk
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
getDeviceLocation(): DeviceLocation;
|
||||
|
||||
@@ -1036,7 +1036,7 @@ export class AssistantApp {
|
||||
*
|
||||
* @return {number} One of AssistantApp.InputTypes.
|
||||
* Null if no input type given.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
getInputType(): number;
|
||||
@@ -1050,7 +1050,7 @@ export class AssistantApp {
|
||||
* the argument object will be in Proto2 format (snake_case, etc).
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({request: request, response: response});
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const NUMBER_INTENT = 'input.number';
|
||||
*
|
||||
@@ -1071,7 +1071,7 @@ export class AssistantApp {
|
||||
* @param {string} argName Name of the argument.
|
||||
* @return {Object} Argument value matching argName
|
||||
* or null if no matching argument.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
getArgumentCommon(argName: string): object;
|
||||
@@ -1081,7 +1081,7 @@ export class AssistantApp {
|
||||
* askForTransactionRequirements. Null if no result given.
|
||||
*
|
||||
* @return {string} One of Transactions.ResultType.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
getTransactionRequirementsResult(): string;
|
||||
@@ -1091,7 +1091,7 @@ export class AssistantApp {
|
||||
*
|
||||
* @return {DeliveryAddress} Delivery address information. Null if user
|
||||
* denies permission, or no address given.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
getDeliveryAddress(): Location;
|
||||
@@ -1103,7 +1103,7 @@ export class AssistantApp {
|
||||
* @return {TransactionDecision} Transaction decision data. Returns object with
|
||||
* userDecision only if user declines. userDecision will be one of
|
||||
* Transactions.ConfirmationDecision. Null if no decision given.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
getTransactionDecision(): TransactionDecision;
|
||||
@@ -1113,7 +1113,7 @@ export class AssistantApp {
|
||||
*
|
||||
* False if user replied with negative response. Null if no user
|
||||
* confirmation decision given.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
getUserConfirmation(): boolean | null;
|
||||
@@ -1123,7 +1123,7 @@ export class AssistantApp {
|
||||
*
|
||||
* @return {DateTime} Date and time given by the user. Null if no user
|
||||
* date and time given.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
getDateTime(): DateTime;
|
||||
@@ -1132,9 +1132,9 @@ export class AssistantApp {
|
||||
* Gets status of user sign in request.
|
||||
*
|
||||
* @return {string} Result of user sign in request. One of
|
||||
* ApiAiApp.SignInStatus or ActionsSdkApp.SignInStatus
|
||||
* DialogflowApp.SignInStatus or ActionsSdkApp.SignInStatus
|
||||
* Null if no sign in status.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
getSignInStatus(): string;
|
||||
@@ -1146,7 +1146,7 @@ export class AssistantApp {
|
||||
* @return {boolean} True if user device has the given capability.
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAIApp({request: req, response: res});
|
||||
* const app = new DialogflowApp({request: req, response: res});
|
||||
* const DESCRIBE_SOMETHING = 'DESCRIBE_SOMETHING';
|
||||
*
|
||||
* function describe (app) {
|
||||
@@ -1160,7 +1160,7 @@ export class AssistantApp {
|
||||
* actionMap.set(DESCRIBE_SOMETHING, describe);
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
hasSurfaceCapability(requestedCapability: string): boolean;
|
||||
@@ -1170,7 +1170,7 @@ export class AssistantApp {
|
||||
*
|
||||
* @return {Array<string>} Supported surface capabilities, as defined in
|
||||
* AssistantApp.SurfaceCapabilities.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
getSurfaceCapabilities(): string[];
|
||||
@@ -1180,7 +1180,7 @@ export class AssistantApp {
|
||||
*
|
||||
* @return {Array<Surface>} Empty if no available surfaces.
|
||||
* @actionssdk
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
getAvailableSurfaces(): Surface[];
|
||||
|
||||
@@ -1193,7 +1193,7 @@ export class AssistantApp {
|
||||
* {@link SurfaceCapabilities}.
|
||||
* @return {boolean} True if user has a capability available on some surface.
|
||||
*
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
hasAvailableSurfaceCapabilities(capabilities: string | string[]): boolean;
|
||||
@@ -1204,7 +1204,7 @@ export class AssistantApp {
|
||||
* @return {boolean} True if user has triggered conversation on a new device
|
||||
* following the NEW_SURFACE intent.
|
||||
* @actionssdk
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
isNewSurface(): boolean;
|
||||
|
||||
@@ -1214,7 +1214,7 @@ export class AssistantApp {
|
||||
* transactions.
|
||||
*
|
||||
* @return {boolean} True if app is being used in Sandbox mode.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
isInSandbox(): boolean;
|
||||
@@ -1249,7 +1249,7 @@ export class AssistantApp {
|
||||
*
|
||||
* @return {number} The current reprompt count. Null if no reprompt count
|
||||
* available (e.g. not in the NO_INPUT intent).
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
getRepromptCount(): number;
|
||||
@@ -1284,7 +1284,7 @@ export class AssistantApp {
|
||||
*
|
||||
* @return {boolean} True if in a NO_INPUT intent and this is the final turn
|
||||
* of dialog.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
isFinalReprompt(): boolean;
|
||||
|
||||
@@ -5,41 +5,41 @@ import { Carousel, List, RichResponse, SimpleResponse } from './response-builder
|
||||
import { TransactionDecision } from './transactions';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// API.AI support
|
||||
// Dialogflow support
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* API.AI {@link https://docs.api.ai/docs/concept-contexts|Context}.
|
||||
* DialogflowApp {@link https://dialogflow.com/docs/concept-contexts|Context}.
|
||||
*/
|
||||
export interface Context {
|
||||
/** Full name of the context. */
|
||||
name: string;
|
||||
/**
|
||||
* Parameters carried within this context.
|
||||
* See {@link https://docs.api.ai/docs/concept-actions#section-extracting-values-from-contexts|here}.
|
||||
* See {@link https://dialogflow.com/docs/concept-actions#section-extracting-values-from-contexts|here}.
|
||||
*/
|
||||
parameters: object;
|
||||
/** Remaining number of intents */
|
||||
lifespan: number;
|
||||
}
|
||||
|
||||
export interface ApiAiAppOptions {
|
||||
export interface DialogflowAppOptions {
|
||||
request: Request;
|
||||
response: Response;
|
||||
sessionStarted?: SessionStartedFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the class that handles the communication with API.AI's fulfillment API.
|
||||
* This is the class that handles the communication with Dialogflow's fulfillment API.
|
||||
*/
|
||||
export class ApiAiApp extends AssistantApp {
|
||||
export class DialogflowApp extends AssistantApp {
|
||||
/**
|
||||
* Constructor for ApiAiApp object.
|
||||
* To be used in the API.AI fulfillment webhook logic.
|
||||
* Constructor for DialogflowApp object.
|
||||
* To be used in the Dialogflow fulfillment webhook logic.
|
||||
*
|
||||
* @example
|
||||
* const ApiAiApp = require('actions-on-google').ApiAiApp;
|
||||
* const app = new ApiAiApp({request: request, response: response,
|
||||
* const DialogflowApp = require('actions-on-google').DialogflowApp;
|
||||
* const app = new DialogflowApp({request: request, response: response,
|
||||
* sessionStarted:sessionStarted});
|
||||
*
|
||||
* @param {Object} options JSON configuration.
|
||||
@@ -47,31 +47,44 @@ export class ApiAiApp extends AssistantApp {
|
||||
* @param {Object} options.response Express HTTP response object.
|
||||
* @param {Function=} options.sessionStarted Function callback when session starts.
|
||||
* Only called if webhook is enabled for welcome/triggering intents, and
|
||||
* called from Web Simulator or Google Home device (i.e., not API.AI simulator).
|
||||
* @apiai
|
||||
* called from Web Simulator or Google Home device (i.e., not Dialogflow simulator).
|
||||
* @dialogflow
|
||||
*/
|
||||
constructor(options: ApiAiAppOptions);
|
||||
constructor(options: DialogflowAppOptions);
|
||||
|
||||
/**
|
||||
* Verifies whether the request comes from API.AI.
|
||||
* @deprecated
|
||||
* Verifies whether the request comes from Dialogflow.
|
||||
*
|
||||
* @param {string} key The header key specified by the developer in the
|
||||
* API.AI Fulfillment settings of the app.
|
||||
* Dialogflow Fulfillment settings of the app.
|
||||
* @param {string} value The private value specified by the developer inside the
|
||||
* fulfillment header.
|
||||
* @return {boolean} True if the request comes from API.AI.
|
||||
* @apiai
|
||||
* @return {boolean} True if the request comes from Dialogflow.
|
||||
* @dialogflow
|
||||
*/
|
||||
isRequestFromApiAi(key: string, value: string): boolean;
|
||||
|
||||
/**
|
||||
* Verifies whether the request comes from Dialogflow.
|
||||
*
|
||||
* @param {string} key The header key specified by the developer in the
|
||||
* Dialogflow Fulfillment settings of the app.
|
||||
* @param {string} value The private value specified by the developer inside the
|
||||
* fulfillment header.
|
||||
* @return {boolean} True if the request comes from Dialogflow.
|
||||
* @dialogflow
|
||||
*/
|
||||
isRequestFromDialogflow(key: string, value: string): boolean;
|
||||
|
||||
/**
|
||||
* Get the current intent. Alternatively, using a handler Map with
|
||||
* {@link AssistantApp#handleRequest|handleRequest},
|
||||
* the client library will automatically handle the incoming intents.
|
||||
* 'Intent' in the API.ai context translates into the current action.
|
||||
* 'Intent' in the Dialogflow context translates into the current action.
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({request: request, response: response});
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
*
|
||||
* function responseHandler (app) {
|
||||
* const intent = app.getIntent();
|
||||
@@ -90,7 +103,7 @@ export class ApiAiApp extends AssistantApp {
|
||||
* app.handleRequest(responseHandler);
|
||||
*
|
||||
* @return {string} Intent id or null if no value (action name).
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
getIntent(): string;
|
||||
|
||||
@@ -103,7 +116,7 @@ export class ApiAiApp extends AssistantApp {
|
||||
* the argument object will be in Proto2 format (snake_case, etc).
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({request: request, response: response});
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const NUMBER_INTENT = 'input.number';
|
||||
*
|
||||
@@ -124,7 +137,7 @@ export class ApiAiApp extends AssistantApp {
|
||||
* @param {string} argName Name of the argument.
|
||||
* @return {Object} Argument value matching argName
|
||||
* or null if no matching argument.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
getArgument(argName: string): object;
|
||||
|
||||
@@ -136,7 +149,7 @@ export class ApiAiApp extends AssistantApp {
|
||||
* as part of the return object.
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({request: request, response: response});
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const NUMBER_INTENT = 'input.number';
|
||||
* const OUT_CONTEXT = 'output_context';
|
||||
@@ -164,12 +177,12 @@ export class ApiAiApp extends AssistantApp {
|
||||
* @param {string} argName Name of the argument.
|
||||
* @return {Object} Object containing value property and optional original
|
||||
* property matching context argument. Null if no matching argument.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
getContextArgument(contextName: string, argName: string): object;
|
||||
|
||||
/**
|
||||
* Returns the RichResponse constructed in API.AI response builder.
|
||||
* Returns the RichResponse constructed in Dialogflow response builder.
|
||||
*
|
||||
* @example
|
||||
* const app = new App({request: req, response: res});
|
||||
@@ -192,14 +205,14 @@ export class ApiAiApp extends AssistantApp {
|
||||
*
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @return {RichResponse} RichResponse created in API.AI. If no RichResponse was
|
||||
* @return {RichResponse} RichResponse created in Dialogflow. If no RichResponse was
|
||||
* created, an empty RichResponse is returned.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
getIncomingRichResponse(): RichResponse;
|
||||
|
||||
/**
|
||||
* Returns the List constructed in API.AI response builder.
|
||||
* Returns the List constructed in Dialogflow response builder.
|
||||
*
|
||||
* @example
|
||||
* const app = new App({request: req, response: res});
|
||||
@@ -220,14 +233,14 @@ export class ApiAiApp extends AssistantApp {
|
||||
*
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @return {List} List created in API.AI. If no List was created, an empty
|
||||
* @return {List} List created in Dialogflow. If no List was created, an empty
|
||||
* List is returned.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
getIncomingList(): List;
|
||||
|
||||
/**
|
||||
* Returns the Carousel constructed in API.AI response builder.
|
||||
* Returns the Carousel constructed in Dialogflow response builder.
|
||||
*
|
||||
* @example
|
||||
* const app = new App({request: req, response: res});
|
||||
@@ -248,9 +261,9 @@ export class ApiAiApp extends AssistantApp {
|
||||
*
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @return {Carousel} Carousel created in API.AI. If no Carousel was created,
|
||||
* @return {Carousel} Carousel created in Dialogflow. If no Carousel was created,
|
||||
* an empty Carousel is returned.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
getIncomingCarousel(): Carousel;
|
||||
|
||||
@@ -283,7 +296,7 @@ export class ApiAiApp extends AssistantApp {
|
||||
*
|
||||
* @return {string} Option key of selected item. Null if no option selected or
|
||||
* if current intent is not OPTION intent.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
getSelectedOption(): string;
|
||||
|
||||
@@ -296,7 +309,7 @@ export class ApiAiApp extends AssistantApp {
|
||||
* for a bye message until the bug is fixed.
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({request: request, response: response});
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const NUMBER_INTENT = 'input.number';
|
||||
*
|
||||
@@ -319,7 +332,7 @@ export class ApiAiApp extends AssistantApp {
|
||||
* response.
|
||||
* @param {Array<string>=} noInputs Array of re-prompts when the user does not respond (max 3).
|
||||
* @return {Object} HTTP response.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
ask(inputPrompt: string | SimpleResponse | RichResponse, noInputs?: string[]): object;
|
||||
|
||||
@@ -327,7 +340,7 @@ export class ApiAiApp extends AssistantApp {
|
||||
* Asks to collect the user's input with a list.
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({request, response});
|
||||
* const app = new DialogflowApp({request, response});
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const OPTION_INTENT = 'option.select';
|
||||
*
|
||||
@@ -361,7 +374,7 @@ export class ApiAiApp extends AssistantApp {
|
||||
* response.
|
||||
* @param {List} list List built with {@link AssistantApp#buildList|buildList}.
|
||||
* @return {Object} HTTP response.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
askWithList(inputPrompt: string | RichResponse | SimpleResponse, list: List): object;
|
||||
|
||||
@@ -369,7 +382,7 @@ export class ApiAiApp extends AssistantApp {
|
||||
* Asks to collect the user's input with a carousel.
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({request, response});
|
||||
* const app = new DialogflowApp({request, response});
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const OPTION_INTENT = 'option.select';
|
||||
*
|
||||
@@ -404,7 +417,7 @@ export class ApiAiApp extends AssistantApp {
|
||||
* @param {Carousel} carousel Carousel built with
|
||||
* {@link AssistantApp#buildCarousel|buildCarousel}.
|
||||
* @return {Object} HTTP response.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
askWithCarousel(inputPrompt: string | RichResponse | SimpleResponse, carousel: Carousel): object;
|
||||
|
||||
@@ -412,7 +425,7 @@ export class ApiAiApp extends AssistantApp {
|
||||
* Tells the Assistant to render the speech response and close the mic.
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({request: request, response: response});
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* const WELCOME_INTENT = 'input.welcome';
|
||||
* const NUMBER_INTENT = 'input.number';
|
||||
*
|
||||
@@ -433,7 +446,7 @@ export class ApiAiApp extends AssistantApp {
|
||||
* @param {string|SimpleResponse|RichResponse} textToSpeech Final response.
|
||||
* Spoken response can be SSML.
|
||||
* @return The response that is sent back to Assistant.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
tell(speechResponse: string | SimpleResponse | RichResponse): object;
|
||||
|
||||
@@ -441,7 +454,7 @@ export class ApiAiApp extends AssistantApp {
|
||||
* Set a new context for the current intent.
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({request: request, response: response});
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* const CONTEXT_NUMBER = 'number';
|
||||
* const NUMBER_ARGUMENT = 'myNumber';
|
||||
*
|
||||
@@ -460,10 +473,10 @@ export class ApiAiApp extends AssistantApp {
|
||||
* actionMap.set(NUMBER_INTENT, numberIntent);
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @param {string} name Name of the context. API.AI converts to lowercase.
|
||||
* @param {string} name Name of the context. Dialogflow converts to lowercase.
|
||||
* @param {int} [lifespan=1] Context lifespan.
|
||||
* @param {Object=} parameters Context JSON parameters.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
setContext(name: string, lifespan: number, parameters?: object): void;
|
||||
|
||||
@@ -471,7 +484,7 @@ export class ApiAiApp extends AssistantApp {
|
||||
* Returns the incoming contexts for this intent.
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({request: request, response: response});
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* const CONTEXT_NUMBER = 'number';
|
||||
* const NUMBER_ARGUMENT = 'myNumber';
|
||||
*
|
||||
@@ -500,7 +513,7 @@ export class ApiAiApp extends AssistantApp {
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @return {Context[]} Empty if no active contexts.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
getContexts(): Context[];
|
||||
|
||||
@@ -508,7 +521,7 @@ export class ApiAiApp extends AssistantApp {
|
||||
* Returns the incoming context by name for this intent.
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiapp({request: request, response: response});
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* const CONTEXT_NUMBER = 'number';
|
||||
* const NUMBER_ARGUMENT = 'myNumber';
|
||||
*
|
||||
@@ -538,7 +551,7 @@ export class ApiAiApp extends AssistantApp {
|
||||
*
|
||||
* @return {Object} Context value matching name
|
||||
* or null if no matching context.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
getContext(name: string): object;
|
||||
|
||||
@@ -546,11 +559,11 @@ export class ApiAiApp extends AssistantApp {
|
||||
* Gets the user's raw input query.
|
||||
*
|
||||
* @example
|
||||
* const app = new ApiAiApp({request: request, response: response});
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
* app.tell('You said ' + app.getRawInput());
|
||||
*
|
||||
* @return {string} User's raw query or null if no value.
|
||||
* @apiai
|
||||
* @dialogflow
|
||||
*/
|
||||
getRawInput(): string;
|
||||
}
|
||||
7
types/actions-on-google/index.d.ts
vendored
7
types/actions-on-google/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for actions-on-google 1.4
|
||||
// Type definitions for actions-on-google 1.5
|
||||
// Project: https://github.com/actions-on-google/actions-on-google-nodejs
|
||||
// Definitions by: Joel Hegg <https://github.com/joelhegg>, Pilwon Huh <https://github.com/pilwon>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -14,10 +14,11 @@ import * as Responses from './response-builder';
|
||||
|
||||
export { AssistantApp, AssistantAppOptions, RequestHandler, SessionStartedFunction, State } from './assistant-app';
|
||||
export { ActionsSdkApp, ActionsSdkAppOptions } from './actions-sdk-app';
|
||||
export { ApiAiApp, ApiAiAppOptions } from './api-ai-app';
|
||||
export { DialogflowApp, DialogflowAppOptions } from './dialogflow-app';
|
||||
export { Transactions };
|
||||
export { Responses };
|
||||
// Backwards compatibility
|
||||
export { AssistantApp as Assistant } from './assistant-app';
|
||||
export { ActionsSdkApp as ActionsSdkAssistant } from './actions-sdk-app';
|
||||
export { ApiAiApp as ApiAiAssistant } from './api-ai-app';
|
||||
export { DialogflowApp as ApiAiAssistant } from './dialogflow-app';
|
||||
export { DialogflowApp as ApiAiApp } from './dialogflow-app';
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"index.d.ts",
|
||||
"assistant-app.d.ts",
|
||||
"actions-sdk-app.d.ts",
|
||||
"api-ai-app.d.ts",
|
||||
"dialogflow-app.d.ts",
|
||||
"response-builder.d.ts",
|
||||
"transactions.d.ts",
|
||||
"actions-on-google-tests.ts"
|
||||
|
||||
Reference in New Issue
Block a user