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 | import { Image, Suggestions, BasicCard, SimpleResponse, LinkOutSuggestion, List, Carousel } from '../actionssdk';
|
19 | import { JsonObject } from '../../common';
|
20 | export declare type IncomingMessage = string | Image | Suggestions | BasicCard | SimpleResponse | LinkOutSuggestion | List | Carousel | JsonObject;
|
21 | export declare class Incoming {
|
22 |
|
23 | parsed: IncomingMessage[];
|
24 |
|
25 | constructor(fulfillment: Api.GoogleCloudDialogflowV2IntentMessage[] | ApiV1.DialogflowV1Fulfillment | undefined);
|
26 | /**
|
27 | * Gets the first Dialogflow incoming message with the given type.
|
28 | * Messages are converted into client library class instances or a string.
|
29 | *
|
30 | * Only messages with the platform field unlabeled (for generic use)
|
31 | * or labeled `ACTIONS_ON_GOOGLE` (`google` in v1) will be converted and read.
|
32 | *
|
33 | * The conversation is detailed below for a specific message oneof:
|
34 | * * Generic Platform Response
|
35 | * * `text` -> `typeof string`
|
36 | * * `image` -> `Image`
|
37 | * * `quickReplies` -> `Suggestions`
|
38 | * * `card` -> `BasicCard`
|
39 | * * Actions on Google Response
|
40 | * * `simpleResponses` -> `SimpleResponse[]`
|
41 | * * `basicCard` -> `BasicCard`
|
42 | * * `suggestions` -> `Suggestions`
|
43 | * * `linkOutSuggestion` -> `LinkOutSuggestion`
|
44 | * * `listSelect` -> `List`
|
45 | * * `carouselSelect` -> `Carousel`
|
46 | * * `payload` -> `typeof object`
|
47 | *
|
48 | * Dialogflow v1:
|
49 | * * Generic Platform Response
|
50 | * * `0` (text) -> `typeof string`
|
51 | * * `3` (image) -> `Image`
|
52 | * * `1` (card) -> `BasicCard`
|
53 | * * `2` (quick replies) -> `Suggestions`
|
54 | * * `4` (custom payload) -> `typeof object`
|
55 | * * Actions on Google Response
|
56 | * * `simple_response` -> `SimpleResponse`
|
57 | * * `basic_card` -> `BasicCard`
|
58 | * * `list_card` -> `List`
|
59 | * * `suggestion_chips` -> `Suggestions`
|
60 | * * `carousel_card` -> `Carousel`
|
61 | * * `link_out_chip` -> `LinkOutSuggestion`
|
62 | * * `custom_payload` -> `typeof object`
|
63 | *
|
64 | * @example
|
65 | * ```javascript
|
66 | *
|
67 | * // Dialogflow
|
68 | * const { dialogflow, BasicCard } = require('actions-on-google')
|
69 | *
|
70 | * const app = dialogflow()
|
71 | *
|
72 | *
|
73 | * app.intent('Default Welcome Intent', conv => {
|
74 | * const str = conv.incoming.get('string')
|
75 | * const card = conv.incoming.get(BasicCard)
|
76 | *
|
77 | * })
|
78 | * ```
|
79 | *
|
80 | * @param type A string checking for the typeof message or a class checking for instanceof message
|
81 | * @public
|
82 | */
|
83 | get<TMessage extends IncomingMessage>(type: new (...args: any[]) => TMessage): TMessage;
|
84 | /** @public */
|
85 | get(type: 'string'): string;
|
86 | /**
|
87 | * Gets the Dialogflow incoming messages as an iterator.
|
88 | * Messages are converted into client library class instances or a string.
|
89 | * See {@link Incoming#get|conv.incoming.get} for details on how the conversion works.
|
90 | *
|
91 | * @example
|
92 | * ```javascript
|
93 | *
|
94 | *
|
95 | * const app = dialogflow()
|
96 | *
|
97 | *
|
98 | * app.intent('Default Welcome Intent', conv => {
|
99 | * const messages = [...conv.incoming]
|
100 | *
|
101 | *
|
102 | * conv.ask(`Here's what was set in the Dialogflow console`)
|
103 | * conv.ask(...conv.incoming)
|
104 | * }
|
105 | * ```
|
106 | *
|
107 | * @public
|
108 | */
|
109 | [Symbol.iterator](): IterableIterator<IncomingMessage>;
|
110 | }
|
111 |
|
\ | No newline at end of file |