Google Chat
Your agent answers as a Google Chat app. Google Chat sends each message to the agent’s webhook, and VirtuAI posts the answer back through the Google Chat API.
Before you start
Section titled “Before you start”- A workspace role that can edit Settings and Agents
- A Google Cloud project with the Google Chat API enabled, and permission to configure a Chat app in your Google Workspace
- A service account in that project, with a JSON key
- An agent already created in VirtuAI. See Create your first agent.
1. Add the service account
Section titled “1. Add the service account”Open Settings and select Channels. Under Google Chat, add the service account’s JSON key in Chat app service account (GOOGLE_CHAT_SERVICE_ACCOUNT_JSON). VirtuAI uses it to post replies and to download attachments. Test connection checks it.
Then check Project number (GOOGLE_CHAT_PROJECT_NUMBER), the number of the Google Cloud project where the Chat app is configured. It’s required: VirtuAI verifies every request against it and refuses with 401 any request from Google Chat that it can’t verify, so without it the agent never answers in Google Chat (see step 6).
- When you save the service account JSON, VirtuAI looks up the project number and fills it in. The lookup needs the service account to have the
resourcemanager.projects.getpermission on its project, for example through the Browser role (roles/browser). - If the setting is still empty after saving, the service account can’t read its project. Type the number yourself: it’s shown as Project number on the project’s dashboard in the Google Cloud console. The lookup runs only when the JSON changes, so saving the same JSON again doesn’t repeat it.
The service account must belong to the same project as the Chat app.
Optionally, change what people see while the agent works:
| Setting | What it does |
|---|---|
Message while the agent works (GOOGLE_CHAT_WAITING_MESSAGE) |
The text of the waiting message. The default is “Analyzing — this can take a few minutes”. |
Working animation (WAITING_ANIMATION_URL) |
An image or animated GIF shown as a small icon beside the waiting message. The same setting applies to every channel. When empty, the default animation is shown. |
2. Turn on Google Chat for the agent
Section titled “2. Turn on Google Chat for the agent”Open the agent and select its Channels tab. Make sure Google Chat is on. It’s on by default, and the card reads Answers in Google Chat spaces. With versioning, this switch waits for Publish. Choose the agent’s model in its Model tab.
Select Check Chat app setup on the Google Chat card. It checks the workspace’s service account and project number, and says what’s missing, for example “set the Chat app’s project number in Settings, Channels”. When the setup is complete, the card reads Connected.
3. Copy the webhook URL
Section titled “3. Copy the webhook URL”Copy the Webhook URL from the Google Chat card, or Google Chat Webhook under Integration URLs at the bottom of the Channels tab. It looks like this and belongs to this agent only:
https://<your-virtuai-host>/googlechat/webhook/<agent-id>4. Configure the Chat app
Section titled “4. Configure the Chat app”In the Google Cloud console, open the Google Chat API configuration for your project:
- Give the app a name, avatar and description.
- Under connection settings, choose an HTTP endpoint and paste the webhook URL.
- Set Authentication audience to Project number. VirtuAI only accepts requests whose token is issued for your project number.
- Choose who in your Google Workspace can find and use the app.
- Save.
5. Add slash commands (optional)
Section titled “5. Add slash commands (optional)”The agent understands six commands. To make them show up in Google Chat’s command menu, add them in the Chat API configuration with these command IDs:
| Command | Command ID | What it does |
|---|---|---|
/new [title] |
1 | Starts a new conversation, with an optional title |
/resume |
2 | Lists your last 5 conversations. /resume 2 switches to the second one. |
/status |
3 | Tells you whether the agent is still working, and for how long |
/cancel |
4 | Stops the running task |
/help |
5 | Lists the commands |
/compact |
6 | Summarizes the older messages so the conversation can keep going when the model’s context fills up. The agent suggests it from 80%. It also works typed as a plain message. |
6. Check request verification
Section titled “6. Check request verification”Google Chat signs every request it sends to your app with a token issued for your project. VirtuAI checks that token against GOOGLE_CHAT_PROJECT_NUMBER and rejects with 401 any request that doesn’t carry a valid token for that project. If you run the app as a Google Workspace add-on, VirtuAI checks that the request comes from your project’s add-on service agent instead, and there is nothing else to configure.
A request VirtuAI can’t verify is never answered: one without a valid token, or any request while the workspace has no project number. Before you go live, check that:
- Project number (
GOOGLE_CHAT_PROJECT_NUMBER) is set in Settings > Channels. Check Chat app setup on the agent’s Google Chat card reads Connected when it is. - The Chat app’s Authentication audience is Project number.
Google Chat doesn’t use integration keys: Google’s token replaces them.
7. Test
Section titled “7. Test”- Message the app directly and send a greeting.
- Ask a real business question.
- Add the app to a space, mention it with
@, and ask again. - Check that the conversation appears in Conversations.
How messages behave
Section titled “How messages behave”- Waiting message. The app first posts the waiting message. While a deep agent works, it shows one card with the plan and each step, updated in place.
- Conversations. Each person has their own conversation with each agent in each space or direct message, so two agents in the same space never share one. Use
/newto start fresh. - Busy agent. If you write while a deep agent is still working, the app answers “✉️ Got it — I’ll respond once I finish your current request.” and handles your message next.
- Replies to messages. When you reply to or quote a message, the quoted text is sent to the agent as context.
- Files you send. With a deep agent, each attachment goes into the agent’s working folder, under
uploads/, where the agent runs commands, so it can open and work on it. Images and PDFs also go to the model itself when it can read them. Drive files are shared as links, not attachments, so the app can’t receive them and says so with “⚠️ Could not receive: …”. Other agents get text and audio only. See Files and voice notes. - Files while the agent is busy. A file sent while a deep agent is still working isn’t queued. The app answers “📎 Still working on your previous request. Send the file again when it is done.”
- Files from the agent. Each file the agent shares arrives as its own card, with the file’s name and size and a Download button.
- Audio. A Gemini model hears audio attachments as they are. For any other model, they’re transcribed and the agent gets your words.
- Thinking and web searches. When the model thinks or searches the web, the card shows it as steps, with a light bulb for a thought and a globe for a search, as web chat does.
- Your accounts. If the sender’s Google email matches a member of your VirtuAI workspace, the agent uses that member’s connected accounts, for example their Gmail or Drive.
- Budgets. If the workspace has run out of budget, the app replies with the budget message instead of an answer.
- Approvals. When a deep agent wants to run a command, or use a tool that needs approval, it posts a card in the space, Run this command? or Use the tool name, with what it would run and the same answers as web chat: Allow once, This conversation, 60 min, Always and Deny. Nothing runs until you answer. Only the person whose message started the task can answer: if someone else in the space clicks, only they see “Only the person who asked for this can approve or deny it.”, and the buttons stay. Once answered, the buttons are replaced by who answered and for how long, for example “Approved by Ana — for this conversation”. This conversation stops asking in this space, 60 min for the next hour, and Always stops asking you about this agent’s commands and tools in Google Chat until someone who can edit the agent revokes it, under Standing approvals in the agent’s Security tab. Each covers you only, on Google Chat only. Other cards already waiting that the answer covers are approved too, and say which answer approved them. An approval you gave in web chat also counts here when your Google email matches your VirtuAI account. With no answer within 10 minutes, the request expires, the card says “Expired with no answer: nothing was run.”, and nothing is run.
- Your browser. When the agent uses the workspace’s Browser and a step needs you (a captcha, a sign-in, a two-step code, an approval), it sends you a link to your own browser desktop, which opens after you sign in to VirtuAI. See Sandboxes.
- Reminders. With the reminder tools attached to the agent, you can ask it to remind you of something, once or daily, weekly or monthly. The agent reminds you in the same space or direct message. Times are in the workspace’s time zone, and due reminders go out every few minutes (every 5 minutes by default). See Predefined tools.
- Channel off. If Google Chat is off for the agent, the app replies “This agent is not available on Google Chat.”
Troubleshooting
Section titled “Troubleshooting”No reply in Google Chat : Check the Chat app service account and the Project number in Settings > Channels, that Google Chat is on for the agent (and published, with versioning), and that the app’s endpoint is this agent’s webhook URL. Then check request verification.
Requests are rejected with 401
: VirtuAI couldn’t verify the request. Check that Project number (GOOGLE_CHAT_PROJECT_NUMBER) is set in Settings > Channels and is the number of the project where the Chat app is configured, and that the Chat app’s Authentication audience is Project number, not HTTP endpoint URL. Check Chat app setup on the agent’s Google Chat card says what’s missing.
The waiting message appears, but no answer follows : The agent failed while working. Check the agent’s model and tools in web chat, then look at the conversation in Conversations.
Authentication or permission errors when posting : The service account must belong to the project where the Chat app is configured.
The wrong agent replies : The app’s endpoint has another agent’s ID. Copy the URL again from the right agent’s Integration URLs.
