Syncing Alexa/Google with the Shopping List

Ideal: Easy voice activation to add item to local HA shopping list via Alexa or Google Home.

I’ve managed to set up a nodered webhook that my IFTTT triggers when I add a shopping list item. “Echo [Alexa], add [item] to shopping list” (adds item to Alexa’s shopping list) > IFTTT eventually shoots off a json POST req via a webhook to my nodered > Nodered parses and then calls the Home Assistant shopping_list.add_item service > [item] shows up in HA Shopping List thumbs up

I can’t for the life of me figure out how to do the opposite: check off an item in HA Shopping List and clear it off of the Alexa shopping list.

Edit: At this rate, I’m winding up with an ever growing Alexa shopping list that says “you already have [item] would you like to add it again?” and I’d really rather not have to go into the Alexa list and prune it.

I guess this is all just a workaround for me to want to keep things locally, i.e. ask Alexa to add something directly to my HA shopping list without the cloud round trip. Is this possible? I use Home Assistant Cloud, so I don’t seem to have the exposed HTTP POST api (of which I’m still very novice at). For every other Alexa automation, it’s either been a command line script (sending ssh to our minecraft server or something silly) or just switching on/off lights. I don’t totally get how to initiate a dynamic skill to my nodered from Alexa.

Any thoughts/ideas/criticism are welcome. Thanks.

You are trying to do the exact same thing I have been struggling with for a different applications. I’m doing chores, but it works the exact same way.

1 Like

This would be very nice to have.

Could we trigger it through IFTTT?

Can you share how you did this (First part of your post)? Im a bit of a newb and struggling to get my head around what i need to do

1 Like

I’d love a step by step of this too if you have time please.

1 Like

Alrighty, after working on this for a little bit and not finding clear answers I finally figured it out and thought I would share how:

NOTE: I use Nabu Casa Cloud. If you don’t you need to set up HTTPS. I cant help with that, but I can highly recommend just using the cloud.

Step 1: In the Home Assistant UI go to configuration -> integrations -> (+) and add IFTTT as an integration. This will give you the URL

Step 2: Add this to automations.yaml

- id: webhook
  alias: 'Webhook Recieved'
  hide_entity: False
  initial_state: 'true'
  trigger:
    platform: event
    event_type: ifttt_webhook_received
    event_data:
      action: call_service
  action:
    service_template: '{{ trigger.event.data.service }}'
    data_template:
      name: '{{ trigger.event.data.name }}'

Step 3: Format your IFTTT aplet. Use whatever If statement (In this case Added item to shopping list), and

URL: Taken from IFTTT integration
Method: Post
Content Type: Application/JSON
Body:

{ "action": "call_service", "service": "shopping_list.add_item", "name": "{{AddedItem}}"}

Step 4: Add items! It should work. It does for me

5 Likes

See above post I made for help

I tryied buto don’t work for me

this is my action

{ “action”: “call_service”, “service”: “shopping_list.add_item”, “name”: “$”}

is right?

I have this error

Error while executing automation automation.ifttt. Invalid data for call_service at pos 1: extra keys not allowed @ data[‘entity_id’]

Thanks

I tryed also

{ “action”: “call_service”, “service”: “shopping_list.add_item”, “name”: {{TextField}}}

but nothing happen

Thanks

Did you put the automation for IFTTT Webhooks in your automations.yaml (or wherever your automations are). Make sure that is exactly as I have in my above code. It has to match the format exactly. If you use IFTTT for other webhooks and have “data_template: entity_id” not “data_template: name” it wont work. I dont use IFTTT for anything else so I didnt attempt to solve using data of multiple types.

Thank for yor answer the problem seem to be the action, because if i write

{“action”: “call_service”, “service”: shopping_list.add_item", “name”: “’$’”}

‘S’ is memorazed in the shopping list

my problem is to pass the ingredient from the action to HA. I made a lot of test without success!

It works… a stupid error… i was tired last night! Thanks for your script!!!

Glad you got it working, sorry for not following up sooner, been busy and out of town.

I’m having a hard time wrapping my mind around this.
I see this as adding an item, but how does it remove one from Alexa?

Nice, I’m glad adding items works, I’ve only had a quick glance at the shopping list docs:

Would just calling the Service shopping_list.complete_item service not remove the item?

Also is IFTTT easy enough to set up to do this? I may give this a try myself at some point.

EDIT: Oh I see you’re trying to make it so NodeRED is able to remove items from the Alexa shopping list, that my turn out to be a little more tricky, I can’t think of an easy way right now.

I also get it working to add an item, but when I attempt to clear out an item, it tells me the trigger is undefined.

Just want to add that you can check the items on the list in Home Assistant as well.

{ "action": "call_service", "service": "shopping_list.complete_item", "name": "{{CompletedItem}}"}

Love this, thank you!

If you need to use ifttt service calls with entity id’s, as well as as this - you can create simple webhook calls for each once you have integrated ifttt:


- id: shopping_list_webhook
  alias: IFTTT shopping webhook received
  trigger:
    platform: webhook
    webhook_id: shopping_list
  action:
    service_template: '{{ trigger.json.service }}'
    data_template:
      name: '{{ trigger.json.name }}'


- id: generic_ifttt_hook
  alias: IFTTT entity webhook received
  trigger:
    platform: webhook
    webhook_id: ifttt
  action:
    service_template: '{{ trigger.json.service }}'
    data_template:
      entity_id: '{{ trigger.json.entity_id }}'

in IFTTT (using the above examples) you would use the following urls for the webhook:

Standard Entity automations: https://your.domain.here/api/webhook/ifttt
Shopping List automations: https://your.domain.here/api/webhook/shopping_list

I’m confused about how to set up Alexa and IFTT
I presume I need to add IFTTT to Alexa?
What triggers the IFTTT in Alexa when I say Add [item] to shopping list?