DEV Community

Cover image for Chat with your Database using Custom GPTs
Alexandro Martinez
Alexandro Martinez

Posted on

Chat with your Database using Custom GPTs

Learn how to chat with your database in natural language by using DataLang API or using a custom GPT.

Live on ProductHunt!

1. Set up your Data Source

Create a DataLang account (50% off 12 months for the first 100 customers) and set up your connection string.

Database Source

Select “Database” and add your connection string.

New Database Source

Custom Server Source

If you don’t want to share your password (although encrypted), download the DataLang Custom server to host it on your server (see the code).

Custom Server Source

⚠️ TIP: Only use database users with read-only access to the tables you want exposed, and never share your API Key.

2. Create Database Views

Write the SQL statement to retrieve the necessary information to facilitate chat interactions among your users, employees, or customers.

New Data View in SQL

By doing this, you’re also exposing your data through the API by calling:

datalang.io/api/data-sources/{source-slug}/views/{view-slug}?sync=false

Get Data View via API

3 Create an Assistant

An Assistant acts as a bridge, grouping various data sources for chat interaction. For instance, you could create a ‘Sales Assistant’ that only has access to the New York and Chicago branches' data sources, each with 2–3 specialized sales data views.

Chat with the your custom Assistant

This is great by itself, but the Assistant’s API can’t do what ChatGPT can so let’s leverage the new GPT store.

4 Create a Custom GPT

Head over to the GPT store, and click Create. You’d need to fill in the following details:

  • Name: Sales Assistant
  • Description: New York and Chicago sales assistant
  • Actions: What your assistant can access (TLDR: all data views from the selected data sources)

Go to your DataLang assistant, click “Custom GPT”, and follow the details instructions.

Create a Custom GPT Instructions

Now, publish it and share it with your users, employees, or customers!

Chat with your Custom GPT in ChatGPT

Become an Affiliate ✨

If you know a company or two that could benefit from this, earn up to 30% for each payment in the first year. Click here to sign up as an affiliate.


What’s next?

This was built using my Remix SaaS boilerplate SaasRock, so tons of upcoming updates this year. I have many ideas specifically for DataLang:

  • Support more data sources: Files, API…
  • Support more data views: Stored procedures, spreadsheets…
  • Add data formats: Table, Chart, PDF…

Follow me to stay tuned, or subscribe to DataLang’s newsletter.

Top comments (0)