kamikat / tttfi
- среда, 19 июля 2017 г. в 03:13:37
 
Middleware for IFTTT.
Middleware for IFTTT.
TTTFI picks up data from IFTTT webhook, pass data through scripts and send output of script back to IFTTT.
STEP1 Prepare scripts:
Let's write a simple hello world in shell (you can find that in samples folder).
#!/bin/sh
# Read body from stdin
read NAME
# Print response to IFTTT
cat << EOF
{"value1": "Hello, $NAME!"}
EOFSTEP2 Run docker image:
docker run -e API_KEY=<your-ifttt-key> \
           -e SECRET_TOKEN=<secret-token> \
           -v `pwd`/samples:/opt/bin \
           -p 3001:3001 \
           --name tttfi \
           kamikat/tttfi
NOTE: Pick up a random string as your SECRET_TOKEN.
STEP3 Setup trigger:
hello (name of the script)Value1 on any field of the service that supports itTest your configuration by sending some data using curl
echo 'world' | curl -XPOST -d- https://your-domain.com/hello/secret/<secret-token>
STEP4 Setup action:
https://your-domain.com/hello/secret/<secret-token>)POST and Content Type to text/plain (the hello event requires simple text)Scripts written in python or other platform can failed to start because they're not installed in container.
Add required package after start the container:
docker exec tttfi apk --no-cache add <package-name>
Or run tttfi natively (see next section)
TTTFI can run natively on *nix with ES6 compatible Node.js.
npm install -g tttfi
Run TTTFI:
PATH=<path-to-scripts>:$PATH API_KEY=<your-ifttt-key> SECRET_TOKEN=<secret-token> tttfi
Be careful that it executes ANYTHING in your $PATH with correct secret token.
(The MIT License)