How to Capture Phone Numbers with your AI Chatbot

How to Capture Phone Numbers with your AI Chatbot

Transitioning from your chatbot to a human sales executive is a crucial feature for your AI chatbot. We've always had this feature. It's been implemented such that if a user drops an email address in the chatbot, this triggers an automatic email being sent to your lead email inbox, with the chatlog, allowing you to continue the conversation where the AI chatbot left it.

We just recently had a client wanting something similar for phone numbers, implying if the user drops a phone number in the chat, an email is being automatically triggered to allow a human being to take over the conversation from where the chatbot left it.

Hyperlambda training snippets

We've always had the ability to inject Hyperlambda into a training snippet, for then to have this Hyperlambda executed if the training snippet scores as the first result when doing RAG and VSS matching. This feature is simple to use if you know some basic Hyperlambda. Basically, you can inject Hyperlambda by wrapping it inside two { and } characters inside the completion of your snippet. Below is a screenshot of how to collect phone numbers.

The ChatGPT Chatbot that can browse the web and display images

Notice the "Cached" checkbox is turned on. This ensures that the text of the prompt will be returned as is, without GPT transformation. The text of the prompt being highlighted in the above screenshot.

It looks a little bit confusing since when mixing text and Hyperlambda the training snippets editor doesn't give you syntax highlighting, but I've included the code further down on this article such that you can copy and paste it.

The text that's highlighted is important since we're doing VSS matching on training snippets, and we don't want to have "false positive". If you only add a prompt, only the prompt will be vectorised, since we remove any Hyperlambda code as we vectorize the snippet. This results in that the snippet becomes too short, and can kick in for false positives, resulting in that things such as "Hi" triggers the training snippet at the top. By adding some more text content inside the snippet, but outside the Hyperlambda brackets, the snippet becomes longer, and we avoid false positives.

If the above is the first matching training snippet during lookups into your database, the Hyperlambda between the { and } characters will be executed. This allows you to put any Hyperlambda inside a training snippet, including code that sends an email. The Hyperlambda snippet will be given the prompt the user provided, allowing you to use the prompt any ways you wish. This is how we connect ChatGPT to your database for instance.

Below is the code you'd typically use to send an email with the prompt for a phone number collecting chatbot.

      .:"User left phone number in chat, user's message was: '"
            name:AINIRO Team
      subject:Chatbot lead
         content:x:@.body was generated

Whatever you return as your last statement will then be returned back to the user as is, without any transformation through OpenAI or their LLM models. This happens because of the Cached" checkbox being turned on in the above screenshot. The [] invocation creates a log entry allowing you to collect KPI information for your cloudlet.

The important parts for a snippets such as the one above becomes your prompt. This should be crafted such that it matches any permutations of "my phone number is xyz", "phone number xyz", "call me please", etc. Since the matching of snippets is done using VSS and embeddings, this can be easily achieved by creating a prompt such as follows.

Prompt - My phone number is 1234567890

Completion - Thank you for leaving your phone number with is. One of our employees will contact you ASAP. (Hyperlambda code here)

The above will match for mostly any numbers, since VSS lookups will use "fuzzy lookups", implying the actual number doesn't need to be an exact match. This allows you to configure your chatbot such that it automatically collects phone numbers, triggering an email being sent to your lead inbox, allowing a human being to take over the conversation from where the chatbot left it.

Thomas Hansen

Thomas Hansen I am the CEO and Founder of AINIRO.IO, Ltd. I am a software developer with more than 25 years of experience. I write about Machine Learning, AI, and how to help organizations adopt said technologies. You can follow me on LinkedIn if you want to read more of what I write.

Published 7. Feb 2024