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