Skip to main content

gassist_text

A Python library for interacting with Google Assistant API via text.

Credits

Uses https://pypi.org/project/google-assistant-grpc/. See instructions there how to get credentials.json.

Code is essentially a copy of https://github.com/googlesamples/assistant-sdk-python/blob/master/google-assistant-sdk/googlesamples/assistant/grpc/textinput.py wrapped in a package.

Example

import json
import google.oauth2.credentials
with open('/path/to/credentials.json', 'r') as f:
    credentials = google.oauth2.credentials.Credentials(token=None, **json.load(f))

from gassist_text import TextAssistant
with TextAssistant(credentials) as assistant:
    print(assistant.assist('tell me a joke')[0])
    print(assistant.assist('another one')[0])

Async example

TextAssistantAsync is the asyncio equivalent of TextAssistant. It has the same constructor and returns the same (text, html, audio) tuple, but assist() is a coroutine and nothing blocks the event loop.

import asyncio
import json
import google.oauth2.credentials
from gassist_text import TextAssistantAsync

with open('/path/to/credentials.json', 'r') as f:
    credentials = google.oauth2.credentials.Credentials(token=None, **json.load(f))

async def main():
    async with TextAssistantAsync(credentials) as assistant:
        print((await assistant.assist('tell me a joke'))[0])
        print((await assistant.assist('another one'))[0])

asyncio.run(main())

Notes:

  • It is built on grpc.aio, which ships with grpcio; no extra dependency is needed.
  • The gRPC channel is created on the first assist() call, so it binds to the event loop that actually uses it. Constructing the object outside of a running loop is fine.
  • Refreshing the OAuth2 access token is blocking, but gRPC calls the auth metadata plugin on its own thread, so the event loop is not blocked.
  • Neither class is safe for concurrent use: both keep the conversation state of a single conversation. Use one instance per conversation, or serialize the calls.

Limitations/Known issues

If you see the issued commands in My Google Activity the library is working fine. If the commands don't have the expected outcome, don't open an issue in this repository. You should instead report the issue directly to Google. Examples of known Google Assistant API issues:

  • Broadcast commands don't work unless speakers and device that runs this library are in the same network and IPv6 is disabled in the router
  • Most queries for media controls don't work
    • not working: e.g. play music on kitchen speaker, stop kitchen speaker
    • working: e.g. play news on kitchen speaker, play rain sounds on bedroom speaker
  • Routines don't work
  • Commands that need to verify your identity through voice match don't work

To get personal results working you need to create an OAuth client ID of Desktop app, see step by step instructions in this article.

Development environment

python3 -m venv .venv
source .venv/bin/activate
# for Windows CMD:
# .venv\Scripts\activate.bat
# for Windows PowerShell:
# .venv\Scripts\Activate.ps1

# Install dependencies
python -m pip install --upgrade pip
python -m pip install -e .

# Generate embedded_assistant_pb2.py and embedded_assistant_pb2_grpc.py,
# and the .pyi type stubs that let mypy check the protobuf messages
python -m pip install grpcio-tools mypy-protobuf
python -m grpc_tools.protoc -Isrc --python_out=src --grpc_python_out=src --mypy_out=src --mypy_grpc_out=src src/google/assistant/embedded/v1alpha2/embedded_assistant.proto

# Run pre-commit
python -m pip install pre-commit
pre-commit autoupdate
pre-commit install
pre-commit run --all-files

# Alternative: run formatter, lint
python -m pip install isort black flake8 ruff
isort . ; black . ; flake8 . ; ruff check . --fix

# Run tests
python -m pip install pytest
pytest

# Run command line interactive tool
python -m pip install click beautifulsoup4
python demo.py --display --audio_out
# ... or exercise the asyncio client
python demo.py --display --audio_out --use-async

# Build package
python -m pip install build
python -m build

Release files for gassist-text 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gassist-text 0.1.0
File Size Uploaded
gassist_text-0.1.0.tar.gz 27.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gassist-text 0.1.0
File Interpreter ABI Platform
gassist_text-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 54.9 kB

Release files / gassist_text-0.1.0.tar.gz

Download URL gassist_text-0.1.0.tar.gz
Size 27.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a3629574bbb99126ed9a489bc47d006e7052fc90fb61bb4ddcd5bb0be704aa0e
BLAKE2b-256 checksum
How to use checksums
33d23b2b1f4a8f11a1640209dab8564314cec90bd52dc0d936f319ca386e25fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release files / gassist_text-0.1.0-py3-none-any.whl

Download URL gassist_text-0.1.0-py3-none-any.whl
Size 27.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5bb82d7384f10636a452b6b805b67cada7d91a2e4ea35af1cb141f94eeb144a8
BLAKE2b-256 checksum
How to use checksums
357047efa79006105d4817b819194de59ad7b8be48d36a8d32c25d495517ca4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page