actions-on-google
- Version 3.0.0
- Published
- 947 kB
- 8 dependencies
- Apache-2.0 license
Install
npm i actions-on-google
yarn add actions-on-google
pnpm add actions-on-google
Overview
Actions on Google Client Library for Node.js
Index
Variables
Classes
Interfaces
Type Aliases
- AppHandler
- Argument
- CarouselArgument
- challengeType
- CompletePurchaseArgument
- ConfirmationArgument
- DateTimeArgument
- DefaultDialogflowIntent
- DeliveryAddressArgument
- DialogflowV1Message
- DigitalPurchaseCheckArgument
- FinalRepromptArgument
- GoogleActionsOrdersV3ActionType
- GoogleActionsOrdersV3OrderUpdateType
- GoogleActionsOrdersV3PriceAttributeState
- GoogleActionsOrdersV3PriceAttributeType
- GoogleActionsOrdersV3VerticalsPurchaseMerchantUnitMeasureUnit
- GoogleActionsOrdersV3VerticalsPurchasePickupInfoCurbsideInfoCurbsideFulfillmentType
- GoogleActionsOrdersV3VerticalsPurchasePickupInfoPickupType
- GoogleActionsOrdersV3VerticalsPurchasePurchaseErrorType
- GoogleActionsOrdersV3VerticalsPurchasePurchaseFulfillmentInfoFulfillmentType
- GoogleActionsOrdersV3VerticalsPurchasePurchaseItemExtensionStatus
- GoogleActionsOrdersV3VerticalsPurchasePurchaseItemExtensionType
- GoogleActionsOrdersV3VerticalsPurchasePurchaseOrderExtensionPurchaseLocationType
- GoogleActionsOrdersV3VerticalsPurchasePurchaseOrderExtensionStatus
- GoogleActionsOrdersV3VerticalsPurchasePurchaseOrderExtensionType
- GoogleActionsOrdersV3VerticalsReservationReservationItemExtensionStatus
- GoogleActionsOrdersV3VerticalsReservationReservationItemExtensionType
- GoogleActionsOrdersV3VerticalsTicketEventCharacterType
- GoogleActionsOrdersV3VerticalsTicketTicketEventType
- GoogleActionsTransactionsV3CompletePurchaseValuePurchaseStatus
- GoogleActionsTransactionsV3DigitalPurchaseCheckResultResultType
- GoogleActionsTransactionsV3PaymentInfoPaymentMethodProvenance
- GoogleActionsTransactionsV3PaymentMethodDisplayInfoPaymentType
- GoogleActionsTransactionsV3PaymentMethodStatusStatus
- GoogleActionsTransactionsV3SkuIdSkuType
- GoogleActionsTransactionsV3TransactionDecisionValueTransactionDecision
- GoogleActionsTransactionsV3TransactionRequirementsCheckResultResultType
- GoogleActionsTransactionsV3UserInfoOptionsUserInfoProperties
- GoogleActionsV2ConversationType
- GoogleActionsV2DeliveryAddressValueUserDecision
- GoogleActionsV2EntitlementSkuType
- GoogleActionsV2MediaResponseMediaType
- GoogleActionsV2MediaStatusStatus
- GoogleActionsV2NewSurfaceValueStatus
- GoogleActionsV2OrdersActionProvidedPaymentOptionsPaymentType
- GoogleActionsV2OrdersCustomerInfoOptionsCustomerInfoProperties
- GoogleActionsV2OrdersGoogleProvidedPaymentOptionsSupportedCardNetworks
- GoogleActionsV2OrdersLineItemType
- GoogleActionsV2OrdersOrderLocationType
- GoogleActionsV2OrdersOrderUpdateActionType
- GoogleActionsV2OrdersPaymentInfoPaymentType
- GoogleActionsV2OrdersPaymentMethodTokenizationParametersTokenizationType
- GoogleActionsV2OrdersPriceType
- GoogleActionsV2OrdersRejectionInfoType
- GoogleActionsV2OrdersTimeType
- GoogleActionsV2PermissionValueSpecPermissions
- GoogleActionsV2RawInputInputType
- GoogleActionsV2RegisterUpdateValueStatus
- GoogleActionsV2SignInValueStatus
- GoogleActionsV2TransactionDecisionValueUserDecision
- GoogleActionsV2TransactionRequirementsCheckResultResultType
- GoogleActionsV2TriggerContextTimeContextFrequency
- GoogleActionsV2UiElementsBasicCardImageDisplayOptions
- GoogleActionsV2UiElementsCarouselBrowseImageDisplayOptions
- GoogleActionsV2UiElementsCarouselSelectImageDisplayOptions
- GoogleActionsV2UiElementsCollectionSelectImageDisplayOptions
- GoogleActionsV2UiElementsOpenUrlActionUrlTypeHint
- GoogleActionsV2UiElementsTableCardColumnPropertiesHorizontalAlignment
- GoogleActionsV2UserPermissions
- GoogleActionsV2UserUserVerificationStatus
- GoogleCloudDialogflowV2IntentDefaultResponsePlatforms
- GoogleCloudDialogflowV2IntentMessagePlatform
- GoogleCloudDialogflowV2IntentTrainingPhraseType
- GoogleCloudDialogflowV2IntentWebhookState
- Intent
- ListArgument
- MediaStatusArgument
- NewSurfaceArgument
- OptionArgument
- PermissionArgument
- PlaceArgument
- RegisterUpdateArgument
- RepromptArgument
- Response
- RichResponseItem
- SignInArgument
- SmartHomeV1ExecuteErrors
- SmartHomeV1ExecuteStatus
- SmartHomeV1Intents
- SmartHomeV1Request
- SmartHomeV1Response
- SurfaceCapability
- TransactionDecisionArgument
- TransactionRequirementsArgument
- UpdatePermissionUserIdArgument
Variables
variable actionssdk
const actionssdk: ActionsSdk;
This is the function that creates the app instance which on new requests, creates a way to interact with the conversation API directly from Assistant, providing implementation for all the methods available in the API.
Only supports Actions SDK v2.
Example 1
const app = actionssdk()app.intent('actions.intent.MAIN', conv => {conv.ask('How are you?')})Modifiers
@public
variable dialogflow
const dialogflow: Dialogflow;
This is the function that creates the app instance which on new requests, creates a way to handle the communication with Dialogflow's fulfillment API.
Supports Dialogflow v1 and v2.
Example 1
const app = dialogflow()app.intent('Default Welcome Intent', conv => {conv.ask('How are you?')})Modifiers
@public
variable smarthome
const smarthome: SmartHome;
Example 1
const app = smarthome({debug: true,key: '<api-key>',jwt: require('./key.json')});app.onSync((body, headers) => {return { ... }});app.onQuery((body, headers) => {return { ... }});app.onExecute((body, headers) => {return { ... }});exports.smarthome = functions.https.onRequest(app);Modifiers
@public
Classes
class ActionsSdkConversation
class ActionsSdkConversation< TConvData = JsonObject, TUserStorage = JsonObject> extends Conversation<TUserStorage> {}
Modifiers
@public
constructor
constructor(options?: ActionsSdkConversationOptions<TConvData, TUserStorage>);
Modifiers
@public
property body
body: Api.GoogleActionsV2AppRequest;
Modifiers
@public
property data
data: {};
The session data in JSON format. Stored using conversationToken.
Example 1
app.intent('actions.intent.MAIN', conv => {conv.data.someProperty = 'someValue'})Modifiers
@public
property intent
intent: string;
Get the current Actions SDK intent.
Example 1
app.intent('actions.intent.MAIN', conv => {const intent = conv.intent // will be 'actions.intent.MAIN'})Modifiers
@public
method serialize
serialize: () => Api.GoogleActionsV2AppResponse;
Modifiers
@public
class BasicCard
class BasicCard implements Api.GoogleActionsV2UiElementsBasicCard {}
constructor
constructor(options: BasicCardOptions);
Modifiers
@public
class BrowseCarousel
class BrowseCarousel implements Api.GoogleActionsV2UiElementsCarouselBrowse {}
constructor
constructor(options: BrowseCarouselOptions);
Parameter options
BrowseCarousel options
Modifiers
@public
constructor
constructor(items: Api.GoogleActionsV2UiElementsCarouselBrowseItem[]);
Parameter items
BrowseCarousel items
Modifiers
@public
constructor
constructor(...items: Api.GoogleActionsV2UiElementsCarouselBrowseItem[]);
Parameter items
BrowseCarousel items
Modifiers
@public
class BrowseCarouselItem
class BrowseCarouselItem implements Api.GoogleActionsV2UiElementsCarouselBrowseItem {}
constructor
constructor(options: BrowseCarouselItemOptions);
Parameter options
BrowseCarouselItem options
Modifiers
@public
class Button
class Button implements Api.GoogleActionsV2UiElementsButton {}
constructor
constructor(options: ButtonOptions);
Parameter options
Button options
Modifiers
@public
class Carousel
class Carousel extends Helper< 'actions.intent.OPTION', Api.GoogleActionsV2OptionValueSpec> {}
Asks to collect user's input with a carousel.
Example 1
// Actions SDKconst app = actionssdk()app.intent('actions.intent.MAIN', conv => {conv.ask('Which of these looks good?')conv.ask(new Carousel({items: {[SELECTION_KEY_ONE]: {title: 'Number one',description: 'Description of number one',synonyms: ['synonym of KEY_ONE 1', 'synonym of KEY_ONE 2'],},[SELECTION_KEY_TWO]: {title: 'Number two',description: 'Description of number one',synonyms: ['synonym of KEY_TWO 1', 'synonym of KEY_TWO 2'],}}}))})app.intent('actions.intent.OPTION', (conv, input, option) => {if (option === SELECTION_KEY_ONE) {conv.close('Number one is a great choice!')} else {conv.close('Number two is also a great choice!')}})// Dialogflowconst app = dialogflow()app.intent('Default Welcome Intent', conv => {conv.ask('Which of these looks good?')conv.ask(new Carousel({items: {[SELECTION_KEY_ONE]: {title: 'Number one',description: 'Description of number one',synonyms: ['synonym of KEY_ONE 1', 'synonym of KEY_ONE 2'],},[SELECTION_KEY_TWO]: {title: 'Number two',description: 'Description of number one',synonyms: ['synonym of KEY_TWO 1', 'synonym of KEY_TWO 2'],}}}))})// Create a Dialogflow intent with the `actions_intent_OPTION` eventapp.intent('Get Option', (conv, input, option) => {if (option === SELECTION_KEY_ONE) {conv.close('Number one is a great choice!')} else {conv.close('Number two is also a great choice!')}})Modifiers
@public
constructor
constructor(options: CarouselOptions);
Parameter options
Carousel option
Modifiers
@public
class CompletePurchase
class CompletePurchase extends SoloHelper< 'actions.intent.COMPLETE_PURCHASE', Api.GoogleActionsTransactionsV3CompletePurchaseValueSpec> {}
Asks the user to complete a purchase
Modifiers
@public
constructor
constructor(options?: Api.GoogleActionsTransactionsV3CompletePurchaseValueSpec);
Parameter options
The raw GoogleActionsTransactionsV3CompletePurchaseValueSpec
Modifiers
@public
class Confirmation
class Confirmation extends SoloHelper< 'actions.intent.CONFIRMATION', Api.GoogleActionsV2ConfirmationValueSpec> {}
Asks user for a confirmation.
Example 1
// Actions SDKconst app = actionssdk()app.intent('actions.intent.MAIN', conv => {conv.ask(new Confirmation('Are you sure you want to do that?'))})app.intent('actions.intent.CONFIRMATION', (conv, input, confirmation) => {if (confirmation) {conv.close(`Great! I'm glad you want to do it!`)} else {conv.close(`That's okay. Let's not do it now.`)}})// Dialogflowconst app = dialogflow()app.intent('Default Welcome Intent', conv => {conv.ask(new Confirmation('Are you sure you want to do that?'))})// Create a Dialogflow intent with the `actions_intent_CONFIRMATION` eventapp.intent('Get Confirmation', (conv, input, confirmation) => {if (confirmation) {conv.close(`Great! I'm glad you want to do it!`)} else {conv.close(`That's okay. Let's not do it now.`)}})Modifiers
@public
constructor
constructor(text: string);
Parameter text
The confirmation prompt presented to the user to query for an affirmative or negative response.
Modifiers
@public
class Conversation
class Conversation<TUserStorage> {}
Modifiers
@public
constructor
constructor(options?: ConversationOptions<TUserStorage>);
property arguments
arguments: Arguments;
Modifiers
@public
property available
available: Available;
Modifiers
@public
property canvas
canvas: Canvas;
Modifiers
@public
property device
device: Device;
Modifiers
@public
property digested
digested: boolean;
Modifiers
@public
property expectUserResponse
expectUserResponse: boolean;
Modifiers
@public
property headers
headers: Headers;
Modifiers
@public
property id
id: string;
Gets the unique conversation ID. It's a new ID for the initial query, and stays the same until the end of the conversation.
Example 1
app.intent('actions.intent.MAIN', conv => {const conversationId = conv.id})Modifiers
@public
property input
input: Input;
Modifiers
@public
property noInputs
noInputs: (string | SimpleResponse)[];
Set reprompts when users don't provide input to this action (no-input errors). Each reprompt represents as the SimpleResponse, but raw strings also can be specified for convenience (they're passed to the constructor of SimpleResponse). Notice that this value is not kept over conversations. Thus, it is necessary to set the reprompts per each conversation response.
Example 1
app.intent('actions.intent.MAIN', conv => {conv.noInputs = ['Are you still there?','Hello?',new SimpleResponse({text: 'Talk to you later. Bye!',speech: '<speak>Talk to you later. Bye!</speak>'})]conv.ask('What's your favorite color?')})Modifiers
@public
property request
request: Api.GoogleActionsV2AppRequest;
Modifiers
@public
property responses
responses: Response[];
Modifiers
@public
property sandbox
sandbox: boolean;
True if the app is being tested in sandbox mode. Enable sandbox mode in the [Actions console](console.actions.google.com) to test transactions.
Modifiers
@public
property screen
screen: boolean;
Shortcut for conv.surface.capabilities.has('actions.capability.SCREEN_OUTPUT')
Modifiers
@public
property speechBiasing
speechBiasing: string[];
Sets speech biasing options.
Example 1
app.intent('actions.intent.MAIN', conv => {conv.speechBiasing = ['red', 'blue', 'green']conv.ask('What is your favorite color out of red, blue, and green?')})Modifiers
@public
property surface
surface: Surface;
Modifiers
@public
property type
type: Api.GoogleActionsV2ConversationType;
Modifiers
@public
property user
user: User<TUserStorage>;
Gets the User object. The user object contains information about the user, including a string identifier and personal information (requires requesting permissions, see conv.ask(new Permission)).
Modifiers
@public
method add
add: (...responses: Response[]) => this;
Modifiers
@public
method ask
ask: (...responses: Response[]) => this;
Asks to collect user's input. All user's queries need to be sent to the app. The guidelines when prompting the user for a response must be followed at all times.
Parameter responses
A response fragment for the library to construct a single complete response
Example 1
// Actions SDKconst app = actionssdk()app.intent('actions.intent.MAIN', conv => {const ssml = '<speak>Hi! <break time="1"/> ' +'I can read out an ordinal like <say-as interpret-as="ordinal">123</say-as>. ' +'Say a number.</speak>'conv.ask(ssml)})app.intent('actions.intent.TEXT', (conv, input) => {if (input === 'bye') {return conv.close('Goodbye!')}const ssml = `<speak>You said, <say-as interpret-as="ordinal">${input}</say-as></speak>`conv.ask(ssml)})// Dialogflowconst app = dialogflow()app.intent('Default Welcome Intent', conv => {conv.ask('Welcome to action snippets! Say a number.')})app.intent('Number Input', (conv, {num}) => {conv.close(`You said ${num}`)})Modifiers
@public
method close
close: (...responses: Response[]) => this;
Have Assistant render the speech response and close the mic.
Parameter responses
A response fragment for the library to construct a single complete response
Example 1
// Actions SDKconst app = actionssdk()app.intent('actions.intent.MAIN', conv => {const ssml = '<speak>Hi! <break time="1"/> ' +'I can read out an ordinal like <say-as interpret-as="ordinal">123</say-as>. ' +'Say a number.</speak>'conv.ask(ssml)})app.intent('actions.intent.TEXT', (conv, input) => {if (input === 'bye') {return conv.close('Goodbye!')}const ssml = `<speak>You said, <say-as interpret-as="ordinal">${input}</say-as></speak>`conv.ask(ssml)})// Dialogflowconst app = dialogflow()app.intent('Default Welcome Intent', conv => {conv.ask('Welcome to action snippets! Say a number.')})app.intent('Number Input', (conv, {num}) => {conv.close(`You said ${num}`)})Modifiers
@public
method json
json: <T = JsonObject>(json: T) => this;
Modifiers
@public
method response
response: () => ConversationResponse;
Modifiers
@public
class DateTime
class DateTime extends SoloHelper< 'actions.intent.DATETIME', Api.GoogleActionsV2DateTimeValueSpec> {}
Asks user for a timezone-agnostic date and time.
Example 1
// Actions SDKconst app = actionssdk()app.intent('actions.intent.MAIN', conv => {conv.ask(new DateTime({prompts: {initial: 'When do you want to come in?',date: 'Which date works best for you?',time: 'What time of day works best for you?',}}))})app.intent('actions.intent.DATETIME', (conv, input, datetime) => {const { month, day } = datetime.dateconst { hours, minutes } = datetime.timeconv.close(new SimpleResponse({speech: 'Great see you at your appointment!',text: `Great, we will see you on ${month}/${day} at ${hours} ${minutes || ''}`}))})// Dialogflowconst app = dialogflow()app.intent('Default Welcome Intent', conv => {conv.ask(new DateTime({prompts: {initial: 'When do you want to come in?',date: 'Which date works best for you?',time: 'What time of day works best for you?',}}))})// Create a Dialogflow intent with the `actions_intent_DATETIME` eventapp.intent('Get Datetime', (conv, params, datetime) => {const { month, day } = datetime.dateconst { hours, minutes } = datetime.timeconv.close(new SimpleResponse({speech: 'Great see you at your appointment!',text: `Great, we will see you on ${month}/${day} at ${hours} ${minutes || ''}`}))})Modifiers
@public
constructor
constructor(options: DateTimeOptions);
Parameter options
DateTime options
Modifiers
@public
class DeliveryAddress
class DeliveryAddress extends SoloHelper< 'actions.intent.DELIVERY_ADDRESS', Api.GoogleActionsV2DeliveryAddressValueSpec> {}
Asks user for delivery address.
Modifiers
@public
constructor
constructor(options?: Api.GoogleActionsV2DeliveryAddressValueSpec);
Parameter options
Modifiers
@public
class DialogflowConversation
class DialogflowConversation< TConvData = JsonObject, TUserStorage = JsonObject, TContexts extends Contexts = Contexts> extends Conversation<TUserStorage> {}
Modifiers
@public
constructor
constructor(options?: DialogflowConversationOptions<TConvData, TUserStorage>);
Modifiers
@public
property action
action: string;
Get the current Dialogflow action name.
Example 1
app.intent('Default Welcome Intent', conv => {const action = conv.action})Modifiers
@public
property body
body: | Api.GoogleCloudDialogflowV2WebhookRequest | ApiV1.DialogflowV1WebhookRequest;
Modifiers
@public
property contexts
contexts: ContextValues<TContexts>;
Modifiers
@public
property data
data: {};
The session data in JSON format. Stored using contexts.
Example 1
app.intent('Default Welcome Intent', conv => {conv.data.someProperty = 'someValue'})Modifiers
@public
property incoming
incoming: Incoming;
Modifiers
@public
property intent
intent: string;
Get the current Dialogflow intent name.
Example 1
app.intent('Default Welcome Intent', conv => {const intent = conv.intent // will be 'Default Welcome Intent'})Modifiers
@public
property parameters
parameters: Parameters;
The Dialogflow parameters from the current intent. Values will only be a string, an Object, or undefined if not included.
Will also be sent via intent handler 3rd argument which is the encouraged method to retrieve.
Example 1
// Encouraged method through intent handlerapp.intent('Tell Greeting', (conv, params) => {const color = params.colorconst num = params.num})// Encouraged method through destructuring in intent handlerapp.intent('Tell Greeting', (conv, { color, num }) => {// now use color and num as variables}))// Using conv.parametersapp.intent('Tell Greeting', conv => {const parameters = conv.parameters// or destructedconst { color, num } = conv.parameters})Modifiers
@public
property query
query: string;
The user's raw input query.
Example 1
app.intent('User Input', conv => {conv.close(`You said ${conv.query}`)})Modifiers
@public
property version
version: number;
Modifiers
@public
method followup
followup: (event: string, parameters?: Parameters, lang?: string) => this;
Triggers an intent of your choosing by sending a followup event from the webhook. Final response can theoretically include responses but these will not be handled by Dialogflow. Dialogflow will not pass anything back to Google Assistant, therefore Google Assistant specific information, most notably conv.user.storage, is ignored.
Parameter event
Name of the event
Parameter parameters
Parameters to send with the event
Parameter lang
The language of this query. See Language Support for a list of the currently supported language codes. Note that queries in the same session do not necessarily need to specify the same language. By default, it is the languageCode sent with Dialogflow's queryResult.languageCode
Example 1
const app = dialogflow()// Create a Dialogflow intent with event 'apply-for-license-event'app.intent('Default Welcome Intent', conv => {conv.followup('apply-for-license-event', {date: new Date().toISOString(),})// The dialogflow intent with the 'apply-for-license-event' event// will be triggered with the given parameters `date`})Modifiers
@public
method serialize
serialize: () => | Api.GoogleCloudDialogflowV2WebhookResponse | ApiV1.DialogflowV1WebhookResponse;
Modifiers
@public
class DigitalPurchaseCheck
class DigitalPurchaseCheck extends SoloHelper< 'actions.intent.DIGITAL_PURCHASE_CHECK', Api.GoogleActionsTransactionsV3DigitalPurchaseCheckSpec> {}
Check to confirm digital purchase eligibility.
Example 1
const app = dialogflow()app.intent('Default Welcome Intent', conv => {// Immediately invoke digital purchase check intent to confirm// purchase eligibility.conv.ask(new DigitalPurchaseCheck())})app.intent('Digital Purchase Check', conv => {const arg = conv.arguments.get('DIGITAL_PURCHASE_CHECK_RESULT')console.log(arg)})Modifiers
@public
constructor
constructor(options?: Api.GoogleActionsTransactionsV3DigitalPurchaseCheckSpec);
Parameter options
Modifiers
@public
class Helper
class Helper<TIntent extends Intent, TValueSpec> implements Api.GoogleActionsV2ExpectedIntent {}
Modifiers
@public
constructor
constructor(options: HelperOptions<TIntent, TValueSpec>);
property inputValueData
inputValueData: { '@type': InputValueSpec };
class HtmlResponse
class HtmlResponse<TData extends JsonObject = JsonObject> implements Api.GoogleActionsV2UiElementsHtmlResponse {}
constructor
constructor( options?: | HtmlResponseOptions<TData> | Api.GoogleActionsV2UiElementsHtmlResponse);
Parameter options
Canvas options
Modifiers
@public
property data
data: JsonObject;
Modifiers
@public
property suppress
suppress: boolean;
Modifiers
@public
class Image
class Image implements Api.GoogleActionsV2UiElementsImage {}
constructor
constructor(option: ImageOptions);
Parameter options
Image options
Modifiers
@public
class LinkOutSuggestion
class LinkOutSuggestion implements Api.GoogleActionsV2UiElementsLinkOutSuggestion {}
constructor
constructor(options: LinkOutSuggestionOptions);
Parameter options
LinkOutSuggestion options
Modifiers
@public
class List
class List extends Helper< 'actions.intent.OPTION', Api.GoogleActionsV2OptionValueSpec> {}
Asks to collect user's input with a list.
Example 1
// Actions SDKconst app = actionssdk()app.intent('actions.intent.MAIN', conv => {conv.ask('Which of these looks good?')conv.ask(new List({items: {[SELECTION_KEY_ONE]: {title: 'Number one',synonyms: ['synonym of KEY_ONE 1', 'synonym of KEY_ONE 2'],},[SELECTION_KEY_TWO]: {title: 'Number two',synonyms: ['synonym of KEY_TWO 1', 'synonym of KEY_TWO 2'],}}}))})app.intent('actions.intent.OPTION', (conv, input, option) => {if (option === SELECTION_KEY_ONE) {conv.close('Number one is a great choice!')} else {conv.close('Number two is also a great choice!')}})// Dialogflowconst app = dialogflow()app.intent('Default Welcome Intent', conv => {conv.ask('Which of these looks good?')conv.ask(new List({items: {[SELECTION_KEY_ONE]: {title: 'Number one',synonyms: ['synonym of KEY_ONE 1', 'synonym of KEY_ONE 2'],},[SELECTION_KEY_TWO]: {title: 'Number two',synonyms: ['synonym of KEY_TWO 1', 'synonym of KEY_TWO 2'],}}}))})// Create a Dialogflow intent with the `actions_intent_OPTION` eventapp.intent('Get Option', (conv, input, option) => {if (option === SELECTION_KEY_ONE) {conv.close('Number one is a great choice!')} else {conv.close('Number two is also a great choice!')}})Modifiers
@public
constructor
constructor(options: ListOptions);
Parameter options
List options
Modifiers
@public
class MediaObject
class MediaObject implements Api.GoogleActionsV2MediaObject {}
constructor
constructor(options: string | MediaObjectOptions);
Parameter options
MediaObject options or just a string for the url
Modifiers
@public
class MediaResponse
class MediaResponse implements Api.GoogleActionsV2MediaResponse {}
constructor
constructor(options: MediaResponseOptions);
Parameter options
MediaResponse options
Modifiers
@public
constructor
constructor(objects: MediaObjectString[]);
Parameter objects
MediaObjects
Modifiers
@public
constructor
constructor(...objects: MediaObjectString[]);
Parameter objects
MediaObjects
Modifiers
@public
class NewSurface
class NewSurface extends SoloHelper< 'actions.intent.NEW_SURFACE', Api.GoogleActionsV2NewSurfaceValueSpec> {}
Requests the user to switch to another surface during the conversation. Works only for en-* locales.
Example 1
// Actions SDKconst app = actionssdk()const imageResponses = [`Here's an image of Google`,new Image({url: 'https://storage.googleapis.com/gweb-uniblog-publish-prod/images/' +'Search_GSA.2e16d0ba.fill-300x300.png',alt: 'Google Logo',})]app.intent('actions.intent.MAIN', conv => {const capability = 'actions.capability.SCREEN_OUTPUT'if (conv.surface.capabilities.has(capability)) {conv.close(...imageResponses)} else {conv.ask(new NewSurface({capabilities: capability,context: 'To show you an image',notification: 'Check out this image',}))}})app.intent('actions.intent.NEW_SURFACE', (conv, input, newSurface) => {if (newSurface.status === 'OK') {conv.close(...imageResponses)} else {conv.close(`Ok, I understand. You don't want to see pictures. Bye`)}})// Dialogflowconst app = dialogflow()const imageResponses = [`Here's an image of Google`,new Image({url: 'https://storage.googleapis.com/gweb-uniblog-publish-prod/images/' +'Search_GSA.2e16d0ba.fill-300x300.png',alt: 'Google Logo',})]app.intent('Default Welcome Intent', conv => {const capability = 'actions.capability.SCREEN_OUTPUT'if (conv.surface.capabilities.has(capability)) {conv.close(...imageResponses)} else {conv.ask(new NewSurface({capabilities: capability,context: 'To show you an image',notification: 'Check out this image',}))}})// Create a Dialogflow intent with the `actions_intent_NEW_SURFACE` eventapp.intent('Get New Surface', (conv, input, newSurface) => {if (newSurface.status === 'OK') {conv.close(...imageResponses)} else {conv.close(`Ok, I understand. You don't want to see pictures. Bye`)}})Modifiers
@public
constructor
constructor(options: NewSurfaceOptions);
Parameter options
NewSurface options
Modifiers
@public
class OpenUrlAction
class OpenUrlAction implements Api.GoogleActionsV2UiElementsOpenUrlAction {}
constructor
constructor(options: OpenUrlActionOptions);
Modifiers
@public
class OrderUpdate
class OrderUpdate implements Api.GoogleActionsV2OrdersOrderUpdate {}
constructor
constructor( options: | Api.GoogleActionsV2OrdersOrderUpdate | Api.GoogleActionsOrdersV3OrderUpdate);
Parameter options
The raw GoogleActionsV2OrdersOrderUpdate or GoogleActionsOrdersV3OrderUpdate if using ordersv3
Modifiers
@public
class Permission
class Permission extends SoloHelper< 'actions.intent.PERMISSION', Api.GoogleActionsV2PermissionValueSpec> {}
Asks the Assistant to guide the user to grant a permission. For example, if you want your app to get access to the user's name, you would invoke
conv.ask(new Permission)
with the context containing the reason for the request, and the GoogleActionsV2PermissionValueSpecPermissions permission. With this, the Assistant will ask the user, in your agent's voice, the following: '[Context with reason for the request], I'll just need to get your name from Google, is that OK?'.Once the user accepts or denies the request, the Assistant will fire another intent:
actions.intent.PERMISSION
with a boolean argument:PERMISSION
and, if granted, the information that you requested.Notes for multiple permissions: * The order in which you specify the permission prompts does not matter - it is controlled by the Assistant to provide a consistent user experience. * The user will be able to either accept all permissions at once, or none. If you wish to allow them to selectively accept one or other, make several dialog turns asking for each permission independently with
conv.ask(new Permission)
. * Asking forDEVICE_COARSE_LOCATION
andDEVICE_PRECISE_LOCATION
at once is equivalent to just asking forDEVICE_PRECISE_LOCATION
Example 1
// Actions SDKconst app = actionssdk()app.intent('actions.intent.MAIN', conv => {conv.ask(new Permission({context: 'To read your mind',permissions: 'NAME',}))})app.intent('actions.intent.PERMISSION', (conv, input, granted) => {// granted: inferred first (and only) argument value, boolean true if granted, false if notconst explicit = conv.arguments.get('PERMISSION') // also retrievable w/ explicit arguments.getconst name = conv.user.name})// Dialogflowconst app = dialogflow()app.intent('Default Welcome Intent', conv => {conv.ask(new Permission({context: 'To read your mind',permissions: 'NAME',}))})// Create a Dialogflow intent with the `actions_intent_PERMISSION` eventapp.intent('Get Permission', (conv, params, granted) => {// granted: inferred first (and only) argument value, boolean true if granted, false if notconst explicit = conv.arguments.get('PERMISSION') // also retrievable w/ explicit arguments.getconst name = conv.user.name})Read more: * Supported Permissions * Check if the permission has been granted with
conv.arguments.get('PERMISSION')
* conv.device.location * conv.user.name * conv.ask(new Place) which also can ask for Location permission to get a placeModifiers
@public
constructor
constructor(options: PermissionOptions);
Parameter options
Permission options
Modifiers
@public
class Place
class Place extends SoloHelper< 'actions.intent.PLACE', Api.GoogleActionsV2PlaceValueSpec> {}
Asks user to provide a geo-located place, possibly using contextual information, like a store near the user's location or a contact's address.
Developer provides custom text prompts to tailor the request handled by Google.
Example 1
// Actions SDKconst app = actionssdk()app.intent('actions.intent.MAIN', conv => {conv.ask(new Place({prompt: 'Where do you want to get picked up?',context: 'To find a place to pick you up',}))})app.intent('actions.intent.PLACE', (conv, input, place, status) => {if (place) {conv.close(`Ah, I see. You want to get picked up at ${place.formattedAddress}`)} else {// Possibly do something with statusconv.close(`Sorry, I couldn't find where you want to get picked up`)}})// Dialogflowconst app = dialogflow()app.intent('Default Welcome Intent', conv => {conv.ask(new Place({prompt: 'Where do you want to get picked up?',context: 'To find a place to pick you up',}))})// Create a Dialogflow intent with the `actions_intent_PLACE` eventapp.intent('Get Place', (conv, params, place, status) => {if (place) {conv.close(`Ah, I see. You want to get picked up at ${place.formattedAddress}`)} else {// Possibly do something with statusconv.close(`Sorry, I couldn't find where you want to get picked up`)}})Modifiers
@public
constructor
constructor(options: PlaceOptions);
Parameter options
Place options
Modifiers
@public
class RegisterUpdate
class RegisterUpdate extends SoloHelper< 'actions.intent.REGISTER_UPDATE', Api.GoogleActionsV2RegisterUpdateValueSpec> {}
Requests the user to register for daily updates.
Example 1
// Actions SDKconst app = actionssdk()app.intent('actions.intent.MAIN', conv => {conv.ask(new RegisterUpdate({frequency: 'DAILY',intent: 'show.image',arguments: [{name: 'image_to_show',textValue: 'image_type_1',}],}))})app.intent('show.image', conv => {const arg = conv.arguments.get('image_to_show') // will be 'image_type_1'// do something with arg})// Dialogflowconst app = dialogflow()app.intent('Default Welcome Intent', conv => {conv.ask(new RegisterUpdate({frequency: 'DAILY',intent: 'Show Image',arguments: [{name: 'image_to_show',textValue: 'image_type_1',}],}))})app.intent('Show Image', conv => {const arg = conv.arguments.get('image_to_show') // will be 'image_type_1'// do something with arg})Modifiers
@public
constructor
constructor(options: RegisterUpdateOptions);
Parameter options
RegisterUpdate options
Modifiers
@public
class RichResponse
class RichResponse implements Api.GoogleActionsV2RichResponse {}
constructor
constructor(options: RichResponseOptions);
Parameter options
RichResponse options
Modifiers
@public
constructor
constructor(items: RichResponseItem[]);
Parameter items
RichResponse items
Modifiers
@public
constructor
constructor(...items: RichResponseItem[]);
Parameter items
RichResponse items
Modifiers
@public
method add
add: (...items: RichResponseItem[]) => this;
Add a RichResponse item
Modifiers
@public
method addSuggestion
addSuggestion: (...suggestions: (string | Suggestions)[]) => this;
Adds a single suggestion or list of suggestions to list of items.
Modifiers
@public
class SignIn
class SignIn extends SoloHelper< 'actions.intent.SIGN_IN', Api.GoogleActionsV2SignInValueSpec> {}
Hands the user off to a web sign in flow. App sign in and OAuth credentials are set in the Actions Console. Retrieve the access token in subsequent intents using conv.user.access.token.
Example 1
// Actions SDKconst app = actionssdk()app.intent('actions.intent.MAIN', conv => {conv.ask(new SignIn())})app.intent('actions.intent.SIGN_IN', (conv, input, signin) => {if (signin.status === 'OK') {const access = conv.user.access.token // possibly do something with access tokenconv.ask('Great, thanks for signing in! What do you want to do next?')} else {conv.ask(`I won't be able to save your data, but what do you want to do next?`)}})// Dialogflowconst app = dialogflow()app.intent('actions.intent.MAIN', conv => {conv.ask(new SignIn())})// Create a Dialogflow intent with the `actions_intent_SIGN_IN` eventapp.intent('Get Signin', (conv, params, signin) => {if (signin.status === 'OK') {const access = conv.user.access.token // possibly do something with access tokenconv.ask('Great, thanks for signing in! What do you want to do next?')} else {conv.ask(`I won't be able to save your data, but what do you want to do next?`)}})Modifiers
@public
constructor
constructor(context?: string);
Parameter context
The optional context why the app needs to ask the user to sign in, as a prefix of a prompt for user consent, e.g. "To track your exercise", or "To check your account balance".
Modifiers
@public
class SimpleResponse
class SimpleResponse implements Api.GoogleActionsV2SimpleResponse {}
constructor
constructor(options: string | SimpleResponseOptions);
Parameter options
SimpleResponse options
Modifiers
@public
class SoloHelper
class SoloHelper<TIntent extends Intent, TValueSpec> extends Helper< TIntent, TValueSpec> {}
Modifiers
@public
class Suggestions
class Suggestions {}
Suggestions to show with response.
Modifiers
@public
constructor
constructor(...suggestions: (string | string[])[]);
Parameter suggestions
Texts of the suggestions.
Modifiers
@public
property suggestions
suggestions: Api.GoogleActionsV2UiElementsSuggestion[];
Modifiers
@public
method add
add: (...suggestions: string[]) => this;
Modifiers
@public
class Table
class Table implements Api.GoogleActionsV2UiElementsTableCard {}
constructor
constructor(options: TableOptions);
Modifiers
@public
class TransactionDecision
class TransactionDecision extends SoloHelper< 'actions.intent.TRANSACTION_DECISION', | Api.GoogleActionsV2TransactionDecisionValueSpec | Api.GoogleActionsTransactionsV3TransactionDecisionValueSpec> {}
Asks user to confirm transaction information.
Modifiers
@public
constructor
constructor( options?: | Api.GoogleActionsV2TransactionDecisionValueSpec | Api.GoogleActionsTransactionsV3TransactionDecisionValueSpec);
Parameter options
The raw GoogleActionsV2TransactionDecisionValueSpec or GoogleActionsTransactionsV3TransactionDecisionValueSpec if using ordersv3
Modifiers
@public
class TransactionRequirements
class TransactionRequirements extends SoloHelper< 'actions.intent.TRANSACTION_REQUIREMENTS_CHECK', | Api.GoogleActionsV2TransactionRequirementsCheckSpec | Api.GoogleActionsTransactionsV3TransactionRequirementsCheckSpec> {}
Checks whether user is in transactable state.
Modifiers
@public
constructor
constructor( options?: | Api.GoogleActionsV2TransactionRequirementsCheckSpec | Api.GoogleActionsTransactionsV3TransactionRequirementsCheckSpec);
Parameter options
The raw GoogleActionsV2TransactionRequirementsCheckSpec or GoogleActionsTransactionsV3TransactionRequirementsCheckSpec if using ordersv3
Modifiers
@public
class UnauthorizedError
class UnauthorizedError extends Error {}
Throw an UnauthorizedError in an intent handler to make the library respond with a HTTP 401 Status Code.
Example 1
const app = dialogflow()// If using Actions SDK:// const app = actionssdk()app.intent('intent', conv => {// ...// given a function to check if a user auth is still validconst valid = checkUserAuthValid(conv)if (!valid) {throw new UnauthorizedError()}// ...})Modifiers
@public
class UpdatePermission
class UpdatePermission extends Permission {}
Prompts the user for permission to send proactive updates at any time.
Example 1
// Actions SDKconst app = actionssdk()app.intent('actions.intent.MAIN', conv => {conv.ask(new UpdatePermission({intent: 'show.image',arguments: [{name: 'image_to_show',textValue: 'image_type_1',}))})app.intent('actions.intent.PERMISSION', conv => {const granted = conv.arguments.get('PERMISSION')if (granted) {conv.close(`Great, I'll send an update whenever I notice a change`)} else {// Response shows that user did not grant permissionconv.close('Alright, just let me know whenever you need the weather!')}})app.intent('show.image', conv => {const arg = conv.arguments.get('image_to_show') // will be 'image_type_1'// do something with arg})// Dialogflowconst app = dialogflow()app.intent('Default Welcome Intent', conv => {conv.ask(new UpdatePermission({intent: 'Show Image',arguments: [{name: 'image_to_show',textValue: 'image_type_1',}))})// Create a Dialogflow intent with the `actions_intent_PERMISSION` eventapp.intent('Get Permission', conv => {const granted = conv.arguments.get('PERMISSION')if (granted) {conv.close(`Great, I'll send an update whenever I notice a change`)} else {// Response shows that user did not grant permissionconv.close('Alright, just let me know whenever you need the weather!')}})app.intent('Show Image', conv => {const arg = conv.arguments.get('image_to_show') // will be 'image_type_1'// do something with arg})Modifiers
@public
constructor
constructor(options: UpdatePermissionOptions);
Parameter options
UpdatePermission options
Modifiers
@public
Interfaces
interface ActionsSdk
interface ActionsSdk {}
Modifiers
@public
call signature
< TConvData, TUserStorage, Conversation extends ActionsSdkConversation< TConvData, TUserStorage > = ActionsSdkConversation<TConvData, TUserStorage>>( options?: ActionsSdkOptions<TConvData, TUserStorage>): AppHandler & ActionsSdkApp<TConvData, TUserStorage, Conversation>;
Modifiers
@public
call signature
< Conversation extends ActionsSdkConversation<{}, {}> = ActionsSdkConversation< {}, {} >>( options?: ActionsSdkOptions<{}, {}>): AppHandler & ActionsSdkApp<{}, {}, Conversation>;
Modifiers
@public
interface ActionsSdkApp
interface ActionsSdkApp< TConvData, TUserStorage, TConversation extends ActionsSdkConversation<TConvData, TUserStorage>> extends ConversationApp<TConvData, TUserStorage> {}
Modifiers
@public
property verification
verification?: ActionsSdkVerification | string;
Modifiers
@public
method catch
catch: (catcher: ExceptionHandler<TUserStorage, TConversation>) => this;
Modifiers
@public
method fallback
fallback: ( handler: | ActionsSdkIntentHandler< TConvData, TUserStorage, TConversation, Argument > | string) => this;
Modifiers
@public
method intent
intent: { <TArgument extends Argument>( intent: Intent | Intent[], handler: | ActionsSdkIntentHandler< TConvData, TUserStorage, TConversation, TArgument > | Intent ): this; <TArgument extends Argument>( intent: string | string[], handler: | string | ActionsSdkIntentHandler< TConvData, TUserStorage, TConversation, TArgument > ): this;};
Sets the IntentHandler to be executed when the fulfillment is called with a given Actions SDK intent.
Parameter intent
The Actions SDK intent to match. When given an array, sets the IntentHandler for any intent in the array.
Parameter handler
The IntentHandler to be executed when the intent is matched. When given a string instead of a function, the intent fulfillment will be redirected to the IntentHandler of the redirected intent.
Modifiers
@public
method middleware
middleware: <TConversationPlugin extends ActionsSdkConversation<{}, {}>>( middleware: ActionsSdkMiddleware<TConversationPlugin>) => this;
Modifiers
@public
interface ActionsSdkConversationOptions
interface ActionsSdkConversationOptions<TConvData, TUserStorage> extends ConversationBaseOptions<TConvData, TUserStorage> {}
Modifiers
@public
property body
body?: Api.GoogleActionsV2AppRequest;
Modifiers
@public
interface ActionsSdkIntentHandler
interface ActionsSdkIntentHandler< TConvData, TUserStorage, TConversation extends ActionsSdkConversation<TConvData, TUserStorage>, TArgument extends Argument> {}
Modifiers
@public
call signature
( conv: TConversation, /** * The user's raw input query. * See {@link Input#raw|Input.raw} * Same as `conv.input.raw` */ input: string, /** * The first argument value from the current intent. * See {@link Arguments#get|Arguments.get} * Same as `conv.arguments.parsed.list[0]` */ argument: TArgument, /** * The first argument status from the current intent. * See {@link Arguments#status|Arguments.status} * Same as `conv.arguments.status.list[0]` */ status: Api.GoogleRpcStatus | undefined): Promise<any> | any;
Modifiers
@public
interface ActionsSdkMiddleware
interface ActionsSdkMiddleware< TConversationPlugin extends ActionsSdkConversation<{}, {}>> {}
Modifiers
@public
call signature
( /** @public */ conv: ActionsSdkConversation<{}, {}>, /** @public */ framework: BuiltinFrameworkMetadata): | (ActionsSdkConversation<{}, {}> & TConversationPlugin) | void | Promise<ActionsSdkConversation<{}, {}> & TConversationPlugin> | Promise<void>;
Modifiers
@public
interface ActionsSdkOptions
interface ActionsSdkOptions<TConvData, TUserStorage> extends ConversationAppOptions<TConvData, TUserStorage> {}
Modifiers
@public
property verification
verification?: ActionsSdkVerification | string;
Validates whether request is from Google through signature verification. Uses Google-Auth-Library to verify authorization token against given Google Cloud Project ID. Auth token is given in request header with key, "authorization".
HTTP Code 403 will be thrown by default on verification error.
Example 1
const app = actionssdk({ verification: 'nodejs-cloud-test-project-1234' })Modifiers
@public
interface AppOptions
interface AppOptions {}
Modifiers
@public
property debug
debug?: boolean;
Modifiers
@public
interface BaseApp
interface BaseApp extends ServiceBaseApp {}
Modifiers
@public
property debug
debug: boolean;
Modifiers
@public
property frameworks
frameworks: BuiltinFrameworks;
Modifiers
@public
method use
use: <TService, TPlugin>(plugin: Plugin<TService, TPlugin>) => this & TPlugin;
Modifiers
@public
interface BasicCard
interface BasicCard extends Api.GoogleActionsV2UiElementsBasicCard {}
Modifiers
@public
interface BasicCardOptions
interface BasicCardOptions {}
Modifiers
@public
property buttons
buttons?: | Api.GoogleActionsV2UiElementsButton | Api.GoogleActionsV2UiElementsButton[];
Modifiers
@public
property display
display?: Api.GoogleActionsV2UiElementsBasicCardImageDisplayOptions;
Modifiers
@public
property image
image?: Api.GoogleActionsV2UiElementsImage;
Modifiers
@public
property subtitle
subtitle?: string;
Modifiers
@public
property text
text?: string;
Modifiers
@public
property title
title?: string;
Modifiers
@public
interface BrowseCarousel
interface BrowseCarousel extends Api.GoogleActionsV2UiElementsCarouselBrowse {}
Class for initializing and constructing Browse Carousel.
Modifiers
@public
interface BrowseCarouselItem
interface BrowseCarouselItem extends Api.GoogleActionsV2UiElementsCarouselBrowseItem {}
Class for initializing and constructing BrowseCarousel Items
Modifiers
@public
interface BrowseCarouselItemOptions
interface BrowseCarouselItemOptions {}
Modifiers
@public
property description
description?: string;
Description text of the item.
Modifiers
@public
property footer
footer?: string;
Footer text of the item.
Modifiers
@public
property image
image?: Api.GoogleActionsV2UiElementsImage;
Image to show on item.
Modifiers
@public
property openUrlAction
openUrlAction?: Api.GoogleActionsV2UiElementsOpenUrlAction;
The URL action that occurs by clicking the BrowseCarouselItem. You should either set this field or
url
but not both.Modifiers
@public
property title
title: string;
Title of the option item.
Modifiers
@public
property url
url?: string;
The URL of the link opened by clicking the BrowseCarouselItem. You should either set this field or
openUrlAction
but not both.Modifiers
@public
interface BrowseCarouselOptions
interface BrowseCarouselOptions {}
Modifiers
@public
interface Button
interface Button extends Api.GoogleActionsV2UiElementsButton {}
Card Button. Shown below cards. Open a URL when selected.
Modifiers
@public
interface ButtonOptions
interface ButtonOptions {}
Modifiers
@public
property action
action?: Api.GoogleActionsV2UiElementsOpenUrlAction;
Action to take when selected. Recommended to use the url property for simple web page url open.
Modifiers
@public
property title
title: string;
Text shown on the button.
Modifiers
@public
property url
url?: string;
String URL to open.
Modifiers
@public
interface CarouselOptionItem
interface CarouselOptionItem extends OptionItem {}
Modifiers
@public
property description
description: string;
Description text of the item.
Modifiers
@public
interface CarouselOptions
interface CarouselOptions {}
Modifiers
@public
property display
display?: Api.GoogleActionsV2UiElementsCarouselSelectImageDisplayOptions;
Sets the display options for the images in this carousel.
Modifiers
@public
property items
items: | OptionItems<CarouselOptionItem> | Api.GoogleActionsV2UiElementsCarouselSelectCarouselItem[];
List of 2-20 items to show in this carousel. Required.
Modifiers
@public
interface Context
interface Context<TParameters extends Parameters> extends OutputContext<TParameters> {}
Modifiers
@public
property lifespan
lifespan: number;
Remaining number of intents
Modifiers
@public
property name
name: string;
Full name of the context.
Modifiers
@public
property parameters
parameters: TParameters;
The context parameters from the current intent. Context parameters include parameters collected in previous intents during the lifespan of the given context.
See here.
Example 1
app.intent('Tell Greeting', conv => {const context1 = conv.contexts.get('context1')const parameters = context1.parametersconst color = parameters.colorconst num = parameters.num})// Using destructuringapp.intent('Tell Greeting', conv => {const context1 = conv.contexts.get('context1')const { color, num } = context1.parameters})Modifiers
@public
interface Contexts
interface Contexts {}
Modifiers
@public
index signature
[context: string]: Context<Parameters> | undefined;
Modifiers
@public
interface DateTimeOptions
interface DateTimeOptions {}
Modifiers
@public
property prompts
prompts?: DateTimeOptionsPrompts;
Prompts for the user
Modifiers
@public
interface Dialogflow
interface Dialogflow {}
Modifiers
@public
call signature
< TConvData, TUserStorage, TContexts extends Contexts = Contexts, Conversation extends DialogflowConversation< TConvData, TUserStorage, TContexts > = DialogflowConversation<TConvData, TUserStorage, TContexts>>( options?: DialogflowOptions<TConvData, TUserStorage>): AppHandler & DialogflowApp<TConvData, TUserStorage, TContexts, Conversation>;
Modifiers
@public
call signature
< TContexts extends Contexts, Conversation extends DialogflowConversation< {}, {}, TContexts > = DialogflowConversation<{}, {}, TContexts>>( options?: DialogflowOptions<{}, {}>): AppHandler & DialogflowApp<{}, {}, TContexts, Conversation>;
Modifiers
@public
call signature
< TConversation extends DialogflowConversation< {}, {} > = DialogflowConversation<{}, {}>>( options?: DialogflowOptions<{}, {}>): AppHandler & DialogflowApp<{}, {}, Contexts, TConversation>;
Modifiers
@public
interface DialogflowApp
interface DialogflowApp< TConvData, TUserStorage, TContexts extends Contexts, TConversation extends DialogflowConversation<TConvData, TUserStorage, TContexts>> extends ConversationApp<TConvData, TUserStorage> {}
Modifiers
@public
property verification
verification?: DialogflowVerification | DialogflowVerificationHeaders;
Modifiers
@public
method catch
catch: (catcher: ExceptionHandler<TUserStorage, TConversation>) => this;
Modifiers
@public
method fallback
fallback: ( handler: | DialogflowIntentHandler< TConvData, TUserStorage, TContexts, TConversation, Parameters, Argument > | string) => this;
Modifiers
@public
method intent
intent: { <TParameters extends Parameters>( intent: DefaultDialogflowIntent | DefaultDialogflowIntent[], handler: | DialogflowIntentHandler< TConvData, TUserStorage, TContexts, TConversation, TParameters, Argument > | string ): this; <TArgument extends Argument>( intent: DefaultDialogflowIntent | DefaultDialogflowIntent[], handler: | string | DialogflowIntentHandler< TConvData, TUserStorage, TContexts, TConversation, Parameters, TArgument > ): this; <TParameters extends Parameters, TArgument extends Argument>( intent: DefaultDialogflowIntent | DefaultDialogflowIntent[], handler: | string | DialogflowIntentHandler< TConvData, TUserStorage, TContexts, TConversation, TParameters, TArgument > ): this; <TParameters extends Parameters>( intent: string | string[], handler: | string | DialogflowIntentHandler< TConvData, TUserStorage, TContexts, TConversation, TParameters, Argument > ): this; <TArgument extends Argument>( intent: string | string[], handler: | string | DialogflowIntentHandler< TConvData, TUserStorage, TContexts, TConversation, Parameters, TArgument > ): this; <TParameters extends Parameters, TArgument extends Argument>( intent: string | string[], handler: | string | DialogflowIntentHandler< TConvData, TUserStorage, TContexts, TConversation, TParameters, TArgument > ): this;};
Sets the IntentHandler to be execute when the fulfillment is called with a given Dialogflow intent name.
Parameter intent
The Dialogflow intent name to match. When given an array, sets the IntentHandler for any intent name in the array.
Parameter handler
The IntentHandler to be executed when the intent name is matched. When given a string instead of a function, the intent fulfillment will be redirected to the IntentHandler of the redirected intent name.
Modifiers
@public
method middleware
middleware: < TConversationPlugin extends DialogflowConversation<{}, {}, Contexts>>( middleware: DialogflowMiddleware<TConversationPlugin>) => this;
Modifiers
@public
interface DialogflowConversationOptions
interface DialogflowConversationOptions<TConvData, TUserStorage> extends ConversationBaseOptions<TConvData, TUserStorage> {}
Modifiers
@public
property body
body?: | Api.GoogleCloudDialogflowV2WebhookRequest | ApiV1.DialogflowV1WebhookRequest;
Modifiers
@public
interface DialogflowIntentHandler
interface DialogflowIntentHandler< TConvData, TUserStorage, TContexts extends Contexts, TConversation extends DialogflowConversation<TConvData, TUserStorage, TContexts>, TParameters extends Parameters, TArgument extends Argument> {}
Modifiers
@public
call signature
( conv: TConversation, params: TParameters, /** * The first argument value from the current intent. * See {@link Arguments#get|Arguments.get} * Same as `conv.arguments.parsed.list[0]` */ argument: TArgument, /** * The first argument status from the current intent. * See {@link Arguments#status|Arguments.status} * Same as `conv.arguments.status.list[0]` */ status: ActionsApi.GoogleRpcStatus | undefined): Promise<any> | any;
Modifiers
@public
interface DialogflowMiddleware
interface DialogflowMiddleware<TConversationPlugin extends DialogflowConversation> {}
Modifiers
@public
call signature
( /** @public */ conv: DialogflowConversation, /** @public */ framework: BuiltinFrameworkMetadata): | (DialogflowConversation & TConversationPlugin) | void | Promise<DialogflowConversation & TConversationPlugin> | Promise<void>;
interface DialogflowOptions
interface DialogflowOptions<TConvData, TUserStorage> extends ConversationAppOptions<TConvData, TUserStorage> {}
Modifiers
@public
property verification
verification?: DialogflowVerification | DialogflowVerificationHeaders;
Verifies whether the request comes from Dialogflow. Uses header keys and values to check against ones specified by the developer in the Dialogflow Fulfillment settings of the app.
HTTP Code 403 will be thrown by default on verification error.
Modifiers
@public
interface DialogflowV1BaseGoogleMessage
interface DialogflowV1BaseGoogleMessage<TType extends string> {}
interface DialogflowV1BaseMessage
interface DialogflowV1BaseMessage<TType extends number> {}
interface DialogflowV1Button
interface DialogflowV1Button {}
interface DialogflowV1Context
interface DialogflowV1Context {}
property lifespan
lifespan?: number;
property name
name?: string;
property parameters
parameters?: DialogflowV1Parameters;
interface DialogflowV1FollowupEvent
interface DialogflowV1FollowupEvent {}
interface DialogflowV1Fulfillment
interface DialogflowV1Fulfillment {}
interface DialogflowV1MessageBasicCard
interface DialogflowV1MessageBasicCard extends DialogflowV1BaseGoogleMessage<'basic_card'> {}
property buttons
buttons?: DialogflowV1MessageBasicCardButton[];
property formattedText
formattedText?: string;
property image
image?: DialogflowV1MessageImage;
property subtitle
subtitle?: string;
property title
title?: string;
interface DialogflowV1MessageBasicCardButton
interface DialogflowV1MessageBasicCardButton {}
property openUrlAction
openUrlAction?: DialogflowV1MessageBasicCardButtonAction;
property title
title?: string;
interface DialogflowV1MessageBasicCardButtonAction
interface DialogflowV1MessageBasicCardButtonAction {}
property url
url?: string;
interface DialogflowV1MessageCard
interface DialogflowV1MessageCard extends DialogflowV1BaseMessage<1> {}
interface DialogflowV1MessageCarousel
interface DialogflowV1MessageCarousel extends DialogflowV1BaseGoogleMessage<'carousel_card'> {}
property items
items?: DialogflowV1MessageOptionItem[];
interface DialogflowV1MessageCustomPayload
interface DialogflowV1MessageCustomPayload extends DialogflowV1BaseMessage<4> {}
property payload
payload?: JsonObject;
interface DialogflowV1MessageGooglePayload
interface DialogflowV1MessageGooglePayload extends DialogflowV1BaseGoogleMessage<'custom_payload'> {}
property payload
payload?: ApiClientObjectMap<any>;
interface DialogflowV1MessageImage
interface DialogflowV1MessageImage extends DialogflowV1BaseMessage<3> {}
property imageUrl
imageUrl?: string;
interface DialogflowV1MessageImage
interface DialogflowV1MessageImage {}
property url
url?: string;
interface DialogflowV1MessageLinkOut
interface DialogflowV1MessageLinkOut extends DialogflowV1BaseGoogleMessage<'link_out_chip'> {}
property destinationName
destinationName?: string;
property url
url?: string;