Unofficial YouTube skill for Alexa
- This skill has become so popular, I am close to hitting the limits on the free AWS lambda tier, which is 800000 seconds of CPU time per month!
- I have removed the ARNs from below, so only start following the instructions if you are capable of deploying your own lambda instance.
- If you have your own lambda instance and would like to host some of the load, please raise an issue and I will be in touch.
- 2nd June 2018: The skill now handles playlists or channels where none of the videos exist (eg copyrighted deletions). It will now ask you if you want to try the next playlist or channel. If you have already created the skill, you will need to update the Interaction Model json file in your Alexa skill, ie step 7 under Setup Instructions.
- 22nd August 2018: Fixed a bug where channels turn up in video search results, eg in Play videos by The Beatles.
- 4th January 2019: Now works in 5 languages, thanks to everyone who helped!
- 1st February 2019: Live videos don't seem to be working. Have updated the list of commands.
- 3rd February 2019: Live videos fixed, for Gen 2 devices at least.
- Play audio from YouTube videos
- Play video (if supported) on live videos or if you ask for just one specific video (command 8)
- Makes a list of all the videos played, in the Alexa app
- Play a video, eg "Alexa, ask YouTube to play Gangnam Style"
- Play a playlist, eg "Alexa, ask YouTube to play playlist Ultimate Beyonce"
- Play a channel, eg "Alexa, ask YouTube to play channel Fall Out Boy Vevo"
- You can replace "play" with "shuffle" to get a randomized version of the search results/channel/playlist, eg "Alexa, ask YouTube to shuffle channel Nicki Minaj"
- Next / Previous / Start Over / Pause / Resume should all work
- Ask what is playing by "Alexa, ask YouTube what song is playing" (or just "Alexa, can you repeat that?" should tell you)
- Skip forward or back in the video by "Alexa, ask YouTube to skip forward/backward to/by one minute and one second"
- Just play one video by "Alexa, ask YouTube to play one video Gangnam Style". You can switch in and out of "autoplay" mode by "Alexa, ask YouTube to turn on/off autoplay."
- Find the current time in the video by "Alexa, ask YouTube what is the timestamp?"
- If you want to play your own playlists, and the search feature finds other people's, if you follow the Advanced instructions below you can specify your own channel id.
- Play related videos, by "Alexa, ask YouTube to play more like this". This is a YouTube feature, don't ask me why it plays what it plays.
Command 7 doesn't seem to work on Generation 1 Echo's, no idea why. Commands 8, 9, 10 and 11 are only available in English at the moment.
- Some videos just fail, it's not clear why, they work locally. The skill just moves to the next video on the playlist, but this can mean sometimes she announces a video that doesn't play.
- Apparently it doesn't work on Sonos devices. Sorry about that, email Sonos and ask them to support mp4.
- Live videos work on Gen 2 devices onwards, not on the original Gen 1 Echo.
- Go to the Alexa Console (https://developer.amazon.com/alexa/console/ask)
- If you have not registered as an Amazon Developer then you will need to do so. Fill in your details and ensure you answer "NO" for "Do you plan to monetize apps by charging for apps or selling in-app items" and "Do you plan to monetize apps by displaying ads from the Amazon Mobile Ad Network or Mobile Associates?"
- Once you are logged into your account click "Create Skill" on the right hand side.
- Give your skill any name, eg "My YouTube Skill".
- Important Set the language to whatever your Echo device is set to. If you are not sure, go to the Alexa app, go to Settings, Device Settings, then click on your Echo device, and look under Language. If your Echo is set to English (UK), then the skill must be English (UK), other types of English will not work!
- Choose "Custom" as your model, and click "Create Skill".
- On the left hand side, click "JSON Editor".
- Delete everything in the text box, and copy in the text from https://raw.githubusercontent.com/ndg63276/alexa-youtube/master/InteractionModel_en.json, (or use InteractionModel_fr.json, InteractionModel_it.json, InteractionModel_de.json, InteractionModel_es.json for French, Italian, German or Spanish)
- Click "Save Model" at the top.
- Click "Interfaces" in the menu on the left, and enable "Audio Player" and "Video App". Click "Save Interfaces".
- Click "Endpoint" in the menu on the left, and select "AWS Lambda ARN". Under "Default Region", put
my ARNthe ARN you get from the section "Deploying Yourself" below. - Click "Save Endpoints"
- Click "Permissions", at the very bottom on the left.
- Turn on "Lists Read" and "Lists Write".
- Click "Custom" in the menu on the left.
- Click "Invocation" in the menu on the left.
- If you want to call the skill anything other than "youtube", change it here. Click "Save Model" if you change anything.
- Click "Build Model". This will take a minute, be patient. It should tell you if it succeeded.
- Important: At the top, click "Test". Where it says "Test is disabled for this skill", change the dropdown from "Off" to "Development".
This skill can make a list of the last 90 videos played, but you have to give it permissions in the Alexa app:
- Go to the Alexa app on your phone. In the menu, go to "Skills & Games", then "Your Skills", then scroll to the right and click on "Dev".
- Click on your YouTube skill. You should see a button marked "Settings", click that.
- Then press on "Manage Settings", and tick the boxes marked "Lists Read Access" and "Lists Write Access", and press "Save Settings".
- Say "Alexa, launch YouTube", that will create the list, and from then on, videos will be added to it. The list can be viewed in the Alexa app, click Lists from the main menu.
That's it!
This skill currently runs on my Lambda instance, hopefully it won't get too popular. If you want to, and know how, you can deploy it on your own Lambda, you just need the lambda_function.zip file, and a YouTube developer key. (See here).
tal9000v2 has put together a handy guide for deploying yourself here.
If you have (public) playlists that you would like to play, first get your channel ID from youtube. Find a video you have uploaded, then click on your name beneath it, it should take you to eg https://www.youtube.com/channel/UCDVYQ4Zhbm3S2dlz7P1GBDg, in which case your channel ID is UCDVYQ4Zhbm3S2dlz7P1GBDg. Then, when you add the environment variable DEVELOPER_KEY, add another environment variable called MY_CHANNEL_ID, with the value of that your channel ID. Then you can say, "Alexa, ask YouTube to play my playlist {name of your playlist}".
- Alexa tells me she can't find any supported video skills, what does that mean? Alexa is trying to be too clever, and not launching this skill. Start your request by saying 'Alexa, open YouTube' and then when she says 'Welcome to YouTube', ask for the video you want.
- She still says she can't find any video skills. Make sure to follow step 15 above, enabling Testing for Development.
- She still says she can't find any video skills! Try using a different word to start the skill. In English, say "Alexa, launch YouTube". In German, say "Alexa, öffne YouTube". In Italian, say "Alexa, avvia YouTube".
- I am getting another issue, can you fix it? Hopefully. Create an issue on github, with the exact wording of what you ask Alexa, so I can try and reproduce it.
- Can you add another language? Yes, as long as you can translate for me. Click on 'Issues' at the top, then 'New Issue', and let me know what language you can help with, and I'll let you know what I need translating.
- If I try and test in the Developer Console, it says 'Unsupported Directive. AudioPlayer is currently an unsupported namespace. Check the device log for more information.' That is normal, the Developer Console doesn't play audio. You just need to enable testing through the Developer Console, then you can use the skill through your Alexa device.
- Why don't more videos work as video? Alexa doesn't provide any ability to enqueue videos, so you only get one video, then it stops. So it only plays videos if you ask for one specific video, or if it is a live video.
- Did I hear an advert? Yes, that was me. If you are in the UK, and are looking for cheap, renewable energy, join Bulb using this link, and both you and me get £50 credit.
- Why have you put in an advert? Writing this skill has taken a large amount of my time, and continues to do so. This is a way to support me. You will only hear it if you are in the UK, and even then only 10% of the time (overall, it's random). If you deploy your own lambda instance, you won't hear it.