
Triggering Email alerts from the IOTA Tangle
The DIY Guide
I recently came across a new project called Totangle. Totangle integrates the tangle with Zapier, which allows you to integrate things happening on the tangle to your existing APIs or workflows. The first use case they present is setting up an email alert when you get a payment on the tangle.
Inspired by this, and also needing this tool myself (I want to get alerts when I receive tips from my Medium articles, without having to constantly keep my wallet open), I thought I’d see if I could make an open source lambda function that copies this basic functionality.
Here’s How It Works:We write a lambda function that looks for an address or tag on the tangle every 30 minutes or so.If the lambda function sees new transactions it hasn’t previously seen, it sends an email using SNS to my email address.Once it has sent the email, it saves the recently seen transactions to some list somewhere — maybe S3 will work for now, or in the future we could use DynamoDB.Part One: Setting up the lambda
We’re going to use the excellent, albeit poorly named, serverless framework to manage our AWS lambdas and triggers for us.
Let’s start by creating a new project.
$ npm install -g serverless
$ serverless create –template aws-nodejs –path tangle-trigger
$ cd tangle-trigger
$ npm init -y
We also need to install the iota library, and set up some nice environment variables
$ touch .env
$ npm install –save iota.lib.js
Let’s edit the .env file first:
export AWS_PROFILE=default
export IOTA_URL=”http://localhost:14265″
export IOTA_ADDRESS=”9999″
We use the AWS_PROFILE environment variable to control which AWS account serverless deploys to. I quite often have to navigate between accounts, so this environment variable is very helpful.
The two IOTA_* environment variables are just placeholder, but I wanted to show you how to get them into the running lambda function.
Let’s add a deploy script to the package.json:
https://medium.com/media/c07f4397cac5df6b8a74de9477833345/href
Next up, we need to modify the Serverless.yml file to define the lambda function and the event triggering the function.
https://medium.com/media/797517106283ed600c51f224f949ff28/href
For now, we

