A Gmail API mock for drafting customer replies.

Your agent answers the seeded SOC 2 request, labels the thread Follow up and saves a follow-up draft. Check the sent reply, the thread label and its draft count.

Connect your agent
The test
  • followed_up

    thread of soc2; label Follow up; drafts at least 1

  • answered

    message label SENT; in thread of soc2; text contains SOC 2

Starting records

  • mailboxes / Acme Support / messages

    ref
    soc2
    from
    Grace Lin <grace.lin@bluefield-logistics.example>
    to
    Acme Support <support@acme.example>
  • mailboxes / Acme Support / messages

    ref
    sso_question
    subject
    SSO and user provisioning
    from
    Grace Lin <grace.lin@bluefield-logistics.example>
  • mailboxes / Acme Support / messages

    ref
    sso_answer
    from
    Acme Support <support@acme.example>
    to
    Grace Lin <grace.lin@bluefield-logistics.example>
  • mailboxes / Acme Support / messages

    ref
    pricing
    subject
    Pricing for a small analytics team
    from
    Lucy Grant <lucy.grant@harbor-foods.example>

Connect your agent to the Gmail mock

When ancha runs your agent, it sets:

  • GMAIL_API_URL
  • GMAIL_ACCESS_TOKEN
  • GMAIL_ADDRESS

Point the client you already use at them.

import { auth, gmail } from '@googleapis/gmail';
const oauth = new auth.OAuth2();
oauth.setCredentials({ access_token: process.env.GMAIL_ACCESS_TOKEN });
const mail = gmail({ version: 'v1', auth: oauth });
const options = { rootUrl: process.env.GMAIL_API_URL + '/', retry: false };
const { data } = await mail.users.messages.list({ userId: 'me', q: 'is:unread' }, options);

Locally, ancha runs your agent as an ordinary process, so keep real Gmail credentials out of its environment.

See all 37 endpoints

GET/.well-known/openid-configuration

gmail

GET/gmail/v1/users/:userId/drafts
POST/gmail/v1/users/:userId/drafts
GET/gmail/v1/users/:userId/drafts/:id
PUT/gmail/v1/users/:userId/drafts/:id
DELETE/gmail/v1/users/:userId/drafts/:id
POST/gmail/v1/users/:userId/drafts/send
GET/gmail/v1/users/:userId/history
GET/gmail/v1/users/:userId/labels
POST/gmail/v1/users/:userId/labels
GET/gmail/v1/users/:userId/labels/:id
PATCH/gmail/v1/users/:userId/labels/:id
DELETE/gmail/v1/users/:userId/labels/:id
GET/gmail/v1/users/:userId/messages
GET/gmail/v1/users/:userId/messages/:id
POST/gmail/v1/users/:userId/messages/:id/modify
POST/gmail/v1/users/:userId/messages/:id/trash
POST/gmail/v1/users/:userId/messages/:id/untrash
GET/gmail/v1/users/:userId/messages/:messageId/attachments/:id
POST/gmail/v1/users/:userId/messages/batchModify
POST/gmail/v1/users/:userId/messages/send
GET/gmail/v1/users/:userId/profile
GET/gmail/v1/users/:userId/settings/filters
POST/gmail/v1/users/:userId/settings/filters
GET/gmail/v1/users/:userId/settings/filters/:id
DELETE/gmail/v1/users/:userId/settings/filters/:id
GET/gmail/v1/users/:userId/settings/forwardingAddresses
GET/gmail/v1/users/:userId/settings/sendAs
GET/gmail/v1/users/:userId/settings/sendAs/:sendAsEmail
POST/gmail/v1/users/:userId/stop
GET/gmail/v1/users/:userId/threads
GET/gmail/v1/users/:userId/threads/:id
POST/gmail/v1/users/:userId/threads/:id/modify
POST/gmail/v1/users/:userId/threads/:id/trash
POST/gmail/v1/users/:userId/threads/:id/untrash
POST/gmail/v1/users/:userId/watch

oauth2

GET/oauth2/v2/userinfo

Seed your own data

The data the Gmail mock starts with on every run, cut to a few records. ancha twins seed gmail prints every field.

Full seed YAML
twins:
  - gmail
seed:
  gmail:
    agent: support@acme.example
    mailboxes:
      - address: support@acme.example
        name: Acme Support
        labels:
          - name: Follow up
            color:
              text_color: "#ffffff"
              background_color: "#fb4c2f"
        messages:
          - ref: sso_question
            from: Grace Lin <grace.lin@bluefield-logistics.example>
            subject: SSO and user provisioning
            body: |-
              Hi Acme team,

              Before we roll Acme out to our dispatch teams: does it support SAML single sign-on with Okta? And can users be provisioned and deprovisioned through SCIM?

              Thanks,
              Grace Lin
              IT Security Lead, Bluefield Logistics
            at: -31h
          - ref: sso_answer
            from: Acme Support <support@acme.example>
            to: Grace Lin <grace.lin@bluefield-logistics.example>
            in_reply_to: sso_question
            body: |-
              Hi Grace,

              SSO with Okta works today; our setup guide covers the SAML app. SCIM provisioning is planned for Q1 and is not available yet.

              Best,
              Laura Kim
              Acme Customer Success
            at: -29h40m
            labels:
              - SENT
          - ref: pricing
            from: Lucy Grant <lucy.grant@harbor-foods.example>
            subject: Pricing for a small analytics team
            body: |-
              Hi,

              We are a team of six analysts at Harbor Foods looking at Acme for our production dashboards. What would the Team plan cost for us, and is there a trial?

              Thanks,
              Lucy Grant
            at: -20h
          - ref: soc2
            from: Grace Lin <grace.lin@bluefield-logistics.example>
            to: Acme Support <support@acme.example>
            in_reply_to: sso_answer
            body: |-
              Thanks, Laura. One more thing: our security team needs your SOC 2 Type II report before we can sign. Could you send it over?

              Grace
            at: -8h30m
        drafts:
          - ref: pricing_draft
            to: Lucy Grant <lucy.grant@harbor-foods.example>
            in_reply_to: pricing
            body: |+
              Hi Lucy,

              Thanks for reaching out. The Team plan covers up to ten analysts, and we offer a 14-day trial with your own data.

            at: -19h

Check what your agent did

Checks YAML
checks:
  - id: followed_up
    state:
      gmail.thread:
        of: soc2
        label: Follow up
        drafts_gte: 1
  - id: answered
    state:
      gmail.message:
        label: SENT
        in_thread_of: soc2
        text_contains: SOC 2

Tested together

All 43 tools

Gmail API mock FAQ

How can I test a Gmail agent that saves a reply as a draft?

Create the draft through POST /gmail/v1/users/:userId/drafts with the email encoded as base64url in message.raw. Include message.threadId and a matching subject to place the draft in an existing conversation, then retrieve it through /gmail/v1/users/:userId/drafts/:id.

Can the Gmail mock find unread messages with attachments?

Use q=is:unread has:attachment when listing messages; Ancha checks the UNREAD label and parsed attachments. Combine that query with subject: or filename: to narrow the results.

Does changing a Gmail thread label affect every message in that conversation?

POST /gmail/v1/users/:userId/threads/:id/modify applies addLabelIds and removeLabelIds to each message currently in the thread. Read the thread again to inspect each message's labels.

Install the CLI and run your agent against the Gmail mock.

Book a demo

Ancha is not affiliated with Gmail.