[KongchangAI]
· 2 min read· 1,009 words

AI-Powered B2B Lead Scoring: A Deep Dive into Tally Forms + Webhooks

AI-Powered B2B Lead Scoring: A Deep Dive into Tally Forms + Webhooks

Automate B2B lead scoring end-to-end with Tally, AI rules, JSON validation, and PostgreSQL deduplication.

This pipeline transforms a standard online form into an automated lead scoring engine. After a prospect submits a Tally form, a Webhook triggers the workflow: data is normalized, scored 1–100 by an AI following predefined rules, validated for correct JSON structure before database writes, and pushed to Telegram with priority details. PostgreSQL upsert logic ensures duplicate submissions update existing records rather than creating new ones. The real value isn't just AI scoring — it's showing how to embed AI into a production-grade pipeline complete with validation, deduplication, and real-time notification.

A Form That Actually Scores Your Leads

Most online forms just collect contact information. This setup turns a form into an automated lead scoring engine. The core logic is straightforward: when a prospect submits a Tally form, a Webhook immediately captures the data and hands it off to the downstream pipeline.

As demonstrated by a YouTube creator, the entire workflow achieves end-to-end automation — from data collection and cleaning to AI scoring and real-time notifications. For B2B acquisition teams, this means sales reps no longer need to manually sift through every lead; the system automatically surfaces high-value prospects.

AI assigns each lead a score from 1 to 100

Data Flow: From Tally to the Database

The first step in the pipeline is data normalization. After a form submission, the data goes through a standardization process (the video mentions using Notion-related tooling for normalization) before being passed to the AI model. This step might seem minor, but it directly determines scoring quality — messy field formats will undermine the model's judgment downstream.

The AI assigns each lead a score between 1 and 100. Only when the output is valid does the lead get saved to the database. In other words, the database contains only validated, high-quality records — not a pile of raw noise.

Never Blindly Trust AI Output

The creator emphasizes a critical detail: never blindly trust what the AI returns. Before writing any result to the database, the workflow validates that the JSON structure is correct.

This is an essential engineering safeguard. Large language models occasionally return malformed responses or missing fields. Writing those directly to a database can corrupt your data at best, or bring your entire automation down at worst. Validating structure before persisting is a non-negotiable practice in production environments.

Validate the JSON structure before writing to the database

Common failure modes when prompting LLMs for structured data include: injecting extra natural-language commentary before or after the JSON, inconsistent key casing, returning numeric fields as strings, and incorrect nesting. Common engineering countermeasures include: specifying the exact output format with few-shot examples in your prompt, using APIs that support Structured Outputs or Function Calling (e.g., OpenAI's response_format: json_object), and running a secondary validation pass with JSON Schema on the receiving end. If validation fails, you can either discard the record and log the error, or re-feed the raw response back to the model for correction — depending on your latency tolerance.

Tally is a no-code online form builder with a Notion-like interface. It supports conditional logic, file uploads, and multi-step forms, and comes with built-in Webhook support — every form submission triggers an immediate HTTP POST request to a specified URL carrying all raw field values. Compared to Typeform or Google Forms, Tally includes Webhooks on its free tier, making it popular for low-cost automation setups. A Webhook is fundamentally an "event push" mechanism, as opposed to polling: instead of a downstream system repeatedly asking "is there new data?", the source notifies you the moment data arrives — typically within seconds — making it an ideal entry trigger for real-time automation pipelines.

The Rules Behind the AI Score

The scoring isn't a black box. According to the demo, the AI follows a set of predefined rules when evaluating leads rather than scoring arbitrarily. This means the scoring criteria are controllable and explainable — dimensions like company size, industry fit, and budget signals can all be encoded into the rules.

This approach combines the flexibility of AI with the determinism of rules: it leverages the model's ability to understand unstructured information while constraining the output to align with business logic. In B2B contexts, an explainable score is far more valuable than an opaque number with no paper trail.

The AI evaluates leads according to predefined rules

Real-Time Notifications and Deduplication

Once a lead is saved, the system immediately sends a Telegram alert containing the score, priority level, and key lead details. The sales team doesn't need to log into any dashboard — they can see which leads deserve immediate follow-up directly in their chat app.

Receive lead scores and priority alerts via Telegram

Handling Duplicate Submissions Gracefully with PostgreSQL

Duplicate data is one of the most overlooked problems in automation. What happens if the same event fires twice?

This pipeline handles it by leveraging PostgreSQL's update mechanism: when the same record arrives again, the system updates the existing entry instead of creating a new one. This is typically implemented via an upsert (insert or update), ensuring that each lead has exactly one up-to-date record in the database — no duplicate alerts, no dirty data.

Upsert is a portmanteau of "insert or update": attempt to insert a record, and if a primary key or unique constraint conflict occurs, update the existing record instead of throwing an error. PostgreSQL syntax looks like: INSERT INTO ... ON CONFLICT (unique_field) DO UPDATE SET .... In this scenario, the submitter's email or the form's built-in unique ID can serve as the conflict key, so no matter how many times someone submits, only the latest record is kept. Telegram won't fire duplicate alerts either. This mechanism also handles Webhook retries caused by network hiccups — idempotency is a fundamental requirement for any production-grade automation pipeline.

What Makes This Worth Borrowing

Despite the brevity of the demo, this workflow covers every critical component a reliable automation system should have:

  • Data normalization ensures input quality
  • AI scoring with rules balances intelligence with control
  • JSON validation blocks dirty data from entering the database
  • Real-time notifications shorten response time
  • Deduplication logic maintains data consistency

For teams building B2B acquisition automation, this architecture is directly reusable. It demonstrates not just the "AI scoring" capability, but how to embed AI into a robust engineering pipeline — where the validation, deduplication, and notification layers are often the difference between automation that actually runs in production and one that doesn't.

(This article is based on a single YouTube creator's demo. Refer to the original video for precise implementation details.)

#B2B lead scoring#Tally webhook automation#AI lead qualification#PostgreSQL upsert#no-code lead scoring pipeline
Share:

Related articles