From acfc85a1795b0ea0e63a675351762c9c4da14696 Mon Sep 17 00:00:00 2001 From: Dheeraj1998 Date: Fri, 26 Feb 2021 15:39:43 +0530 Subject: [PATCH 1/2] Update Lex event to include confidence score and alternative intents --- events/lex.go | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/events/lex.go b/events/lex.go index dd635fbd..1c03616f 100644 --- a/events/lex.go +++ b/events/lex.go @@ -1,16 +1,17 @@ package events type LexEvent struct { - MessageVersion string `json:"messageVersion,omitempty"` - InvocationSource string `json:"invocationSource,omitempty"` - UserID string `json:"userId,omitempty"` - InputTranscript string `json:"inputTranscript,omitempty"` - SessionAttributes SessionAttributes `json:"sessionAttributes,omitempty"` - RequestAttributes map[string]string `json:"requestAttributes,omitempty"` - Bot *LexBot `json:"bot,omitempty"` - OutputDialogMode string `json:"outputDialogMode,omitempty"` - CurrentIntent *LexCurrentIntent `json:"currentIntent,omitempty"` - DialogAction *LexDialogAction `json:"dialogAction,omitempty"` + MessageVersion string `json:"messageVersion,omitempty"` + InvocationSource string `json:"invocationSource,omitempty"` + UserID string `json:"userId,omitempty"` + InputTranscript string `json:"inputTranscript,omitempty"` + SessionAttributes SessionAttributes `json:"sessionAttributes,omitempty"` + RequestAttributes map[string]string `json:"requestAttributes,omitempty"` + Bot *LexBot `json:"bot,omitempty"` + OutputDialogMode string `json:"outputDialogMode,omitempty"` + CurrentIntent *LexCurrentIntent `json:"currentIntent,omitempty"` + AlternativeIntent *LexAlternativeIntent `json:"alternativeIntent,omitempty"` + DialogAction *LexDialogAction `json:"dialogAction,omitempty"` } type LexBot struct { @@ -20,10 +21,19 @@ type LexBot struct { } type LexCurrentIntent struct { - Name string `json:"name,omitempty"` - Slots Slots `json:"slots,omitempty"` - SlotDetails map[string]SlotDetail `json:"slotDetails,omitempty"` - ConfirmationStatus string `json:"confirmationStatus,omitempty"` + Name string `json:"name,omitempty"` + NLUIntentConfidenceScore float64 `json:"nluIntentConfidenceScore,omitempty"` + Slots Slots `json:"slots,omitempty"` + SlotDetails map[string]SlotDetail `json:"slotDetails,omitempty"` + ConfirmationStatus string `json:"confirmationStatus,omitempty"` +} + +type LexAlternativeIntent struct { + Name string `json:"name,omitempty"` + NLUIntentConfidenceScore float64 `json:"nluIntentConfidenceScore,omitempty"` + Slots Slots `json:"slots,omitempty"` + SlotDetails map[string]SlotDetail `json:"slotDetails,omitempty"` + ConfirmationStatus string `json:"confirmationStatus,omitempty"` } type SlotDetail struct { From c800be69518f0477fcf0d37327a2d2b9d09411bb Mon Sep 17 00:00:00 2001 From: Dheeraj1998 Date: Mon, 1 Mar 2021 12:25:33 +0530 Subject: [PATCH 2/2] Fix Lex event to allow Alternative Intents array --- events/lex.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/events/lex.go b/events/lex.go index 1c03616f..62b1e6d6 100644 --- a/events/lex.go +++ b/events/lex.go @@ -1,17 +1,17 @@ package events type LexEvent struct { - MessageVersion string `json:"messageVersion,omitempty"` - InvocationSource string `json:"invocationSource,omitempty"` - UserID string `json:"userId,omitempty"` - InputTranscript string `json:"inputTranscript,omitempty"` - SessionAttributes SessionAttributes `json:"sessionAttributes,omitempty"` - RequestAttributes map[string]string `json:"requestAttributes,omitempty"` - Bot *LexBot `json:"bot,omitempty"` - OutputDialogMode string `json:"outputDialogMode,omitempty"` - CurrentIntent *LexCurrentIntent `json:"currentIntent,omitempty"` - AlternativeIntent *LexAlternativeIntent `json:"alternativeIntent,omitempty"` - DialogAction *LexDialogAction `json:"dialogAction,omitempty"` + MessageVersion string `json:"messageVersion,omitempty"` + InvocationSource string `json:"invocationSource,omitempty"` + UserID string `json:"userId,omitempty"` + InputTranscript string `json:"inputTranscript,omitempty"` + SessionAttributes SessionAttributes `json:"sessionAttributes,omitempty"` + RequestAttributes map[string]string `json:"requestAttributes,omitempty"` + Bot *LexBot `json:"bot,omitempty"` + OutputDialogMode string `json:"outputDialogMode,omitempty"` + CurrentIntent *LexCurrentIntent `json:"currentIntent,omitempty"` + AlternativeIntents []LexAlternativeIntents `json:"alternativeIntents,omitempty"` + DialogAction *LexDialogAction `json:"dialogAction,omitempty"` } type LexBot struct { @@ -28,7 +28,7 @@ type LexCurrentIntent struct { ConfirmationStatus string `json:"confirmationStatus,omitempty"` } -type LexAlternativeIntent struct { +type LexAlternativeIntents struct { Name string `json:"name,omitempty"` NLUIntentConfidenceScore float64 `json:"nluIntentConfidenceScore,omitempty"` Slots Slots `json:"slots,omitempty"`