
How we built an AI chatbot for lead generation
We built b2blead.ai to answer website enquiries while the visitor is still on the page. It uses the company's content to answer questions, then qualifies the lead before passing the conversation to a person.
A contact form leaves the visitor waiting for a response. We wanted to let them ask follow-up questions and give the sales team enough context to respond when the enquiry reaches them.
Architecture
b2blead.ai is a multi-tenant SaaS platform, designed for hundreds of concurrent deployments. Each client has a separate knowledge base, branding and integration settings on shared infrastructure.
Retrieving company information
The system uses retrieval-augmented generation (RAG). We ingest website pages, blog posts, documentation and product descriptions, then split the text into chunks and store embeddings in a vector database.
When a visitor asks a question, the system retrieves relevant passages and uses them to generate an answer. For a question about same-day delivery in Bangkok, for example, it looks for the company's shipping policy. This keeps the response tied to company information, although the output still needs evaluation for accuracy.
Qualifying leads
The chatbot asks about the visitor's needs, company size and industry, as well as their timing and budget. It uses the client's criteria to assess whether the enquiry is a fit.
For qualifying enquiries, the system collects contact details within the conversation and sends the lead to the CRM with the chat history attached.
Infrastructure and integrations
The platform uses AWS auto-scaling to handle traffic spikes and was built for sub-second response times. Retention periods are configurable to support GDPR requirements. Webhooks connect it to CRMs including HubSpot, Salesforce and custom systems.
Each client has an isolated knowledge base and configuration while sharing the underlying infrastructure.
Conversation analytics
The dashboards show common questions, where visitors leave a conversation, lead quality over time and conversion rates compared with the client's previous contact form. Clients use these results to revise website content, product messaging and sales follow-up.
The stack used for this build
| Component | Technology |
|---|---|
| Response generation | OpenAI GPT-4o |
| Vector storage and retrieval | Pinecone |
| Backend | Node.js with TypeScript |
| Website widget | Embeddable JavaScript |
| Infrastructure | AWS ECS, RDS, ElastiCache and S3 |
| Monitoring | Custom dashboards with live performance tracking |
What we learned
Vague website content produces vague answers. We now review content during onboarding to identify gaps in the information a visitor is likely to need.
Visitors also need answers quickly. We optimised latency and kept responses short and direct; long paragraphs were less useful in the chat interface.
Some enquiries need a person. We added escalation triggers for visitors who are frustrated, confused or asking about something outside the knowledge base.
Use after launch
The platform runs across multiple client deployments and handles thousands of conversations per month. We also build standalone chatbots, SaaS products and AI features for existing applications.
See the b2blead.ai case study or book a call to discuss your project.
