1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | import * as Api from './api/v2';
|
17 | import * as ApiV1 from './api/v1';
|
18 |
|
19 | export interface Parameters {
|
20 |
|
21 | [parameter: string]: string | Object | undefined;
|
22 | }
|
23 |
|
24 | export interface Contexts {
|
25 |
|
26 | [context: string]: Context<Parameters> | undefined;
|
27 | }
|
28 |
|
29 | export interface OutputContexts {
|
30 |
|
31 | [context: string]: OutputContext<Parameters> | undefined;
|
32 | }
|
33 |
|
34 | export interface Context<TParameters extends Parameters> extends OutputContext<TParameters> {
|
35 | |
36 |
|
37 |
|
38 |
|
39 | name: string;
|
40 | |
41 |
|
42 |
|
43 |
|
44 | lifespan: number;
|
45 | |
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 | parameters: TParameters;
|
73 | }
|
74 |
|
75 | export interface OutputContext<TParameters extends Parameters> {
|
76 |
|
77 | lifespan: number;
|
78 |
|
79 | parameters?: TParameters;
|
80 | }
|
81 | export declare class ContextValues<TContexts extends Contexts> {
|
82 | private _session?;
|
83 |
|
84 | input: TContexts;
|
85 |
|
86 | output: OutputContexts;
|
87 |
|
88 | constructor(outputContexts?: Api.GoogleCloudDialogflowV2Context[] | ApiV1.DialogflowV1Context[], _session?: string);
|
89 | /** @hidden */
|
90 | _serialize(): Api.GoogleCloudDialogflowV2Context[];
|
91 | /** @hidden */
|
92 | _serializeV1(): ApiV1.DialogflowV1Context[];
|
93 | /**
|
94 | * Returns the incoming context by name for this intent.
|
95 | *
|
96 | * @example
|
97 | * ```javascript
|
98 | *
|
99 | * const AppContexts = {
|
100 | * NUMBER: 'number',
|
101 | * }
|
102 | *
|
103 | * const app = dialogflow()
|
104 | *
|
105 | * app.intent('Default Welcome Intent', conv => {
|
106 | * conv.contexts.set(AppContexts.NUMBER, 1)
|
107 | * conv.ask('Welcome to action snippets! Say a number.')
|
108 | * })
|
109 | *
|
110 | *
|
111 | * app.intent('Number Input', conv => {
|
112 | * const context = conv.contexts.get(AppContexts.NUMBER)
|
113 | * })
|
114 | * ```
|
115 | *
|
116 | * @param name The name of the Context to retrieve.
|
117 | * @return Context value matching name or undefined if no matching context.
|
118 | * @public
|
119 | */
|
120 | get(name: keyof TContexts): TContexts[keyof TContexts];
|
121 | /**
|
122 | * Set a new context for the current intent.
|
123 | *
|
124 | * @example
|
125 | * ```javascript
|
126 | *
|
127 | * const AppContexts = {
|
128 | * NUMBER: 'number',
|
129 | * }
|
130 | *
|
131 | * const app = dialogflow()
|
132 | *
|
133 | * app.intent('Default Welcome Intent', conv => {
|
134 | * conv.contexts.set(AppContexts.NUMBER, 1)
|
135 | * conv.ask('Welcome to action snippets! Say a number.')
|
136 | * })
|
137 | *
|
138 | *
|
139 | * app.intent('Number Input', conv => {
|
140 | * const context = conv.contexts.get(AppContexts.NUMBER)
|
141 | * })
|
142 | * ```
|
143 | *
|
144 | * @param name Name of the context. Dialogflow converts to lowercase.
|
145 | * @param lifespan Context lifespan.
|
146 | * @param parameters Context parameters.
|
147 | * @public
|
148 | */
|
149 | set(name: string, lifespan: number, parameters?: Parameters): void;
|
150 | /** @public */
|
151 | delete(name: string): void;
|
152 | /**
|
153 | * Returns the incoming contexts for this intent as an iterator.
|
154 | *
|
155 | * @example
|
156 | * ```javascript
|
157 | *
|
158 | * const AppContexts = {
|
159 | * NUMBER: 'number',
|
160 | * }
|
161 | *
|
162 | * const app = dialogflow()
|
163 | *
|
164 | * app.intent('Default Welcome Intent', conv => {
|
165 | * conv.contexts.set(AppContexts.NUMBER, 1)
|
166 | * conv.ask('Welcome to action snippets! Say a number.')
|
167 | * })
|
168 | *
|
169 | *
|
170 | * app.intent('Number Input', conv => {
|
171 | * for (const context of conv.contexts) {
|
172 | *
|
173 | * }
|
174 | * })
|
175 | * ```
|
176 | *
|
177 | * @public
|
178 | */
|
179 | [Symbol.iterator](): IterableIterator<Context<Parameters>>;
|
180 | }
|
181 |
|
\ | No newline at end of file |