If Pay Then That
Trigger IFTTT actions with Bitcoin Lightning payments.
Powered by ⚡️ Lightning Charge and paypercall.
Install
$ npm install -g ifpaytt
Setup
-
Setup Lightning Charge.
-
Get your IFTTT maker key from IFTTT's Webhook settings page (shown as
https://maker.ifttt.com/use/[MAKER-KEY-HERE]
). -
Open the new applet page, click "this", enter "Webhooks", click "Receive a web request", enter a descriptive event name prefixed by
ifpaytt_
containing only numbers, lowercase letters and_
(e.g.ifpaytt_lightup_room404
orifpaytt_vend_machine137_item56
), and hit "Create Trigger". -
Configure your "then" action and finish creating the IFTTT applet.
-
Start the
ifpaytt
server:$ ifpaytt --charge-token [mySecretToken] --ifttt-key [myMakerKey] --port 6000 --currency BTC \--price-lightup_room404 0.00001 --price-vend_machine137_item56 0.00023Running on http://localhost:6000
That's it! The server is now ready to accept payments and trigger IFTTT actions.
Paying to trigger actions
-
Send an empty
POST
request to/{event-name}
to get the BOLT11 payment request and theX-Token
header:$ curl -i -X POST http://localhost:6000/lightup_room404HTTP/1.1 402 Payment RequiredContent-Type: application/vnd.lightning.bolt11X-Token: lmbdmJeoSQ0ZCB5egtnph.af1eupleFBVuhN2vrbRuDLTlsnnUPYRzDWdL5HtWykYlnbcrt8925560p1pdfh7n2pp54g5avyupe70l988h30u0hy8agpj2z7qsveu7ejhys97j98rgez0... -
Make the payment:
$ lightning-cli pay lnbcrt8925560p1pdfh7n2pp54g5avyupe70l988h30u0hy8agpj2z7qsveu7ejhys97j98rgez0... -
Send the request again, this time with the
X-Token
header echoed back and optionally withvalue1
,value2
andvalue3
in the request body (passed along to IFTTT):$ curl -i -X POST http://localhost:6000/lightup_room404 \-H 'X-Token: lmbdmJeoSQ0ZCB5egtnph.af1eupleFBVuhN2vrbRuDLTlsnnUPYRzDWdL5HtWykY' \-d value1='brightness=80,color=red'HTTP/1.1 200 OKContent-Type: text/plainCongratulations! You've fired the lightup_room404 event(if
value[1-3]
are not set, they'll automatically be populated with some useful information about the payment.)
CLI options
$ ifpaytt --help Trigger IFTTT actions with Bitcoin Lightning payments Usage $ ifpaytt [options] Options -c, --charge-url <url> lightning charge server url [default: http://localhost:9112] -t, --charge-token <token> lightning charge access token [required] -k, --ifttt-key <key> IFTTT maker key [required] -r, --ifttt-prefix <prefix> prefix
License
MIT