-
Notifications
You must be signed in to change notification settings - Fork 1
Adding mobile notifications
Since all the messages are going to AWS IoT, you can define the AWS IoT ACT engine rule to get the notifications when there is a new MQTT message triggered.

You can also generate logs of all the triggered events.

We are using the IFTTT service to accomplish this task. You need an account in IFTTT.
Explore the webhook service.

Activate the service, then go to its Documentation.

You will see your IFTTT webhook API key.

Once the webhook service is activated, you can create the IF-This-Then-That applets. You can create IF-Webhook-Then-Send_a_notification_from_IFTTT_app. You also need to install the IFTTT mobile app on your phone so you can receive the notification.

You can also create the IF-Webhook-Then-Dropbox_append_to_a_text_file to generate the event logs sent through Dropbox.
We will need to build the Lambda function to be used in AWS Lambda, a serverless cloud. The source of this project was developed by Golang, so you will need the Golang SDK.
It is a simple Go code. The Webhook Code
Modify the code with your IFTTT API key and the event name when you created the applets.
Build the code with the target platform linux.
GOARCH=amd64 GOOS=linux go build -tags lambda.norpc -o bootstrap main.go
Note: Starting from December 31st, 2023, provided.al2
is required for the AWS Lambda with Golang.
The binary output needs to be named bootstrap
. Zip the built binary file.
zip ifttt_webhook.zip bootstrap
Let's go back to AWS console. We need to create a new IAM role for the Lambda function to run.

Create a new role.

Select 'AWS service' as the type of the trusted entity. Choose 'Lambda' for the use case.

Let's make it simple to choose 'AWSLambda_FullAccess' as the permission policy. If you are familiar with the AWS IAM, you can narrow down the permission selections on this role.

Let's call this role 'IFTTT', and create it.

Let's go to Lambda Management Console.

Create a new Lambda function.

Let's call the function name 'iftttWebhook'. The runtime is provided.al2. Custom runtime on Amazon Linux 2
. Choose the permission from the existing role. Select the role 'IFTTT' we just created previously. Click 'Create function'.

After the function is created, we need to edit the runtime settings.

Change the Handler to 'bootstrap'.

Upload the zipped built binary from the ifttt_webhook Go program.


We need to go back to the AWS IoT Core.

Go to the IoT Core Act -> Rules.

Create a rule.

- Name: EventToIFTTT
- Description: IFTTT Webhook Trigger
- Rule query statement:
SELECT * FROM 'mycontrol/demo' WHERE command > 0

Add action. Choose 'Send a message to a Lambda function'.

Select the Lambda function we just created previously.

Create this rule. You are good to go.
