Name: amazon-workmail-demo-ews-push-notifications
Owner: AWS Samples
Description: A sample application demonstrating the use of EWS Push Notifications. It creates a push responder using AWS Lambda and API Gateway to respond to changes in your mailbox.
Created: 2018-02-06 19:13:06.0
Updated: 2018-02-19 09:51:13.0
Pushed: 2018-02-09 13:01:11.0
Homepage: null
Size: 18
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
WorkMail?s Push Notifications API allows customers to receive notifications about changes in their mailbox, such as receiving a new mail and updates in the calendar, by using its Push Notifications feature. Customers can register URL?s (push notification responders) which will then receive these notifications. This allows the development of responsive client applications, as they can quickly reflect changes in the mailbox in the user interface.
This sample presents a demo Push Notification responder running on top of AWS Lambda and API Gateway, using the AWS Serverless framework.
This demo contains two parts:
The push notification responder (Lambda handler) performs the following activities:
To run the demo application perform the following operations:
clone https://github.com/aws-samples/amazon-workmail-demo-ews-push-notifications
clean package shade:shade
cloudformation package --template-file template.yml --output-template-file output-template.yaml --s3-bucket <YOUR_S3_BUCKET_NAME>
cloudformation deploy --template-file output-template.yaml --stack-name workmail-demo --capabilities CAPABILITY_IAM
This will create a CloudFormation stack with two functions: one which will invoke the Push Subscription API and another which will handle the notifications.
Inspect the output values of the cloud formation.
cloudformation describe-stacks | jq '.Stacks[] | select(.StackName == "workmail-demo").Outputs[].OutputValue'
The first is the API Gateway endpoint of the lambda response handler and the second is the ARN of the lambda function which subscribes to the mailbox events.
Both lambda functions require valid user credentials to access the WorkMail endpoint. The code assumes that the user password is stored encrypted in the AWS Systems Manager Parameter Store (SSM Parameter store - https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-paramstore.html).
To set the password in the SSM Parameter store, run the command below or use the AWS EC2 console to create the parameter. Note that the parameter name must match the user part of the email (e.g if the email address is john@example.com then the name of the parameter must be ?john).
ssm put-parameter --name <USER> --value <PASSWORD> --type "SecureString"
To register a user's mailbox for push subscriptions run:
lambda invoke --function-name <SUBSCRIBE_LAMBDA_ARN> --payload '{"email": "EMAIL"}' outputfile.txt
A successful run results in the following output in the console:
"StatusCode": 200
To see the demo in action, send an email to the user subscribed for push subscriptions above with the subject “demo” from another user's account. The sender will then receive a reply consisting of the sentiment analysis of the content in the body of the initial email.
To stop subscriptions just delete the stored password from the SSM Parameter store:
ssm delete-parameter --name <USER>
Once the parameter is deleted the lambda notification responder will respond with 'Unsubscribe' when the next notification will be received.
To find out more about Amazon WorkMail, please visit Amazon WorkMail.