Skip to content

Commit 044197f

Browse files
turhnbmoffatt
authored andcommitted
Add AWS Lex event example (#170)
1 parent 7522090 commit 044197f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

events/README_Lex.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
# Sample Function
3+
4+
The following is a sample class and Lambda function that receives Amazon Lex event data as input, writes some of the record data to CloudWatch Logs, and responds back to Lex. (Note that by default anything written to Console will be logged as CloudWatch Logs events.)
5+
6+
```go
7+
import (
8+
"context"
9+
"fmt"
10+
11+
"github.com/aws/aws-lambda-go/events"
12+
)
13+
14+
func Handler(ctx context.Context, event events.LexEvent) (*lex.LexResponse, error) {
15+
fmt.Printf("Received an input from Amazon Lex. Current Intent: %s", event.CurrentIntent.Name)
16+
17+
messageContent := "Hello from AWS Lambda!"
18+
19+
return &LexResponse{
20+
SessionAttributes: event.SessionAttributes,
21+
DialogAction: events.LexDialogAction{
22+
Type: "Close",
23+
Message: map[string]string{
24+
"content": messageContent,
25+
"contentType": "PlainText",
26+
},
27+
FulfillmentState: "Fulfilled",
28+
},
29+
}, nil
30+
}
31+
```

0 commit comments

Comments
 (0)