Contact us
Oleksa Stelmakh about creating custom LLM solution How I Used ChatGPT to Develop AI Sales Email Auto-Response Solution

How I Used ChatGPT to Develop AI Sales Email Auto-Response Solution

May 29, 2024

17 mins read

Disclaimer: In this article, I share my journey of switching from CEO to developer to build an “AI Sales Email Auto-response” solution completely by ChatGPT—without writing a single line of code myself. The second part of this article will reveal the future migration to Google Gemini and Azure OpenAI Service as pre-trained models, explore the landscape of LLMs, and share how companies can benefit from implementing AI tools based on corporate LLM. This text was written entirely by a human, without any AI generation or review.

In November 2022, OpenAI released ChatGPT and made DALL-E 2 available to the public. Initially, we were amazed, then we laughed at its mistakes and hallucinations. We tested how good it was, checked if it could “add 2 plus 2,” and even tried convincing it that “2 plus 2 is 5.”

However, the initial issues were fixed faster than we could have imagined. Objectively, GPT-3.5 wasn’t bad, but just a few months later, on March 14th, 2023, GPT-4.0 was released, and it was a game changer.

Our position as the smartest creatures was suddenly in jeopardy, and we switched to a defensive and critical mode:

  • “But GPT (generative pre-trained transformer) can’t create anything truly new.”
  • “It only rephrases existing text.”
  • “Maybe some jobs, but my job can’t be replaced.”

Soon after, we started using it for our daily tasks and loved it. The pace of innovation has become so fast that now it’s not a question of whether you should implement AI in your company, but rather—aren’t you already behind? The release of ChatGPT-4o in May made it even a bit scary.

AI We All Use Now

Of course, we all began using ChatGPT for writing emails, making them both great and terrible at the same time. Instead of simple, clear messages like, “It’s important to use AI in our daily work,” we started using sophisticated English, saying things like, “Arguably, it’s vital to delve into the landscape of AI in our daily work.”

Doubtfully our content has become better, but that’s not the point.. The amount of AI-generated text has exploded. We started using AI for image generation, writing articles, and text review. Software engineers began relying on tools like Copilot and ChatGPT-4 for coding. Some claim we’ve become 20% to 50% more efficient.

But is that enough? Are we using AI to its full potential, and if not, what are the better use cases?

Corporate Large Language Model (LLM)

I’m convinced that the true value of AI/GPT for companies lies in building a corporate LLM and applying it to most of the company’s processes in fully automated—or at least semi-automated modes. By a corporate LLM, I mean a model pre-trained on the entire dataset of the company’s internal knowledge base.

However, building this AI requires more than just feeding it all available digital information. Often, you’ll need to create new company artifacts that may be missing to enhance the pre-trained AI’s inference capabilities. Ideally, your corporate AI should answer any relevant company-related question as well as your representatives can.

The information we aim to include in the model is substantial:

  • Company website(s)
  • Project cases with all related information
  • Internal presentations
  • Legal documents
  • Internal knowledge base (e.g., Confluence, wikis, OneDrive, Google Drive)
  • Emails
  • Recorded calls
  • Graphic objects like charts, images, and diagrams

Building such an AI isn’t overly difficult, but it does take some time. The problem is that sometimes loading too much of the data is not making the LLM any smarter. Still you can’t expect LLM will know some information you haven’t loaded into it.

Corporate LLM

For this article, I’ll describe how we built a simpler version of a corporate LLM for just one function: automatically answering sales inquiries received via the sales email or website form submissions.

AI Sales Email Auto-response

We called this project “AI Auto-Response for Pre-Sales Emails & Site Form Submissions,” or, for short, “AI Sales Email Auto-Response.” Besides building an AI solution, the goal was to validate the hypothesis that AI implementation can be done by AI itself. In simpler terms: can ChatGPT build a ChatGPT integration solution?

Why do we need AI auto-response

“Where are my leads?”—that’s probably the number one question for every Marketing Department in every service company, especially IT service companies.

The inbound channel is typically the preferred channel because once you’ve invested in brand recognition, incoming inbound leads can be treated as free. What’s special about inbound leads is that someone has already googled your company and is potentially interested specifically in your services (perhaps due to your Clutch rating or an organic search). The problem, however, is that customers usually identify 10-20 potential vendors and then send the same message or RFP to all of them.

Responding within 24 hours is considered good, but many believe that a relevant response within an hour (the faster, the better) can significantly increase your chances of securing the lead.

Of course, we can respond immediately without AI, but it would just be a generic template message, even for irrelevant requests. This is where using AI seems like a perfect solution. With it, we can filter requests, categorize them by type, and provide strong, specific, and relevant responses almost instantly.

The Team

I decided to do this myself, so let me start with a brief introduction. I’m the CEO and Founder of Leobit, a software development and outsourcing company. We have around 170 engineers in our offices in Lviv, Ukraine, and Krakow, Poland, with representative headquarters in Austin, TX, and Tallinn, Estonia. Leobit primarily focuses on .NET, Web, AI, LLMs, and Azure.

I’ve been in IT for over 20 years, starting as a Java and .NET developer in the early 2000s. However, for the past 10 years, I haven’t written a single line of code as a developer, which is typical for a CEO of a well-functioning company. This project was an experiment for me—could I use AI to resume development after a 10-year break without writing code myself?

AI Training Approach & AI Request Categorization

The first logical idea to train your model is to collect all datasets of initial customer requests and your company’s responses. Although we’ve gathered a substantial dataset over almost 10 years, it’s not as useful as it seems. Companies are constantly evolving, so responses from more than six months ago are likely outdated, and even last month’s responses may no longer be relevant. You might change focus, update your project portfolio, or adjust your strategy. For example, we no longer work with Xamarin, preferring Flutter or .NET MAUI over React Native, and we’ve only gained significant expertise in working with LLMs in the second half of 2023.

Instead of training on outdated historical datasets, it’s better to describe your new approach and strategy. Since customer requests can vary greatly (e.g., building LLM integration solutions vs. building UI/UX for a mobile/web app or team setup with BOT model), you’ll need to categorize them to provide tailored, specific responses. For the final product, you might want to build a hierarchy of categories, but for my proof of concept, 10 categories were sufficient.

Development Environment (Google Sheets & Apps Script)

As a manager, I didn’t feel like dealing with a development environment like Visual Studio or MS Azure—I definitely wanted to avoid it. What I had at my disposal was a Google Sheets document where site form submissions were already arriving. Google offers Apps Script for every Sheet, which allows you to code directly in what is essentially JavaScript, but without the browser context.

The challenge was that I didn’t know JavaScript, which actually made the process more exciting. It raised a new question: Can you develop in a language you don’t know, with the help of AI? As an ex-developer, I grasp most of the syntax of JavaScript (though I find it weird and prefer C# or Java).

Thus, my choice for using Google Sheets & Apps Script was driven by the desire to not add anything new.

PoC Architecture

The goal was to build a working proof of concept (PoC) in just a few days, so I wanted to start with a simple approach. The future MVP and production versions were first ported to Google Gemini and then to MS Azure OpenAI Service as pre-trained custom models, trained on a substantial amount of corporate data. However, for my PoC, I decided to use the OpenAI API (essentially the same as a ChatGPT prompt, but accessible via API).

Since I wasn’t building a pre-trained model, the simplest approach was to make stateless API calls, passing the company description, prompt instruction, and customer request text every time for each new lead.

LLM PoC Architecture

PoC Coding with ChatGPT and Some Technical Considerations

[If you are non-technical you can skip this section and continue reading from “Summary of Coding with AI”, but for tech folks it may be quite interesting]

It turned out to be simpler than I expected. You just ask what to code—and that’s it. Then you run the code, describe your issues, and it fixes them. Sometimes I didn’t even read the error message or explain what needed to be done; I simply pasted the error directly into the prompt and copied the fixed version back to Apps Script.

OMG, modern developers—is this how you work now?

By the way, if I were a senior JavaScript developer, it would probably have taken me 5 times longer to code the solution myself without AI.

Let me share examples.

Code to search for new sales emails to write into Google SpreadSheet

>For Google App Script write a function that will search my Google Workspace emails for all initial emails sent from external to hello@leobit.com and write output to active Sheet of Google SpreadSheet inserting new row after header.

var searchQuery = '(to:hello@leobit.com) -label:reply -label:forward' + ' (-from:leobit.com OR from:via))';
if (dayFromInclusive !== null && dayToExclusive !== null) {
searchQuery = searchQuery + ' after:' + dayFromInclusive + ' before:' + dayToExclusive;

var threads = GmailAppSearch(searchQuery);
threads.reverse().forEach(function (thread, index) {
var message = thread.getMessages()[0];
var _date = message.getDate();
var _from = message.getFrom().trim();
var _to = message.getTo().toLowerCase().trim();
var _subject = message.getSubject().trim();

var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
// Insert the new row at the top (after the header)
spreadsheet.insertRowAfter(1);
spreadsheet.getRange("A2:G2").setValues([[_date, _from, _to, _cc, _subject, _body]]);
}

Executing ChatGPT from Google SpreadSheet Formula

Since we used Google Spreadsheet as a controller to store data, calculate scores, and change status through the workflow, we sometimes needed custom, non-standard GPT calls directly from a cell formula. For instance, if we have lead headquarters information in a non-canonical form, we might not be able to retrieve the country for score calculation.

To address this, we can use our custom function “doPerformOpenAIAPICall,” which we defined earlier, directly from a cell, passing the entire prompt as a parameter. This can be a powerful tool for Sheet automation.

Warning: Be careful with this approach, as Spreadsheet may recalculate these cells frequently, potentially incurring significant costs for such a simple task. You will have to replace the output of the formula with values once executed (using Copy+Paste as Text) or implement some caching mechanism in your GPT calls.

Spreadsheet calculations

For standard Sheet formulas, GPT worked even better. I considered myself an Excel/Spreadsheet expert, but the formulas that GPT generated at my request were on another level—sometimes I even had a hard time understanding how they worked exactly. Take a look at this example:

Spreadsheet logic example

AI lead qualification

It would be strange to respond to every request you get from the website form and sales email. First, because a good portion of the requests are spam or irrelevant. But even for potentially relevant inquiries, we need to distinguish between No-Go, Low-score, and High-score leads to initiate different flows based on lead type and score.

So, what do we disqualify & categorize?

  • Requests from terrorist states like Russia, Belarus, or North Korea
  • Requests from non-commercial emails or if the website isn’t working (HTTP response code must be 200)
  • Certain industries

We check if the website is working using this AI-generated Apps Script code:

var options = {
'muteHttpExceptions': true,
'followRedirects': true
}
try {
var response = UrlFetchApp.fetch(url, options);
var responseCode = response.getResponseCode();
}

AI Lead scoring

AI lead scoring

The scoring logic is quite straightforward. We consider the following attributes:

  • Request category type (as identified by AI)
  • Lead country
  • Lead industry
  • Lead company match
  • Technology match

Based on these parameters, we calculate the Lead Score, which is then used to apply specific workflows for leads based on score. Additionally, the allocation of Sales Managers is performed automatically based on lead geography and score.

Summary of Coding with AI

Let me share some of the conclusions from implementing this project as well as multiple other LLM implementations of Leobit for internal use and our customers:

  • For simple projects, you can develop without writing a single line of code (just many hundreds of lines of prompts)
  • Coding of simple project with AI in a language you don’t know isn’t a problem as long as you understand the basics (for complex projects that would probably not work)
  • Coding with AI can significantly speed up development. For many projects, it can be 5x faster; for some, it will only be a 20% speedup, and only very unique projects can’t utilize ChatGPT for coding (which is still quite questionable)
  • An engineer who can fully leverage AI can be miles ahead, so learning effective use of AI should become number one priority for developers
  • AI integration into your business flow is simple (at least for the basic version of the integration)
  • However, we must start applying effective AI use and automation now to avoid being replaced by competitors who adopt AI faster

Junior Developer or ChatGPT 4?

It’s a popular discussion in the developer community: who would you choose as your partner for a project—a Junior Developer or ChatGPT 4?

To my surprise, even in 2024, many Senior Developers still complain about the quality of coding outputs from ChatGPT or Co-Pilot. Some say they can code faster with Stack Overflow or prefer to do things manually rather than fixing AI hallucinations and defects. Folks, are you serious? You get an immediate answer that satisfies your needs in 25% of cases, and in the other 75%, you just need to provide an additional prompt or run the code and ask ChatGPT to fix the issues.

I believe it’s important to recognize that ChatGPT can code at the level close to a strong Junior developer, but it does so in no time. If it’s not working for you, it may be worth examining how you can better leverage its capabilities. Embracing AI tools can help you stay competitive and keep pace with colleagues who are already utilizing them effectively.

While I acknowledge that for some projects, such as those with extensive legacy codebases and complex logic, AI might not be as beneficial, but these situations are not too often. Considering the rapid improvements in LLM technology, it’s clear that their potential will only increase, making them an invaluable asset in many development scenarios.

Developers without AI skills will be absolutely uncompetitive. Even Juniors need to know more now, as basic coding is already covered by AI. Since AI can significantly aid in coding, the most successful developers will be those who fully embrace AI, excel in troubleshooting and debugging, focus on system engineering and architecture, and have strong business orientation and requirements management skills.

Response Email from Leo - Leobit AI

Initially, we were unsure how people would react to an email from an AI, so we considered sending emails on behalf of our Sales Representatives. However, we wanted to be transparent and decided to give it a try. From day one of our release to production, we operated on behalf of Leo – Leobit AI.

Leo generates responses that are a blend of fixed, templated, and pure AI-generated content. He’s instructed to act as a Sales Representative, and he does a good job of selling Leobit: providing relevant expertise, related cases, appropriate proof of competence, and convincing reasons why we’re a good match.

For .NET requests, he mentions our Microsoft Solution Partner status, Azure-certified engineers, and .NET-related recognitions, achievements, and cases. However, for technologies we haven’t worked with, he initially started hallucinating. For instance, he claimed that we had significant experience with Delphi when we sent a test request for a Delphi solution, despite us not having worked with it.

While this isn’t necessarily harmful in this context, we provided extra instructions to encourage greater transparency with potential customers. Now, he’s more truthful.

Example of Request [above] and AI Email Response [below]
Example of Request and AI Email Response

Results and Human Reaction to AI

The results were quite promising. Of course, responding to incoming requests is just a tiny part of sales work (probably 1%). Sometimes humans can do it better. But the biggest achievement is the full automation of the workflow to filter, score, allocate, and generate answers, and most importantly—an immediate, relevant response. It has essentially removed the anxiety of missing important requests and added a more structured process with a greater sense of relaxation.

Interestingly, some people, even after realizing that Leo is artificial, still engaged with him, responding with comments like, “Thanks, Leo, looking forward to speaking with your biological colleagues.”

The biggest achievement is that some calls have been scheduled by customers themselves without any work from Sales Managers. Imagine starting your day and seeing calls scheduled in your calendar for today by leads that were processed and interacted with AI while you were sleeping. The record time between a lead request and a scheduled call was less than one hour. That’s indeed impressive.

AI Transformation with Corporate LLM

The PoC took me less than a week, while the next Azure OpenAI version, with a pre-trained model and more sophisticated logic, was developed by the Leobit R&D team in around three months. Improving the system will be an ongoing process, but it won’t require much development time—primarily the expertise of an LLM Business Analyst to refine the knowledge base and prompt instructions.

Once we have finished and deployed the Leobit Corporate LLM it allowed rolling out of the new solutions on top of it quite easily. Now we have several AI employees built on top of Leobit corporate LLM: LeoSlack Leonard (Slack chatbot to help with HR-related tasks), Leora (Leobit AI Sales Manager) and many others. 

Since this is quite a big topic we will cover corporate tools built on top of corporate LLM in the second part of the story which will be published shortly. [Update: link to AI Transformation article]

Summary

The main takeaway is that whether you believe it or not, AI is here and ready to take human jobs (developers aren’t among the first 20 jobs to be replaced but will eventually be affected). AI is already doing impressive things, and we may be amazed by its abilities in a year—it’s better to be prepared. Many companies haven’t implemented a corporate LLM yet, but such a system could significantly enhance their operations or elevate their product. It’s inevitable: either you implement AI and corporate LLMs now to stay ahead of competitors, or you’ll miss the boat when it’s already too late.

If you have any questions, I’d be happy to answer them. Please connect with me on LinkedIn

If you’re looking to implement AI/LLM for your company, submit the form below or read more about our AI/ML & Generative AI Services. We’ll be happy to assist you with consulting and AI development.

 

 

Want a
quick tech consultation?

Contact us
Artem Matsa | Business Development Director