Adding a shopping list item using webhook api HTTP POST...almost there...need help

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:

{
	"eventCreator": {
		"id": 128084,
		"firstName": “First Name”,
		"lastName": “Last Name“,
		"avatar": "https://s3.amazonaws.com/TWFiles/408231/userAvatar/tf_3D3E2308-E39C-C6F3-687FDDB4B99CBD1A.Gray_Shirt_Facing_Front.png"
	},
	"task": {
		"id": 12708403,
		"name": "Bing Bong",   <---THIS IS THE SHOPPING LIST ITEM
		"priority": null,
		"status": "new",
		"parentId": 0,
		"taskListId": 666593,
		"startDate": null,
		"dueDate": null,
		"progress": 0,
		"tags": [],
		"projectId": 228335,
		"dateCreated": "2019-01-31T05:58:55Z",
		"dateUpdated": "2019-01-31T05:58:55Z"
	},
	"taskList": {
		"id": 666593,
		"name": "General tasks",
		"description": "",
		"status": "reopened",
		"milestoneId": 0,
		"projectId": 228335,
		"tags": []
	}
}

If I create an automation, how do I get the “name” : “Bing Bong” into the data: name: portion of the service data for the automation?

Yes , was struggling with this too with Google assistant … Add blabla to the shopping list…

Ended up with IFTTT , there you can use a variable textfield

I am using this custom component :

Google Keep Custom Component

But also interested in your idea, don’t want to work anymore with IFTTT

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???

Not sure how this happens though.

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:

  - id: shopping_list_webhook_test
    alias: shopping list webhook test
    trigger:
      platform: webhook
      webhook_id: shopping_list_webhook_test
    action:
      - service: shopping_list.add_item
        data_template:
          name: "{{ trigger.json.name }}"
  • 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!

1 Like

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 :-).