Skip to content

Commit

Permalink
Add AWS Lex event example (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
turhn authored and bmoffatt committed Feb 20, 2019
1 parent 7522090 commit 044197f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions events/README_Lex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

# Sample Function

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.)

```go
import (
"context"
"fmt"

"github.com/aws/aws-lambda-go/events"
)

func Handler(ctx context.Context, event events.LexEvent) (*lex.LexResponse, error) {
fmt.Printf("Received an input from Amazon Lex. Current Intent: %s", event.CurrentIntent.Name)

messageContent := "Hello from AWS Lambda!"

return &LexResponse{
SessionAttributes: event.SessionAttributes,
DialogAction: events.LexDialogAction{
Type: "Close",
Message: map[string]string{
"content": messageContent,
"contentType": "PlainText",
},
FulfillmentState: "Fulfilled",
},
}, nil
}
```

0 comments on commit 044197f

Please sign in to comment.