Alexa Shopping list one way sync to HA

Me and my wife are constantly asking Alexa to add things to the shopping list. However, when we go shopping, we prefer to use HA Shopping List.
So, I had to find a way to sync from Alexa to HA one way sync only.

In my first setup I had the following:

  • Alexa Shopping List => IFTTT => Home Assistant.
    An item was created in Alexa Shopping list, IFTTT would see that as a trigger and send a webhook to HA and add the item to HA Shopping List
    IFTTT stopped working with Alexa Shopping list, so I had to find a different way.

My second setup was:

  • Alexa Shopping List => Todoist => IFTTT => Home Assistant
    An item was created in Alexa Shopping list, it would automatically sync with Todoist, IFTTT would see that as a trigger and send a webhook to HA and add the item to HA Shopping List
    However, recently, IFTTT change its policy and Webhooks are available only in the paid version (Pro version).
    I had to find another way.
    In a quick search for ITFFF alternatives, I found Zapier (zapier.com)

My current setup that is actually working is:

  • Alexa Shopping List => Todoist => Zapier => Home Assistant
    An item was created in Alexa Shopping list, it would automatically sync with Todoist, Zapier sees that as a trigger and send a webhook to HA and add the item to HA Shopping List

If you want to set that up, follow the instructions below:

In Home Assistant:

1 - Go to Settings, Automations and click on Create Automation
2 - Add a trigger and select Webhook. Once create, click on the copy button on the right. It will copy something similar to:
http://10.0.0.1/api/webhook/-njfnsnfnalsdnaksd
Make sure when you use in Zapier, you use with your external URL:
i.e. https://my_ha_server/api/webhook/-njfnsnfnalsdnaksd
3 - Under Action, select Call Service, switch to YAML Editor and add the following:

service: shopping_list.add_item
data_template:
  name: "{{ trigger.json.name }}"

In Alexa App:

1 - Add Todoist Skill to your Alexa

In Zapier:

1 - Go to Zapier, create an account and create an app.

2 - Click on trigger, select Todoist and choose “New Incomplete Task”.

3 - When you click on Continue, it will ask you to Sign In to Todoist. Do it and click on Continue.

4 - Under Project, select Alexa Shopping List and click on Continue

5 - On the left side, click on Action.

6 - Select “Code by Zapier” and under Event, select “Run Javascript” and click Continue

7 - Under Input Data add the following (as the image below)
Webhook => https://your_ha_page/api/webhook/your_webhook (use the webhook address saved in the step #2 under “In Home Assistant:”
Methodo => POST
item_name => click and select “1. Content:” (it will show the last item in your list)

  • if you need help to create a webhook in HA, please check this page

8 - Under Code, add this:

let Timestamp = new Date().toISOString(); // creates a Timestamp
let Webhook = inputData.Webhook.trim();
let Method = inputData.Method.trim();
let item_name = inputData.item_name.trim();

// creates the JSON Object to send with the key/value pairs
let JSONObject = { "action": "call_service", "service": "shopping_list.add_item", "name": item_name}

// creates the Method, Headers, and Body of the HTTP POST Request
let Options = {
     method: Method,
     headers: {
          'Accept': 'application/json',
          'Content-Type': 'application/json'
     },
     body: JSON.stringify(JSONObject)
}
const Request = await fetch(Webhook, Options); // HTTP POST Request
output = {Timestamp}

9 - Click on Continue and click on Test step
The test above should add the item to your HA Shopping list.

10 - Click on Publish.
This last step should activate the App and everything that you add to the Alexa Shopping List will make into your HA Shopping List.

Because this is a one way sync (Alexa => HA), I have an automation to clear my Alexa Shopping List every day and I manage everything from HA only.

There is a custom component Todoist Alexa Shopping List you should check out. I had an Iftt webhook set up for years and was looking for alternatives when it became unavailable. This component syncs Alexa - Todoist - Home Assistant almost instant and both ways.

In my case, I needed to sync one way only (from Alexa to HA).
I did not want items cleared from the HA Shopping List to be removed from Todoist and Alexa.