Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

Using IFTTT WebHooks

I've just recently been able to do simple https request to IFTTT to text me so I'm sharing how this is done in Mongoose OS with you guys.
1. Open IFTTT account, setup SMS service then create a Webhooks applet to trigger SMS from "Receive a web request". For testing, setup a simple trigger to do email instead of SMS to start. Make a note of your applet name and IFTTT key.
2. Test your IFTTT applet using the "Documentation" link under page https://ifttt.com/maker_webhooks.
3. Get maker.ifttt.com CA certificate using openssl command. Under linux os: openssl s_client -connect maker.ifttt.com:443 -showcerts Save result then extract one of the available certificates. Below is what I extracted for your convenient.

Subject:/C=US/O=The Go Daddy Group, Inc./OU=Go Daddy Class 2 Certification Authority
Not Before: Jul 25 16:45:38 2016 GMT
Not After : Sep 28 21:13:54 2018 GMT
-----BEGIN CERTIFICATE-----
MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEh
MB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBE
YWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3
MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkGA1UEBhMCVVMxITAfBgNVBAoTGFRo
ZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28gRGFkZHkgQ2xhc3Mg
MiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQADggEN
ADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCA
PVYYYwhv2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6w
wdhFJ2+qN1j3hybX2C32qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXi
EqITLdiOr18SPaAIBQi2XKVlOARFmR6jYGB0xUGlcmIbYsUfb18aQr4CUWWoriMY
avx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmYvLEHZ6IVDd2gWMZEewo+
YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0OBBYEFNLE
sNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h
/t2oatTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5
IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmlj
YXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD
ggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wimPQoZ+YeAEW5p5JYXMP80kWNy
OO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKtI3lpjbi2Tc7P
TMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ
HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mER
dEr/VxqHD3VILs9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5Cuf
ReYNnyicsbkqWletNw+vHX/bvZ8=
-----END CERTIFICATE-----
  1. Create a basic MOS apps, make sure you have file ca.pem in your device's file system. Edit your ca.pem and add the ca certificate above.
  2. Configure MOS OS mos config-set http.ssl_ca_cert=ca.pem
  3. Now you are ready to use it in your Javascript apps. In example code below, replace "EvenName" with your applet name and xxxxxx with your ifttt maker key
    HTTP.query({
        url: 'https://maker.ifttt.com/trigger/EventName/with/key/xxxxxxxxxxxxxxxx',
        headers: { 'Content-Type': 'application/json'},
        data: {
            'value1': 'MOS Test',
            'value2': 'My message'},
        success: function(body, full_http_msg) { print( "HTTPS Sent: ", body); },
        error: function(err) { print("HTTPS Error: ", err); },  // Optional
    });

I have this code in a button handler block to run when I press a button. Below is what you will receive from the HTTP.query if it works

HTTPS Sent:  Congratulations! You've fired the MySMS event

Comments

Sign In or Register to comment.