简体   繁体   中英

Custom commands for Google Assistant SDK

I've got a raspberry pi running the Google Assistant SDK, and it's working amazingly so far. I'm just wondering how I could make custom commands for the assistant, that would then trigger bash commands on the pi. Any help would be greatly appreciated.

You can add your own functions, call external commands, etc. using the pattern in assistant_library_with_local_commands_demo.py from the aiyprojects-raspbian project on GitHub. Here is a commit where I add my own custom local commands to Google Assistant.

You do have to jump through the hoops to use the Cloud Speech API, but it's still using the Google Assistant. You don't have to use "actions on Google" stuff described by @Ayoub above.

Note: If you fail to include the assistant.stop_conversation() as I first did, you get a weird response with 2 voices talking to you.

As far as i know what you are looking for is more complicated than that. the assistant does not have direct access to its environment where it's installed.

So if it's on your phone you cannot just run something on the phone directly.

what you're looking for is to create an action on google:

the action on google that you will create will be triggered with your command on the assistant then it will it self trigger a webhook (function running in the cloud) hosted possibly in your pi (if you have a web server that you can access publicly) and then from there you can run whatever script you are talking about. i have done that using my:

  • google home ==> actions on google ==> api.ai ==> raspberrypi ==> run action

feel free to ask if you have any thing unclear.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM