This is currently available only on certain apps, and only certain phrases work. You can say 'Ok Google' to do voice actions with other apps on your device. Remove what you've taught to Google to recognize your voice on that device.
Try this if Google isn’t recognizing your voice when you say 'Hey Google.' If you don't see this setting, make sure 'Hey Google' is turned on.
Teach Google the sound of your voice again. See personal results for your voice searches, even when your device is locked. When you say 'Hey Google' from a secure lock screen and we're able to recognize the sound of your voice, you can ask Google to take actions for you or visit sites without having to unlock your device manually. You can say 'Hey Google' whether your screen is on or off. You can say 'Hey Google' while you use Google Maps and Android Auto. This setting could prevent some other voice services that use hot words or wake-up commands from working. If the screen is on or the device is charging, you can say 'Hey Google' from any screen. Learn how to change your Google app settings. Not all settings are available for all languages. Settings can vary by device and Google app version.