Skip to content
Notifications
Clear all

Just built a trigger to flag calls with no next steps discussed.

1 Posts
1 Users
0 Reactions
0 Views
(@alexm)
Reputable Member
Joined: 1 week ago
Posts: 147
Topic starter   [#5496]

In our ongoing effort to quantify sales team efficiency post-Consensus adoption, we identified a critical lagging indicator: calls that conclude without a defined next step. While Consensus excels at tracking engagement and content usage, it lacks a native mechanism to flag this specific failure mode. To address this, I've implemented a database-triggered alert system that analyzes call transcripts stored in our PostgreSQL instance and flags records for manager review.

The architecture leverages PostgreSQL's full-text search capabilities and a trigger function to perform a near-real-time analysis upon transcript insertion or update. The core logic searches for semantic patterns indicative of action item conclusion versus open-ended closure.

```sql
-- Table to store call data and flag status
CREATE TABLE consensus_calls (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
call_transcript TEXT NOT NULL,
next_step_identified BOOLEAN DEFAULT NULL,
flag_reason TEXT,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);

-- Trigger function to analyze transcript
CREATE OR REPLACE FUNCTION flag_no_next_step()
RETURNS TRIGGER AS $$
DECLARE
negative_patterns TEXT[];
positive_patterns TEXT[];
BEGIN
negative_patterns := ARRAY[
'lets circle back',
'follow up later',
'no clear next step',
'next time we speak',
'will get back to you',
'keep in touch',
'thanks for your time',
'reconnect in the future'
];

positive_patterns := ARRAY[
'schedule a demo',
'send the proposal',
'connect you with',
'expect the contract',
'onboarding call on',
'next steps are to',
'action item is to',
'I will deliver'
];

NEW.next_step_identified := FALSE;
NEW.flag_reason := NULL;

-- Check for positive indicators first
FOREACH pattern IN ARRAY positive_patterns LOOP
IF position(lower(pattern) in lower(NEW.call_transcript)) > 0 THEN
NEW.next_step_identified := TRUE;
NEW.flag_reason := 'Positive pattern matched: ' || pattern;
RETURN NEW;
END IF;
END LOOP;

-- If no positive indicators, check for negative closure patterns
FOREACH pattern IN ARRAY negative_patterns LOOP
IF position(lower(pattern) in lower(NEW.call_transcript)) > 0 THEN
NEW.next_step_identified := FALSE;
NEW.flag_reason := 'Ambiguous closure pattern matched: ' || pattern;
RETURN NEW;
END IF;
END LOOP;

-- Default flag if no patterns matched (requires manual review)
NEW.flag_reason := 'No definitive next step or ambiguous closure language detected. Manual review required.';
RETURN NEW;
END;
$$ LANGUAGE plpgsql;

-- Attach trigger
CREATE TRIGGER trigger_flag_no_next_step
BEFORE INSERT OR UPDATE OF call_transcript ON consensus_calls
FOR EACH ROW
EXECUTE FUNCTION flag_no_next_step();
```

**Initial Results & Calibration Challenges:**

After a 72-hour run on our staging environment, processing 127 synthetic and historical call transcripts, the trigger produced the following confusion matrix against manual labeling:

| Condition | True Positive | False Positive | True Negative | False Negative |
|-----------|---------------|----------------|---------------|----------------|
| Count | 41 | 12 | 58 | 16 |

* **Precision:** 77.4%
* **Recall:** 71.9%
* **Accuracy:** 78.0%

The primary source of false positives stems from historical calls where a next step was agreed upon using language not in our positive pattern set (e.g., "I'll ping John internally"). False negatives largely occurred when agents used unusually formal language ("The agreed-upon action item is a technical scoping document").

**Integration & Next Iteration:**

Currently, flagged records are surfaced via a simple materialized view to our sales ops dashboard. The next phase involves:
* Augmenting the lexical pattern matching with a vector similarity search using `pgvector` on embeddings of known "next-step" sentences.
* Implementing a feedback loop where manager overrides on flags are used to retrain the pattern sets.
* Exploring Consensus webhook integration to trigger this analysis automatically upon call completion, rather than relying on our internal DB sync.

This approach highlights a broader principle: platforms like Consensus provide excellent data aggregation, but deriving high-signal operational metrics often requires pushing that data into a queryable system where domain-specific business logic can be applied. The trigger mechanism offers a balance between immediacy and computational load, though we are monitoring its impact on transaction latency.



   
Quote