UNPKG

5.74 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 { ApiClientObjectMap, JsonObject } from '../../../common';
17import * as ActionsApi from '../../actionssdk/api/v2';
18export interface DialogflowV1OriginalRequest {
19 source?: string;
20 version?: string;
21 data?: ActionsApi.GoogleActionsV2AppRequest;
22}
23export interface DialogflowV1Parameters {
24 [parameter: string]: string | Object | undefined;
25}
26export interface DialogflowV1Context {
27 name?: string;
28 parameters?: DialogflowV1Parameters;
29 lifespan?: number;
30}
31export interface DialogflowV1Metadata {
32 intentId?: string;
33 webhookUsed?: string;
34 webhookForSlotFillingUsed?: string;
35 nluResponseTime?: number;
36 intentName?: string;
37}
38export interface DialogflowV1Button {
39 text?: string;
40 postback?: string;
41}
42export interface DialogflowV1BaseMessage<TType extends number> {
43 platform?: 'facebook' | 'kik' | 'line' | 'skype' | 'slack' | 'telegram' | 'viber';
44 type?: TType;
45}
46export interface DialogflowV1MessageText extends DialogflowV1BaseMessage<0> {
47 speech?: string;
48}
49export interface DialogflowV1MessageImage extends DialogflowV1BaseMessage<3> {
50 imageUrl?: string;
51}
52export interface DialogflowV1MessageCard extends DialogflowV1BaseMessage<1> {
53 buttons?: DialogflowV1Button[];
54 imageUrl?: string;
55 subtitle?: string;
56 title?: string;
57}
58export interface DialogflowV1MessageQuickReplies extends DialogflowV1BaseMessage<2> {
59 replies?: string[];
60 title?: string;
61}
62export interface DialogflowV1MessageCustomPayload extends DialogflowV1BaseMessage<4> {
63 payload?: JsonObject;
64}
65export interface DialogflowV1BaseGoogleMessage<TType extends string> {
66 platform: 'google';
67 type?: TType;
68}
69export interface DialogflowV1MessageSimpleResponse extends DialogflowV1BaseGoogleMessage<'simple_response'> {
70 displayText?: string;
71 textToSpeech?: string;
72}
73export interface DialogflowV1MessageBasicCardButtonAction {
74 url?: string;
75}
76export interface DialogflowV1MessageBasicCardButton {
77 openUrlAction?: DialogflowV1MessageBasicCardButtonAction;
78 title?: string;
79}
80export interface DialogflowV1MessageImage {
81 url?: string;
82}
83export interface DialogflowV1MessageBasicCard extends DialogflowV1BaseGoogleMessage<'basic_card'> {
84 buttons?: DialogflowV1MessageBasicCardButton[];
85 formattedText?: string;
86 image?: DialogflowV1MessageImage;
87 subtitle?: string;
88 title?: string;
89}
90export interface DialogflowV1MessageOptionInfo {
91 key?: string;
92 synonyms?: string[];
93}
94export interface DialogflowV1MessageOptionItem {
95 description?: string;
96 image?: DialogflowV1MessageImage;
97 optionInfo?: DialogflowV1MessageOptionInfo;
98 title?: string;
99}
100export interface DialogflowV1MessageList extends DialogflowV1BaseGoogleMessage<'list_card'> {
101 items?: DialogflowV1MessageOptionItem[];
102 title?: string;
103}
104export interface DialogflowV1MessageSuggestion {
105 title?: string;
106}
107export interface DialogflowV1MessageSuggestions extends DialogflowV1BaseGoogleMessage<'suggestion_chips'> {
108 suggestions?: DialogflowV1MessageSuggestion[];
109}
110export interface DialogflowV1MessageCarousel extends DialogflowV1BaseGoogleMessage<'carousel_card'> {
111 items?: DialogflowV1MessageOptionItem[];
112}
113export interface DialogflowV1MessageLinkOut extends DialogflowV1BaseGoogleMessage<'link_out_chip'> {
114 destinationName?: string;
115 url?: string;
116}
117export interface DialogflowV1MessageGooglePayload extends DialogflowV1BaseGoogleMessage<'custom_payload'> {
118 payload?: ApiClientObjectMap<any>;
119}
120export declare type DialogflowV1Message = DialogflowV1MessageText | DialogflowV1MessageImage | DialogflowV1MessageCard | DialogflowV1MessageQuickReplies | DialogflowV1MessageCustomPayload | DialogflowV1MessageSimpleResponse | DialogflowV1MessageBasicCard | DialogflowV1MessageList | DialogflowV1MessageSuggestions | DialogflowV1MessageCarousel | DialogflowV1MessageLinkOut | DialogflowV1MessageGooglePayload;
121export interface DialogflowV1Fulfillment {
122 speech?: string;
123 messages?: DialogflowV1Message[];
124}
125export interface DialogflowV1Result {
126 source?: string;
127 resolvedQuery?: string;
128 speech?: string;
129 action?: string;
130 actionIncomplete?: boolean;
131 parameters?: DialogflowV1Parameters;
132 contexts?: DialogflowV1Context[];
133 metadata?: DialogflowV1Metadata;
134 fulfillment?: DialogflowV1Fulfillment;
135 score?: number;
136}
137export interface DialogflowV1Status {
138 code?: number;
139 errorType?: string;
140 webhookTimedOut?: boolean;
141}
142export interface DialogflowV1WebhookRequest {
143 originalRequest?: DialogflowV1OriginalRequest;
144 id?: string;
145 sessionId?: string;
146 timestamp?: string;
147 timezone?: string;
148 lang?: string;
149 result?: DialogflowV1Result;
150 status?: DialogflowV1Status;
151}
152export interface DialogflowV1FollowupEvent {
153 name?: string;
154 data?: DialogflowV1Parameters;
155}
156export interface DialogflowV1WebhookResponse {
157 speech?: string;
158 displayText?: string;
159 messages?: DialogflowV1Message[];
160 data?: ApiClientObjectMap<any>;
161 contextOut?: DialogflowV1Context[];
162 source?: string;
163 followupEvent?: DialogflowV1FollowupEvent;
164}