Prompt

How do I connect an AI agent to Slack and Gmail?

Artificial Intelligence / AI Agents1 observationLast seen Oct 9, 2026

Latest observation

Oct 9, 2026OpenAI APIWeb search: off

To connect an AI agent to Slack and Gmail, you generally need to give the agent access through each product’s API, then define what actions it’s allowed to take.

High-level approach

  1. Create app credentials

    • Slack: create a Slack App and use a bot token.
    • Gmail: use Google Cloud / Gmail API with OAuth credentials.
  2. Authenticate the agent

    • Store the tokens securely.
    • Use OAuth for user-delegated access, especially for Gmail.
  3. Expose tools/actions to the agent

    • Slack: send messages, read channels, search messages, reply in threads.
    • Gmail: read inbox, search emails, draft replies, send emails.
  4. Connect those tools to your AI agent

    • If you’re using an agent framework, register these API calls as “tools.”
    • The model decides when to call them, and your code executes them.

Slack setup

1) Create a Slack App

  • Go to the Slack API dashboard.
  • Create a new app.
  • Add a Bot User.

2) Add required scopes

Common scopes:

  • chat:write — send messages
  • channels:read — list public channels
  • channels:history — read public channel history
  • groups:read / groups:history — private channels if needed
  • im:read, im:history — direct messages
  • users:read — user info

3) Install the app to your workspace

  • Use OAuth to install the app.
  • Save the bot token.

4) Use Slack API / SDK

Example actions:

  • chat.postMessage
  • conversations.history
  • conversations.replies

Gmail setup

1) Create a Google Cloud project

  • Enable the Gmail API.

2) Configure OAuth consent screen

  • Add your app name, scopes, and test users.

3) Create OAuth client credentials

  • Typically a web app or desktop app client ID.

4) Request Gmail scopes

Common scopes:

  • https://www.googleapis.com/auth/gmail.readonly
  • https://www.googleapis.com/auth/gmail.send
  • https://www.googleapis.com/auth/gmail.modify

5) Authenticate with OAuth

  • The user logs in with Google and approves access.
  • Store the access/refresh tokens securely.

How to wire this into an AI agent

Your agent framework should have tools like:

  • send_slack_message(channel, text)
  • read_slack_thread(channel, ts)
  • search_gmail(query)
  • draft_gmail_reply(message_id, text)
  • send_gmail(to, subject, body)

The agent:

  1. Receives a user request.
  2. Chooses a tool.
  3. Your backend executes the API call.
  4. The result is returned to the model.
  5. The model responds to the user.

Security best practices

  • Use OAuth, not hardcoded passwords.
  • Limit scopes to only what you need.
  • Keep tokens in a secrets manager.
  • Log carefully; avoid exposing email contents or Slack messages unnecessarily.
  • Add approval steps for risky actions like sending emails or posting messages.
  • If the agent is autonomous, set guardrails:
    • allowed channels
    • allowed recipients
    • approval required before sending

Example architecture

  • Frontend: chat UI for the user
  • Agent orchestrator: LLM + tool calling
  • Slack connector: Slack API client
  • Gmail connector: Google API client
  • Database: store conversations, token metadata, and audit logs
  • Secrets manager: store OAuth tokens securely

If you want a quick implementation path

  • Use Slack Bolt for Slack integration.
  • Use Google API client libraries for Gmail.
  • Use an agent framework like:
    • OpenAI Agents / tool calling
    • LangChain
    • LlamaIndex
    • CrewAI

Minimal pseudo-flow

User: “Summarize my unread Gmail and post it to #team-updates.”

Agent:
1. Calls Gmail tool to fetch unread messages.
2. Summarizes them.
3. Calls Slack tool to post summary to #team-updates.
4. Confirms completion.

If you want, I can give you:

  1. a Python example for Slack + Gmail integration, or
  2. a step-by-step setup guide for one specific framework.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.