README.md
  1  # ๐Ÿ“Š AI Revenue Intelligence
  2  
  3  > **Prove content ROI, extract call intelligence, and generate client reports โ€” automatically.**
  4  
  5  An AI-powered revenue intelligence suite that connects the dots between sales calls, content performance, and closed deals. These tools pull from Gong, GA4, HubSpot, and Ahrefs to answer the questions every marketing team hates: "What content actually drove revenue?" and "What are prospects really saying on calls?"
  6  
  7  Built in production at [Single Grain](https://www.singlegrain.com/?utm_source=github&utm_medium=skill_repo&utm_campaign=ai_marketing_skills). Now open-sourced for any revenue-focused marketing team.
  8  
  9  ---
 10  
 11  ## Architecture
 12  
 13  ```
 14  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 15  โ”‚                        DATA SOURCES                                 โ”‚
 16  โ”‚                                                                     โ”‚
 17  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
 18  โ”‚  โ”‚   Gong    โ”‚  โ”‚   GA4    โ”‚  โ”‚ HubSpot  โ”‚  โ”‚     Ahrefs       โ”‚   โ”‚
 19  โ”‚  โ”‚  (calls)  โ”‚  โ”‚(traffic) โ”‚  โ”‚ (deals)  โ”‚  โ”‚    (SEO)         โ”‚   โ”‚
 20  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
 21  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
 22           โ”‚              โ”‚             โ”‚                โ”‚
 23           โ–ผ              โ”‚             โ”‚                โ”‚
 24  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚             โ”‚                โ”‚
 25  โ”‚  Gong-to-Insight โ”‚    โ”‚             โ”‚                โ”‚
 26  โ”‚    Pipeline      โ”‚    โ”‚             โ”‚                โ”‚
 27  โ”‚                  โ”‚    โ”‚             โ”‚                โ”‚
 28  โ”‚ โ€ข Objections     โ”‚    โ”‚             โ”‚                โ”‚
 29  โ”‚ โ€ข Buying signals โ”‚    โ”‚             โ”‚                โ”‚
 30  โ”‚ โ€ข Competitors    โ”‚    โ”‚             โ”‚                โ”‚
 31  โ”‚ โ€ข Content topics โ”‚    โ”‚             โ”‚                โ”‚
 32  โ”‚ โ€ข Follow-ups     โ”‚    โ”‚             โ”‚                โ”‚
 33  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚             โ”‚                โ”‚
 34         โ”‚                โ–ผ             โ–ผ                โ”‚
 35         โ”‚      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”            โ”‚
 36         โ”‚      โ”‚   Revenue Attribution     โ”‚            โ”‚
 37         โ”‚      โ”‚       Mapper              โ”‚            โ”‚
 38         โ”‚      โ”‚                           โ”‚            โ”‚
 39         โ”‚      โ”‚ โ€ข First-touch / linear /  โ”‚            โ”‚
 40         โ”‚      โ”‚   time-decay attribution  โ”‚            โ”‚
 41         โ”‚      โ”‚ โ€ข Content ROI by type     โ”‚            โ”‚
 42         โ”‚      โ”‚ โ€ข CPA calculations        โ”‚            โ”‚
 43         โ”‚      โ”‚ โ€ข Content gap analysis    โ”‚            โ”‚
 44         โ”‚      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ”‚
 45         โ”‚                  โ”‚                            โ”‚
 46         โ–ผ                  โ–ผ                            โ–ผ
 47  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 48  โ”‚              Client Report Generator                         โ”‚
 49  โ”‚                                                              โ”‚
 50  โ”‚  Executive Summary + Traffic + Pipeline + SEO + Call Quality โ”‚
 51  โ”‚  Anomaly Detection + Period-over-Period Comparison           โ”‚
 52  โ”‚  โ†’ Markdown or JSON output                                   โ”‚
 53  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
 54  ```
 55  
 56  ---
 57  
 58  ## Tools
 59  
 60  ### 1. ๐ŸŽ™๏ธ Gong-to-Insight Pipeline (`gong_insight_pipeline.py`)
 61  
 62  Turns sales call transcripts into structured intelligence. Works with the Gong API or plain `.txt` transcript files.
 63  
 64  **What it extracts:**
 65  - **Objections** โ€” categorized as pricing, timing, competition, authority, or need
 66  - **Buying signals** โ€” budget confirmed, timeline mentioned, decision maker engaged, champion identified
 67  - **Competitive mentions** โ€” which competitors were named and in what sentiment (positive/negative/neutral)
 68  - **Pricing discussions** โ€” dollar amounts, pricing model questions, ROI concerns
 69  - **Content topics** โ€” recurring objection patterns that should become blog posts, case studies, or battle cards
 70  - **Follow-up drafts** โ€” personalized outbound suggestions based on what happened on the call
 71  
 72  ```bash
 73  # Analyze a transcript file
 74  python gong_insight_pipeline.py --file transcript.txt
 75  
 76  # Analyze a directory of transcripts
 77  python gong_insight_pipeline.py --dir ./transcripts/ --content-topics
 78  
 79  # Pull from Gong API (last 7 days)
 80  python gong_insight_pipeline.py --gong --days 7
 81  
 82  # Full output with follow-ups
 83  python gong_insight_pipeline.py --file call.txt --follow-ups --output insights.json
 84  
 85  # Example output:
 86  # ============================================================
 87  #   Call: discovery-call-acme
 88  #   Temperature: WARM
 89  # ============================================================
 90  #
 91  #   ๐Ÿšซ Objections (3):
 92  #      pricing: 2
 93  #      timing: 1
 94  #      โ†’ [pricing] "That's a bit more than we budgeted for this quarter"
 95  #      โ†’ [pricing] "Can you do a smaller pilot first?"
 96  #      โ†’ [timing] "We're in the middle of a platform migration"
 97  #
 98  #   โœ… Buying Signals (2):
 99  #      budget_confirmed: 1
100  #      champion_identified: 1
101  #
102  #   โš”๏ธ  Competitors: HubSpot, Drift
103  #
104  #   ๐Ÿ’ฐ Pricing discussed: Yes (3 mentions)
105  ```
106  
107  ### 2. ๐Ÿ’ฐ Revenue Attribution Mapper (`revenue_attribution.py`)
108  
109  The "prove content ROI" tool. Maps blog posts, videos, podcasts, and webinars to actual closed deals using first-touch, linear, or time-decay attribution models.
110  
111  **What it produces:**
112  - Content-to-revenue mapping showing exactly which pieces drove pipeline
113  - Attribution across three models (pick the one that fits your sales motion)
114  - Cost-per-acquisition by content type (blog vs. video vs. webinar vs. podcast)
115  - Content gap analysis (which funnel stages have no content working?)
116  - Top performers ranked by attributed revenue
117  
118  ```bash
119  # Full attribution report (linear model)
120  python revenue_attribution.py --report
121  
122  # Time-decay model (more credit to recent touchpoints)
123  python revenue_attribution.py --report --model time-decay
124  
125  # Content gaps (which funnel stages are uncovered?)
126  python revenue_attribution.py --gaps
127  
128  # CPA by content type
129  python revenue_attribution.py --cpa --costs content_costs.json
130  
131  # Example output:
132  # ======================================================================
133  #   CONTENT REVENUE ATTRIBUTION REPORT
134  #   Model: linear
135  # ======================================================================
136  #
137  #   ๐Ÿ“Š Summary
138  #      Total Revenue:          $984,000
139  #      Total Deals:            5
140  #      Avg Deal Size:          $196,800
141  #      Content w/ Attribution: 13
142  #      Avg Touchpoints/Deal:   4.4
143  #
144  #   ๐Ÿ“ˆ Revenue by Content Type
145  #   Type             Revenue    Sessions   Pieces   Avg/Piece
146  #   --------------------------------------------------------
147  #   landing_page    $211,200     1,800        1    $211,200
148  #   blog            $298,560    17,000        6     $49,760
149  #   case_study      $156,000     2,090        2     $78,000
150  #   ...
151  ```
152  
153  ### 3. ๐Ÿ“‹ Multi-Source Client Report Generator (`client_report_generator.py`)
154  
155  Pulls from all four data sources (GA4, HubSpot, Ahrefs, Gong) and generates a unified, client-ready BI report with an auto-generated executive summary and optional anomaly detection.
156  
157  **What it includes:**
158  - **Executive summary** โ€” auto-generated highlights, concerns, and recommendations
159  - **Traffic** โ€” sessions, users, conversions, channel breakdown, top pages (GA4)
160  - **Pipeline** โ€” deals created/won/lost, revenue, win rate, avg cycle (HubSpot)
161  - **SEO** โ€” domain rating, rankings, backlinks, organic traffic (Ahrefs)
162  - **Call quality** โ€” talk ratio, call duration, next-steps rate, top topics (Gong)
163  - **Anomaly detection** โ€” flags unusual changes with severity levels
164  - **Period comparison** โ€” month-over-month, quarter-over-quarter, or year-over-year
165  
166  ```bash
167  # Console summary
168  python client_report_generator.py --client "Acme Corp"
169  
170  # Full markdown report
171  python client_report_generator.py --client "Acme Corp" --format markdown --output report.md
172  
173  # JSON for dashboards/slides
174  python client_report_generator.py --client "Acme Corp" --format json --anomalies
175  
176  # Skip sources you don't use
177  python client_report_generator.py --client "Acme Corp" --skip gong,ahrefs
178  
179  # Example output:
180  # ======================================================================
181  #   Acme Corp - Performance Report
182  #   2025-03-01 to 2025-03-31
183  # ======================================================================
184  #
185  #   ๐ŸŸข Overall: Strong
186  #
187  #   โœ… Highlights:
188  #      โ€ข Traffic up 8.1% (45,200 sessions)
189  #      โ€ข Conversions up 14.8% (342 total)
190  #      โ€ข Win rate at 60.0% (12 won)
191  #      โ€ข $1,440,000 revenue closed
192  #
193  #   โš ๏ธ  Concerns:
194  #      โ€ข Reps talking too much (54.2% talk ratio)
195  ```
196  
197  ---
198  
199  ## Quick Start
200  
201  ### 1. Install dependencies
202  
203  ```bash
204  pip install -r requirements.txt
205  ```
206  
207  ### 2. Configure environment
208  
209  ```bash
210  cp .env.example .env
211  # Edit .env with your API keys
212  ```
213  
214  ### 3. Test with sample data
215  
216  All tools ship with built-in sample data and fall back gracefully when API keys aren't configured. Try them out of the box:
217  
218  ```bash
219  # Analyze a transcript
220  echo "Prospect: That's more than we budgeted for this quarter.
221  Rep: I understand. What range were you expecting?
222  Prospect: We were looking at HubSpot too, they quoted us around 50k.
223  Rep: Makes sense. Our ROI calculator shows 3x return in year one." > sample.txt
224  
225  python gong_insight_pipeline.py --file sample.txt --follow-ups
226  
227  # Run attribution report (uses sample data without API keys)
228  python revenue_attribution.py --report --gaps
229  
230  # Generate client report (uses sample data without API keys)
231  python client_report_generator.py --client "Demo Corp" --anomalies
232  ```
233  
234  ### 4. Connect real APIs
235  
236  Set these environment variables to connect live data:
237  
238  ```bash
239  # Gong
240  export GONG_API_KEY="your-gong-api-key"
241  
242  # GA4
243  export GA4_PROPERTY_ID="123456789"
244  export GA4_CREDENTIALS_JSON="/path/to/service-account.json"
245  
246  # HubSpot
247  export HUBSPOT_API_KEY="your-hubspot-private-app-token"
248  
249  # Ahrefs
250  export AHREFS_TOKEN="your-ahrefs-api-token"
251  ```
252  
253  ---
254  
255  ## Configuration
256  
257  | Variable | Required By | Description |
258  |----------|-------------|-------------|
259  | `GONG_API_KEY` | Gong Pipeline, Client Report | Gong API access key |
260  | `GONG_API_BASE_URL` | Gong Pipeline, Client Report | Gong API URL (default: `https://api.gong.io/v2`) |
261  | `GA4_PROPERTY_ID` | Attribution, Client Report | GA4 property ID |
262  | `GA4_CREDENTIALS_JSON` | Attribution, Client Report | Path to GA4 service account JSON |
263  | `HUBSPOT_API_KEY` | Attribution, Client Report | HubSpot private app token |
264  | `AHREFS_TOKEN` | Client Report | Ahrefs API token |
265  | `YOUR_DOMAIN` | Client Report | Your root domain for Ahrefs data |
266  | `OUTPUT_DIR` | All | Output directory (default: `./output`) |
267  
268  ---
269  
270  ## Customization
271  
272  ### Objection Patterns
273  Edit `OBJECTION_PATTERNS` in `gong_insight_pipeline.py` to match your industry's objection language.
274  
275  ### Competitor List
276  Edit `KNOWN_COMPETITORS` in `gong_insight_pipeline.py` with your actual competitive landscape.
277  
278  ### Content Type Classification
279  Edit `CONTENT_TYPE_PATTERNS` in `revenue_attribution.py` to match your site's URL structure.
280  
281  ### Anomaly Thresholds
282  Pass custom thresholds to `detect_anomalies()` in `client_report_generator.py`:
283  ```python
284  thresholds = {"warning": 0.15, "critical": 0.30}  # 15% = warning, 30% = critical
285  ```
286  
287  ---
288  
289  ## How They Work Together
290  
291  1. **Weekly**: Run `gong_insight_pipeline.py` on recent calls โ†’ extract objections and buying signals
292  2. **Monthly**: Run `revenue_attribution.py` โ†’ see which content drove deals
293  3. **Monthly**: Run `client_report_generator.py` โ†’ deliver unified report to clients or leadership
294  4. **Quarterly**: Use Gong content topics + attribution gaps to plan next quarter's content
295  
296  The insight loop:
297  - Gong reveals what prospects ask about โ†’ creates content topics
298  - Content gets published โ†’ drives traffic (GA4)
299  - Traffic converts to pipeline โ†’ deals close (HubSpot)
300  - Attribution mapper proves which content worked โ†’ invest more in winners
301  - Repeat
302  
303  ---
304  
305  ## File Structure
306  
307  ```
308  revenue-intelligence/
309  โ”œโ”€โ”€ README.md                       # This file
310  โ”œโ”€โ”€ SKILL.md                        # Claude Code agent skill definition
311  โ”œโ”€โ”€ requirements.txt                # Python dependencies
312  โ”œโ”€โ”€ gong_insight_pipeline.py        # Call transcript โ†’ structured insights
313  โ”œโ”€โ”€ revenue_attribution.py          # Content โ†’ revenue mapping
314  โ””โ”€โ”€ client_report_generator.py      # Multi-source client BI reports
315  ```
316  
317  ---
318  
319  <div align="center">
320  
321  **๐Ÿง  [Want these built and managed for you? โ†’](https://singlebrain.com/?utm_source=github&utm_medium=skill_repo&utm_campaign=ai_marketing_skills)**
322  
323  *This is how we build agents at [Single Brain](https://singlebrain.com/?utm_source=github&utm_medium=skill_repo&utm_campaign=ai_marketing_skills) for our clients.*
324  
325  [Single Grain](https://www.singlegrain.com/?utm_source=github&utm_medium=skill_repo&utm_campaign=ai_marketing_skills) ยท our marketing agency
326  
327  ๐Ÿ“ฌ **[Level up your marketing with 14,000+ marketers and founders โ†’](https://levelingup.beehiiv.com/subscribe)** *(free)*
328  
329  </div>