trigger IFTTT maker webhook from HB vbscipt

Share your scripts written for the Script Device in this forum.
Post Reply
martijnj
Member
Posts: 61
Joined: Mon Nov 03, 2003 2:50 pm
Location: NL

trigger IFTTT maker webhook from HB vbscipt

Post by martijnj »

Hi all,

I'm trying to get HB to trigger IFTTT maker Webhook from Housebot. I just can't seem to get it to work.

Does anybody know how to do this.

This is the info from de IFTTT side
To trigger an Event
Make a POST or GET web request to:

https://maker.ifttt.com/trigger/{event}/with/key/{maker code}
With an optional JSON body of:

{ "value1" : "", "value2" : "", "value3" : "" }

The data is completely optional, and you can also pass value1, value2, and value3 as query parameters or form variables. This content will be passed on to the Action in your Recipe.

You can also try it with curl from a command line.

curl -X POST https://maker.ifttt.com/trigger/{event}/with/key/{maker code}
I tryed (I replaced {event} and {maker code} with my own cridentials

Code: Select all

Dim objXmlHttpMain , URL

strJSONToSend = "{""value1"":""test""}"

URL="https://maker.ifttt.com/trigger/{event}/with/key/{maker code}"


Set objXmlHttpMain = CreateObject("Msxml2.ServerXMLHTTP") 

objXmlHttpMain.open "GET",URL, false 

objXmlHttpMain.setRequestHeader "Content-Type", "application/json"


objXmlHttpMain.send strJSONToSend

msgbox objxmlHttpMain.responseText

set objJSONDoc = nothing 
set objResult = nothing
Results in Error 0 unexpected Responce....

And

Code: Select all

Dim objRequest 
Dim URL 
Set objRequest = CreateObject("MSXML2.XMLHTTP.6.0")      
URL = "https://maker.ifttt.com/trigger/{event}/with/key/{maker code}"    
objRequest.open "GET", URL , false      
objRequest.Send ()     
Set objRequest = Nothing 
It results in Error 0 The download of the ..... has faild

If I type the URL ("https://maker.ifttt.com/trigger/{event}/with/key/{maker code}) in my browser I get an responce in html:
Congratulations! You've fired the {event} event
Does anybody know the sollution?
Richard Naninck
HouseBot Guru Extraordinaire
Posts: 1121
Joined: Tue Sep 28, 2004 7:49 am
Location: The Netherlands

Re: trigger IFTTT maker webhook from HB vbscipt

Post by Richard Naninck »

Not sure what you are trying to do however IFTTT Webhooks work just fine for me.

Code: Select all

https://my.housebot.com/xc/SPV?D=Your%20Device&P=Your%20DeviceProperty&V=Your%20Value%53{{TextField}}&C=your my.housebot key
This IFTTT Webhook gets triggered by Google Home if I ask Google where a certain person is.
Hey Google; Where is "Richard"

Richard is then put in the {TextField} and the webhook sends a message to my.housebot @ Device / Property / Value
In this case the Value would be: Your Value^Richard
A script then parses the value and casts to google where Richard is.

Hope this helps a bit.
martijnj
Member
Posts: 61
Joined: Mon Nov 03, 2003 2:50 pm
Location: NL

Re: trigger IFTTT maker webhook from HB vbscipt

Post by martijnj »

Hi Richard,

Thanks but I am trying the other way around. Use housebot as a trigger for IFTTT. If I push a housebot theme button it fires the webhook.

Martijn
martijnj
Member
Posts: 61
Joined: Mon Nov 03, 2003 2:50 pm
Location: NL

Re: trigger IFTTT maker webhook from HB vbscipt

Post by martijnj »

Hi Richard,

Thanks but I am trying the other way around. Use housebot as a trigger for IFTTT. If I push a housebot theme button it fires the webhook.

Housebot is the IF and the webhook the That

Martijn
Richard Naninck
HouseBot Guru Extraordinaire
Posts: 1121
Joined: Tue Sep 28, 2004 7:49 am
Location: The Netherlands

Re: trigger IFTTT maker webhook from HB vbscipt

Post by Richard Naninck »

Ah, that makes sense now. Never tried that but I will give it some thought and report back if I find something
Richard Naninck
HouseBot Guru Extraordinaire
Posts: 1121
Joined: Tue Sep 28, 2004 7:49 am
Location: The Netherlands

Re: trigger IFTTT maker webhook from HB vbscipt

Post by Richard Naninck »

I just created the code below and tested it. It gives me "Congratualations! You...."
However after comparing my code with yours, there seems to be no difference and your code is supposed to work.
If it doesn't, it is not the code that is wrong, but some other setting. Just try different XML objects such as "Microsoft.XmlHttp" or "Msxml2.ServerXMLHTTP.6.0" instead of Msxml.ServerXMLHTTP. All of those work in my code

Code: Select all

Call Test()


'-------------------------------------------------------
'- -----------------------------------------------------
'-------------------------------------------------------
Sub Test() 
Dim objXML
Dim strJSONToSend

	Set objXML    = CreateObject("Msxml2.ServerXMLHTTP")  
	strJSONToSend = "{""value1"":""test1"", ""value2"":""test2""}"
		
	Call objXML.Open("GET", "https://maker.ifttt.com/trigger/MyTest/with/key/your_key_here", False)
	objXML.setRequestHeader "Content-Type", "application/json" 
	Call objXML.Send(strJSONToSend)
	MsgBox objXML.responseText
	Set objXML = Nothing
End Sub
Post Reply