This is a quick tutorial on adding button trigger for google assistant on raspberry pi, this tutorial was very straight forward and should take that much time to perform to add this action.

○○○ Parts ○○○

Momentary Switch ►


resistor 220 ohm ►

USB Microphone ►

Raspberry Pi 3 ►

Installing the RPi.GPIO

pip install RPi.GPIO

edit google samples assistant file

nano /home/pi/env/lib/python3.4/site-packages/googlesamples/assistant/

on the top of the file we need to import gpio

import RPi.GPIO as GPIO

now we have to setup our pins


GPIO.setup(18,  GPIO.IN, pull_up_down=GPIO.PUD_UP)

GPIO.setup(23, GPIO.OUT)

now we need to add the trigger to our code at line 197

comment out with #click.pause…..

input_state = GPIO.input(18)

if input_state == True:






remember to double check the indents, google likes to use 4 spaces in place of tab spacing.

if you want more details about this project, consider checking out one of my previous post about installing google assistant on raspberry pi

Google Assistant on Raspberry Pi