Okay. Here’s the goal. Use a third party task management system that can post webhooks with JSON payloads to add items to a shopping list.
I have the shopping list component setup. I have the ability to trigger automations with a URL.
What I can’t figure out is how to extract a portion of the payload that is delivered by the task management system as the shopping list item (task item.)
The following is the payload that is being posted from the task management software when the URL is called:
Right? I can easily trigger an automation with a webhook but the automation has the task name baked in:
action:
- service: shopping_list.add_item
data:
name: "Feed the dogs."
Etc.
I need to get what’s in the JSON payload into that name: data field, which if I conceptualize it correctly, means that either HA has to pluck specified information from the JSON payload, or the webhook has to somehow store a specific value in a variable that can be passed to a hassio script???
Hey guys, I have been trying to do something simliar with webhooks. Maybe this helps someone here, whoever finds this thread in the future. But: this will only work if you are subscribed to Nabu Casa Cloud, to have access to webhooks. Maybe there is another way, but I am subscribed so I can only speak for this way of doing it.
Here is the guide:
I was trying to use Alexa to add things to my shopping list in HA, so that may girlfriend and I both have the same shopping list when we open the HA app on our phones. I tried the IFTTT integration but it did not work for me, as I had to restart the service on IFTTT from time to time to get it to work - I don’t know why. Therefore I was looking for an alternative and first used Zapier, but they no longer offer Webhooks on their free plan. That’s why I used Automate.io to use ToDoIst and Webhooks. Step by step guide:
First I connected Alexa to ToDoIst. There is a skill on the app where you can “link” both lists. If you add something to your shopping list in alexa (e.g. via voice) it is also added to ToDoIst and vice versa.
Now I needed ToDoIst to add that item to my shopping list in HA: first create a new automation in your automations.yaml file with the following code:
Reload your automations and it should create a new automation. Go to Settings --> Home Assistant Cloud --> Webhooks --> “shopping list webhook test” --> copy the webhook URL
Go to the automate website and create a new bot and connect ToDoIst and use “new task” as a trigger & also choose your project --> “Alexa Shopping List” is the name of my list
Then choose the action: choose Webhook & “POST DATA” and insert your Webhook URL you copied earlier
Choose content type “JSON” and add this for the data field:
{"name":"Task Name"}
The field task name can be chosen from the little plus in the top right corner
The other fields can stay empty
Now you should be good to go! Add a new task in ToDoIst or on your Alexa Shopping List and then hit save on your bot and try to run it. It should pick up the new task and post the JSON data, which triggers your automation in HA and adds the JSON data to your shopping list!
Thanks for this great write up. 100% IFTTT just doesn’t cut it when it comes to reliability. When I put together my shopping list setup the todoist integration was broken, so IFTTT it was. I meant to, but never went back and changed when they fixed it. This write up will save me tons of time!! Thanks
no problem! to be honest, I didn’t even know or check if there was a native integration of Todoist. Might even work better, but what I posted above seems to be pretty solid :-).