Google API
Every handle of the Google fake: the google fixture, the people and objects a test creates on it, and what they read and wait for. How to test a Google app or agent, step by step, is in the Google guide.
Each call is shown in every SDK's language, with its required options (the table under it lists them all). Arguments go first; options are TypeScript's trailing object, Python's keyword arguments and Rust's builder setters. The variable names are the ones the calls return elsewhere on these pages, so user is a GoogleUser handle.
Besides the errors listed with each method, most methods can fail with action_requires, cross_workspace_credential, fake_actor_in_live_world, internal, invalid_argument, live_misconfigured, live_not_allowlisted, not_found, session_not_found, unauthorized, unsupported_in_live: a bad request, a closed session, or live mode refusing or misconfigured.
GoogleFixture#
Returned by Session.google().
| Field | Python / Rust | Type |
|---|---|---|
app | app | GoogleApp |
apiUrl | api_url | string |
createApp()#
Make another app: a mailbox of its own, with its own address and credentials (decision 0027), or return the one made with this name and settings. Its events go to CHANNELSTACK_GOOGLE_APP_<NAME>_WEBHOOK_URL.
const app = await google.createApp({ name: "…" });app = await google.create_app(name="…")let app = google.create_app().name("…").await?;| Parameter | Type | Required | |
|---|---|---|---|
name | string | yes | option |
Returns GoogleApp.
Live: refused with unsupported_in_live: Live, each app is a sandbox app set up by hand, and this channel has no second one yet (decision 0027).
apps()#
The mailboxs this session used: the agent's first, then each it got from createApp, in the order it first did. Another session's are not_found here.
const apps = await google.apps();apps = await google.apps()let apps = google.apps().await?;Returns GoogleApps.
createUser()#
Create a person: a mailbox, at <name>@example.com unless a test gives the address.
const user = await google.createUser({ name: "…" });user = await google.create_user(name="…")let user = google.create_user().name("…").await?;| Parameter | Type | Required | |
|---|---|---|---|
name | string | yes | option |
address | string | no | option |
token | string | no | option; read from CHANNELSTACK_GOOGLE_USER_{name}_TOKEN when left out |
Returns GoogleUser.
users()#
The people this session created.
const users = await google.users();users = await google.users()let users = google.users().await?;Returns GoogleUsers.
threads()#
The threads this session's people started, oldest first.
const threads = await google.threads();threads = await google.threads()let threads = google.threads().await?;Returns GoogleThreads.
deliveries()#
Every push channelstack sent the agent for this session, with every attempt.
const deliveries = await google.deliveries({ type: "…" });deliveries = await google.deliveries(type="…")let deliveries = google.deliveries().r#type("…").await?;| Parameter | Python / Rust | Type | Required | |
|---|---|---|---|---|
type | type · r#type | string | no | option |
resource | resource | GoogleThread | no | option |
app | app | GoogleApp | no | option |
Returns GoogleDeliveries.
Live: refused with unsupported_in_live: Live, the platform delivers to the agent itself and channelstack isn't in the path (delivery chaos is fake-only).
calls()#
The Gmail calls the agent made about this session's mail, by the SDK's method name (users.messages.send).
const apiCalls = await google.calls({ operation: "…" });api_calls = await google.calls(operation="…")let api_calls = google.calls().operation("…").await?;| Parameter | Type | Required | |
|---|---|---|---|
operation | string | no | option |
error | true | string | no | option |
Returns GoogleApiCalls.
Live: needs proxy mode: Gmail doesn't report the mailbox's calls; proxy mode sees them. Proxy mode doesn't read the app's calls back live yet (#24), so for now the call is refused with action_requires and the test is skipped.
waitForCall()#
Waits for the next API call from the agent after the last one this handle returned: it polls calls() and never sleeps longer than it must.
const apiCall = await google.waitForCall({ operation: "…" });api_call = await google.wait_for_call(operation="…")let api_call = google.wait_for_call().operation("…").await?;| Parameter | Type | Required | |
|---|---|---|---|
operation | string | no | filter |
error | true | string | no | filter |
timeout | Duration | no | default 10s |
Returns GoogleApiCall. When the time is up, it fails with what it was waiting for.
GoogleApp#
Returned by GoogleFixture.createApp().
| Field | Python / Rust | Type |
|---|---|---|
id | id | string |
channel | channel | "google" |
kind | kind | "app" |
name | name | string |
botUserId | bot_user_id | string |
address | address | string |
clientId | client_id | string |
clientSecret | client_secret | string |
refreshToken | refresh_token | string |
send()#
An app a test made sends an email, through its own mailbox's API, as its own call would.
const email = await app.send({ to, subject: "…" });email = await app.send(to=to, subject="…")let email = app.send().to(to).subject("…").await?;| Parameter | Type | Required | |
|---|---|---|---|
to | Array<GoogleUser | GoogleApp> | yes | option |
cc | Array<GoogleUser | GoogleApp> | no | option |
subject | string | yes | option |
text | string | no | option |
html | string | no | option |
headers | Record<string, string> | no | option |
Returns GoogleEmail.
Live: refused with unsupported_in_live: Live, each app is a sandbox app set up by hand, and this channel has no second one yet (decision 0027).
reply()#
An app a test made replies to an email, in its thread, as its own call would.
const result = await app.reply(email, { text: "…" });result = await app.reply(email, text="…")let result = app.reply(&email).text("…").await?;| Parameter | Type | Required | |
|---|---|---|---|
email | GoogleEmail | yes | positional |
text | string | no | option |
html | string | no | option |
all | boolean | no | option |
headers | Record<string, string> | no | option |
Returns GoogleEmail.
Live: refused with unsupported_in_live: Live, each app is a sandbox app set up by hand, and this channel has no second one yet (decision 0027).
GoogleEmail#
Returned by GoogleApp.send(), GoogleApp.reply(), GoogleEmail.refresh(), GoogleUser.send().
| Field | Python / Rust | Type |
|---|---|---|
id | id | string |
channel | channel | "google" |
thread | thread | GoogleThread |
author | author | GooglePrincipal |
from | from_ · from | string |
to | to | string[] |
cc | cc | string[] |
subject | subject | string |
text | text | string |
at | at | string |
messageId | message_id | string |
headers | headers | Record<string, string> |
labels | labels | string[] |
delivery | delivery | GoogleDelivery | undefined |
refresh()#
Re-read an email.
const updated = await email.refresh();updated = await email.refresh()let updated = email.refresh().await?;Returns GoogleEmail.
deliveryFor()#
The delivery that told this app of the email (decision 0027), or nothing when it wasn't told.
const delivery = await email.deliveryFor(app);delivery = await email.delivery_for(app)let delivery = email.delivery_for(&app).await?;| Parameter | Type | Required | |
|---|---|---|---|
app | GoogleApp | yes | positional |
Returns GoogleDelivery | undefined.
Live: refused with unsupported_in_live: Live, the platform delivers to the agent itself and channelstack isn't in the path (delivery chaos is fake-only).
GoogleThread#
| Field | Type |
|---|---|
id | string |
channel | "google" |
subject | string |
messages()#
Every email in the thread, oldest first.
const messages = await thread.messages();messages = await thread.messages()let messages = thread.messages().await?;Returns GoogleMessages.
replies()#
The thread's answers: every email after the first, oldest first.
const replies = await thread.replies();replies = await thread.replies()let replies = thread.replies().await?;Returns GoogleReplies.
transcript()#
The thread as a person reads it: each email's own words, without the quoted history.
const transcript = await thread.transcript();transcript = await thread.transcript()let transcript = thread.transcript().await?;Returns GoogleTranscript.
waitForReply()#
Waits for the next reply after the last one this handle returned: it polls replies() and never sleeps longer than it must.
const email = await thread.waitForReply({ from: "my-agent" });email = await thread.wait_for_reply(from_="my-agent")let email = thread.wait_for_reply().from("my-agent").await?;| Parameter | Python / Rust | Type | Required | |
|---|---|---|---|---|
from | from_ · from | GooglePrincipal | string | no | a handle, or a name |
timeout | timeout | Duration | no | default 10s |
Returns GoogleEmail. When the time is up, it fails with what it was waiting for.
latestReply()#
The latest reply, once the app is quiet. Waits for at least one: it polls replies() and never sleeps longer than it must.
const email = await thread.latestReply({ from: "my-agent" });email = await thread.latest_reply(from_="my-agent")let email = thread.latest_reply().from("my-agent").await?;| Parameter | Python / Rust | Type | Required | |
|---|---|---|---|---|
from | from_ · from | GooglePrincipal | string | no | a handle, or a name |
timeout | timeout | Duration | no | default 10s |
quietFor | quiet_for | Duration | no | default 750ms |
Returns GoogleEmail. When the time is up, it fails with what it was waiting for.
GoogleDelivery#
Returned by GoogleEmail.deliveryFor(), GoogleDelivery.refresh().
| Field | Python / Rust | Type |
|---|---|---|
id | id | string |
channel | channel | "google" |
app | app | string |
type | type · r#type | string |
emailAddress | email_address | string |
historyId | history_id | string |
payload | payload | unknown | undefined |
attempts | attempts | DeliveryAttempt[] |
status | status | "pending" | "acknowledged" | "failed" | "timed_out" | "unreachable" |
refresh()#
Re-read a delivery: its attempts and status.
const updated = await delivery.refresh();updated = await delivery.refresh()let updated = delivery.refresh().await?;Returns GoogleDelivery.
Live: refused with unsupported_in_live: Live, the platform delivers to the agent itself and channelstack isn't in the path (delivery chaos is fake-only).
redeliver()#
Push the same message again, as Pub/Sub does when a push isn't acknowledged: the same message id.
const deliveryAttempt = await delivery.redeliver();delivery_attempt = await delivery.redeliver()let delivery_attempt = delivery.redeliver().await?;Returns DeliveryAttempt.
Live: refused with unsupported_in_live: Pub/Sub has no API to push an acknowledged message again.
resend()#
Push it again, forged: with a token signed by another key, one that has expired, or one for another audience than the push endpoint.
const deliveryAttempt = await delivery.resend({ badSignature });delivery_attempt = await delivery.resend(bad_signature=bad_signature)let delivery_attempt = delivery.resend().bad_signature(bad_signature).await?;| Parameter | Python / Rust | Type | Required | |
|---|---|---|---|---|
badSignature | bad_signature | boolean | no | option |
stale | stale | boolean | no | option |
wrongAudience | wrong_audience | boolean | no | option |
Returns DeliveryAttempt.
Live: refused with unsupported_in_live: Live, the platform delivers to the agent itself and channelstack isn't in the path (delivery chaos is fake-only).
settled()#
Waits for the delivery to settle: it polls refresh() and never sleeps longer than it must.
const updated = await delivery.settled();updated = await delivery.settled()let updated = delivery.settled().await?;| Parameter | Type | Required | |
|---|---|---|---|
timeout | Duration | no | default 10s |
Returns GoogleDelivery. When the time is up, it fails with what it was waiting for.
GoogleUser#
Returned by GoogleFixture.createUser().
| Field | Type |
|---|---|
id | string |
channel | "google" |
kind | "user" |
name | string |
address | string |
send()#
The person emails someone: the agent (google.app), another app, or another person.
const email = await user.send({ to, subject: "…" });email = await user.send(to=to, subject="…")let email = user.send().to(to).subject("…").await?;| Parameter | Type | Required | |
|---|---|---|---|
to | Array<GoogleUser | GoogleApp> | yes | option |
cc | Array<GoogleUser | GoogleApp> | no | option |
subject | string | yes | option |
text | string | no | option |
html | string | no | option |
Returns GoogleEmail.
reply()#
The person replies to an email, in its thread: Re: its subject, with In-Reply-To and References.
const result = await user.reply(email, { text: "…" });result = await user.reply(email, text="…")let result = user.reply(&email).text("…").await?;| Parameter | Type | Required | |
|---|---|---|---|
email | GoogleEmail | yes | positional |
text | string | no | option |
html | string | no | option |
all | boolean | no | option |
Returns GoogleEmail.
inbox()#
What reached the person's mailbox, oldest first.
const inbox = await user.inbox();inbox = await user.inbox()let inbox = user.inbox().await?;Returns GoogleInbox.
waitForEmail()#
Waits for the next email after the last one this handle returned: it polls inbox() and never sleeps longer than it must.
const email = await user.waitForEmail({ from: "my-agent" });email = await user.wait_for_email(from_="my-agent")let email = user.wait_for_email().from("my-agent").await?;| Parameter | Python / Rust | Type | Required | |
|---|---|---|---|---|
from | from_ · from | GooglePrincipal | string | no | a handle, or a name |
timeout | timeout | Duration | no | default 10s |
Returns GoogleEmail. When the time is up, it fails with what it was waiting for.
Types#
Plain values the handles return and take.
GoogleApps#
type GoogleApps = GoogleApp[];
GooglePrincipal#
| Field | Type |
|---|---|
id | string |
name | string |
kind | "user" | "app" |
GoogleUsers#
type GoogleUsers = GoogleUser[];
GoogleThreads#
type GoogleThreads = GoogleThread[];
GoogleInbox#
type GoogleInbox = GoogleEmail[];
GoogleMessages#
type GoogleMessages = GoogleEmail[];
GoogleReplies#
type GoogleReplies = GoogleEmail[];
GoogleTranscript#
| Field | Type |
|---|---|
entries | GoogleTranscriptEntry[] |
text | string |
GoogleTranscriptEntry#
| Field | Type |
|---|---|
id | string |
author | GooglePrincipal |
at | string |
text | string |
controls | string[] |
edited | boolean |
depth | number |
GoogleDeliveries#
type GoogleDeliveries = GoogleDelivery[];
GoogleApiCalls#
type GoogleApiCalls = GoogleApiCall[];
GoogleApiCall#
| Field | Python / Rust | Type |
|---|---|---|
id | id | string |
channel | channel | "google" |
operation | operation | string |
method | method | string |
path | path | string |
at | at | string |
durationMs | duration_ms | number |
request | request | unknown | undefined |
responseStatus | response_status | number |
response | response | unknown | undefined |
error | error | string | undefined |