Skip to content

aaronkao/clay-outreach-bot

Repository files navigation

Clay Outreach Bot

A FastAPI-powered backend for generating highly personalized, research-driven business development emails using real-time company news, case studies, and AI summarization. Deployable to Google Cloud Run with Docker and GitHub Actions, with secrets managed via Google Secret Manager.

Features

  • Company News Aggregation:
    • Fetches recent news headlines using DuckDuckGo or Google Custom Search.
    • Crawls news article URLs and extracts their content as markdown.
  • Case Study Context:
    • Integrates with Pinecone to retrieve relevant case studies and context for a given company or query.
  • AI Summarization:
    • Uses OpenAI's GPT models to summarize news and generate outreach emails.
  • Reranking:
    • Uses Pinecone’s reranker to prioritize the most relevant news and case study content.
  • API Endpoints:
    • /chat: Main endpoint for generating a business development email based on a company name or query.
    • /: Serves a static HTML frontend for quick testing.

Setup

1. Clone the Repository

git clone https://github.com/aaronkao/clay-outreach-bot.git
cd clay-outreach-bot

2. Install Dependencies

It is recommended to use uv or pip:

uv pip install -r requirements.txt
# or
pip install -r requirements.txt

3. Environment Variables

Create a .env file in the project root with the following variables:

OPENAI_API_KEY=your-openai-api-key
PINECONE_API_KEY=your-pinecone-api-key
PINECONE_ASSISTANT_NAME=your-pinecone-assistant-name
GOOGLE_API_KEY=your-google-api-key
CSE_ID=your-google-custom-search-engine-id
GOOGLE_SEARCH_URL=https://www.googleapis.com/customsearch/v1

4. Run the Server Locally

uvicorn main:app --reload

Or with Docker

docker build -t clay-outreach-bot .
docker run --env-file .env -p 8000:8000 clay-outreach-bot

Deployment

  • GitHub Action is setup to run manually or pushing to master.
  • Pipeline builds Docker image, uploads to Container Reigstry, and deploys to Cloud Run.
  • See .github/workflows/ for workflow YAMLs.

Secret Management

  • Store API keys and secrets in Google Secret Manager.
  • Grant Cloud Run service account access to secrets.
  • Reference secrets as environment variables in Cloud Run settings.

Usage

The response will be a generated business development email tailored to the company, using recent news and verified case studies.

/chat Endpoint (Local)

Send a POST request to /chat with a JSON body:

curl -X POST "http://127.0.0.1:8000/chat" -H "Content-Type: application/json" -d '{"message": "Morgan Stanley"}'          

/chat Endpoint (Cloud Run)

Replace YOUR_CLOUD_RUN_URL with your deployed URL:

curl -X POST "https://YOUR_CLOUD_RUN_URL/chat" \
  -H "Content-Type: application/json" \
  -d '{"message": "Morgan Stanley"}'

Frontend

Visit http://127.0.0.1:8000/ (or your Cloud Run URL) to use the static HTML frontend.

File Overview

  • main.py: FastAPI app and main orchestration logic.
  • crawler_utils.py: Utilities for crawling URLs, searching news, and summarizing content.
  • rerank_utils.py: Pinecone reranking utilities.
  • frontend.html: Static HTML frontend for quick testing.
  • requirements.txt: Python dependencies.
  • .env: Environment variables (not committed).
  • Dockerfile: Containerization for deployment.
  • .github/workflows/: GitHub Actions CI/CD workflows.

Development Notes

  • Ensure all API keys are valid and have sufficient quota.
  • The project uses async functions for crawling and summarization.
  • Extend crawler_utils.py to add more search/crawling providers if needed.

License

Apache 2.0

About

Clay outreach service that creates contextually relevant outbound email messages

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors