1 | import { Callback, Handler } from "../handler";
|
2 |
|
3 | export type LexHandler = Handler<LexEvent, LexResult>;
|
4 | export type LexCallback = Callback<LexResult>;
|
5 |
|
6 |
|
7 |
|
8 | export interface LexEvent {
|
9 | currentIntent: {
|
10 | name: string;
|
11 | slots: { [name: string]: string | null };
|
12 | slotDetails: LexSlotDetails;
|
13 | confirmationStatus: 'None' | 'Confirmed' | 'Denied';
|
14 | };
|
15 | bot: {
|
16 | name: string;
|
17 | alias: string;
|
18 | version: string;
|
19 | };
|
20 | userId: string;
|
21 | inputTranscript: string;
|
22 | invocationSource: 'DialogCodeHook' | 'FulfillmentCodeHook';
|
23 | outputDialogMode: 'Text' | 'Voice';
|
24 | messageVersion: '1.0';
|
25 | sessionAttributes: { [key: string]: string };
|
26 | requestAttributes: { [key: string]: string } | null;
|
27 | }
|
28 |
|
29 | export interface LexSlotResolution {
|
30 | value: string;
|
31 | }
|
32 |
|
33 | export interface LexSlotDetails {
|
34 | [name: string]: {
|
35 |
|
36 |
|
37 | resolutions: LexSlotResolution[];
|
38 | originalValue: string;
|
39 | };
|
40 | }
|
41 |
|
42 | export interface LexGenericAttachment {
|
43 | title: string;
|
44 | subTitle: string;
|
45 | imageUrl: string;
|
46 | attachmentLinkUrl: string;
|
47 | buttons: Array<{
|
48 | text: string;
|
49 | value: string;
|
50 | }>;
|
51 | }
|
52 |
|
53 | export interface LexDialogActionBase {
|
54 | type: 'Close' | 'ElicitIntent' | 'ElicitSlot' | 'ConfirmIntent';
|
55 | message?: {
|
56 | contentType: 'PlainText' | 'SSML' | 'CustomPayload';
|
57 | content: string;
|
58 | };
|
59 | responseCard?: {
|
60 | version: number;
|
61 | contentType: 'application/vnd.amazonaws.card.generic';
|
62 | genericAttachments: LexGenericAttachment[];
|
63 | };
|
64 | }
|
65 |
|
66 | export interface LexDialogActionClose extends LexDialogActionBase {
|
67 | type: 'Close';
|
68 | fulfillmentState: 'Fulfilled' | 'Failed';
|
69 | }
|
70 |
|
71 | export interface LexDialogActionElicitIntent extends LexDialogActionBase {
|
72 | type: 'ElicitIntent';
|
73 | }
|
74 |
|
75 | export interface LexDialogActionElicitSlot extends LexDialogActionBase {
|
76 | type: 'ElicitSlot';
|
77 | intentName: string;
|
78 | slots: { [name: string]: string | null };
|
79 | slotToElicit: string;
|
80 | }
|
81 |
|
82 | export interface LexDialogActionConfirmIntent extends LexDialogActionBase {
|
83 | type: 'ConfirmIntent';
|
84 | intentName: string;
|
85 | slots: { [name: string]: string | null };
|
86 | }
|
87 |
|
88 | export interface LexDialogActionDelegate {
|
89 | type: 'Delegate';
|
90 | slots: { [name: string]: string | null };
|
91 | }
|
92 |
|
93 | export type LexDialogAction =
|
94 | | LexDialogActionClose
|
95 | | LexDialogActionElicitIntent
|
96 | | LexDialogActionElicitSlot
|
97 | | LexDialogActionConfirmIntent
|
98 | | LexDialogActionDelegate;
|
99 |
|
100 | export interface LexResult {
|
101 | sessionAttributes?: { [key: string]: string };
|
102 | dialogAction: LexDialogAction;
|
103 | }
|