Published Jan 5, 2024

Natural language BI: Query your database with no-code AI solutions

Youssef Zouhairi

Solutions Consultant

Youssef Zouhairi

One of the significant hurdles enterprises face is the ability to tap into the extensive data stored in databases and data warehouses. This task often demands strong SQL skills for efficient data extraction and utilization. Despite the critical importance of data management, many organizations struggle with accessing and utilizing their data effectively.

A 2022 report by Gartner found that poor data quality costs organizations an average of $12.8 million annually, highlighting the significant challenges enterprises face in tapping into and effectively using the extensive data stored in databases and data warehouses.

However, using AI can be a game-changer, enabling human-like conversations with data. Celigo is revolutionizing the transformation of natural language into AI-powered SQL queries. This innovative approach allows users without SQL expertise to query and retrieve information from databases and data warehouses easily, simplifying data access.

Here, we highlight an instance of Celigo’s AI-enhanced flow assistant. In this example, we showcase a Slack-based chatbot that converts natural language into executable SQL queries, a technique that’s revolutionizing our approach to querying structured data, transforming the way we interact with our data – making it as straightforward as asking a question.

How Celigo Transforms Natural Language into SQL with AI

Generative AI and LLMs are revolutionizing data querying by enabling intuitive, natural language interactions with databases. These technologies interpret user queries and convert them into precise SQL commands, facilitating more accessible and efficient data access.

The recent launch of Celigo’s embedded AI capabilities marks a significant advancement, enhancing NLP-based flows within the platform and promising increased efficiency and innovation in data interactions.

With AI, users can easily manage data processes, including data extraction, transformation, and loading.

Building the Text-to-SQL Flow

Slack Integration

Imagine a scenario where posing a question in a Slack channel triggers a response from our bot, activating an event in integrator.io:

  • First, we set up a bot in Slack with specific permissions like “chat:write” and “channels:history”.
  • Our bot employs an ‘Event Listener’ to detect messages in “message.channels”, forwarding payloads to our endpoint, the Slack Listener in integrator.io.
  • During data processing in integrator.io, our bot updates the relevant Slack thread. Caution is needed to avoid triggering the ‘Event Listener’ again, which could create an infinite loop. To prevent this, we use an output filter or a pre-save page hook in our flow to filter out messages from our bot.

 

SQL Query Generation

The process begins by contextualizing the database schema for our LLM. We use SQL to gather a detailed schema representation.

Our prompt engineering protocol instructs the LLM to craft an SQL query following specific guidelines:

  • Limit query results to a maximum of 10, unless specified otherwise.
  • Ensure the query doesn’t modify the database, avoiding commands like CREATE, UPDATE, and DELETE.
  • If the question doesn’t directly relate to the database, the response is simply “I don’t know.”

Executing SQL Queries

Executing the SQL query on Celigo’s integrator.io platform, we ensure each result is serialized into JSON format and integrated into our data payload.

This method allows for accurate inferences and efficient outcome prediction (and the platform offers comprehensive error-handling capabilities). In case of an event where the output of the executed SQL query is null, our automated system can validate the results for accuracy, ensuring an efficient troubleshooting process.

We also use filters, hooks (scripts), and branching to efficiently handle exceptions. These functionalities not only ensure precision but also help enhance the overall performance and reliability of our process.

 

Example Use Case

Car Dealer Management

In this example, we leverage Text-to-SQL with Celigo to extract data from a Car Dealership database using natural language processing.

The process flow includes:

 

  • Extracting the dealership database schema using Celigo’s integrator.io.
  • Generating an SQL query response to the inquiry using AI.
  • Executing the query on the database.
  • If the result is null, we consider two scenarios: either the query didn’t find matches, or it lacked sufficient information.
  • The AI reevaluates and refines the SQL query for a potential alternate outcome.

Steps and Prompts

  1. Question: “Who purchased a Spider in the past 30 years?”
  2. Initially, Celigo extracts the schema of the dealership database.
  3. Subsequently, the AI module generates an SQL query response for the given inquiry.
  4. This query is then executed on the database.
  5. If the result appears null, two potential scenarios could be inferred:
    • The SQL query is accurate and did not yield any matches, indicating no “Spider” purchases in the past 30 years.
    • The SQL query appears syntactically correct but resulted in insufficient information in the original question.
  6. Acknowledging these scenarios, the AI module reevaluates the initial SQL query to determine whether a different approach might yield an alternate outcome.
  7. Upon rethinking the query, the AI module scripts an enhanced SQL query that is then executed again.
  8. Finally, AI generates the conclusion.

 

No Code, Just Words

Celigo’s iPaaS and generative AI significantly enhance the capabilities of SQL database users, enabling even those without technical expertise to query databases and extract vital business information rapidly.

Celigo’s low-code environment streamlines processes, integrating various business systems and technologies, including relational databases.

Learn how to create an AI-powered chatbot, combining Slack, OpenAI’s Generative AI language model, and Pinecone’s vector database.

This synergy creates a robust, AI-powered knowledge base, facilitating quick access to critical information, bolstering data-driven decision-making, and evolving business processes.

Let’s get started

Integrate, automate, and optimize every process.

Already a user? Log in now.

Integration insights

Expand your knowledge on all things integration and automation. Explore our resources, learn from experts, and elevate your building expertise.