Skip to content

kiransilwal1/email-sql-agent

Repository files navigation

Using Local Ollma model to build an Agent that queries database and send email to a user

Here's a step-by-step tutorial for setting up and deploying an AI Agent with Ollama, local LLM and Langchain, including installing necessary tools, deploying the app, and running it locally.

This example consists of the following pieces:

  • ollama (models)
  • Langchain
  • Next.js (user inteface)
  • sqlite3 (database)
  • sendGrid for sending email
  • Zod for data validation

This guide will walk you through installing the dependencies, initializing and deploying a project, and running the application locally. I will use sqlite3 to run a local database. Qwen2.5-coder:7b as the LLM.

Cloning the repository

Clone this repository and open the right directory:

git clone https://github.com/kiransilwal1/email-sql-agent

Step 1: Install Dependencies in the Application

To run the application you need to install the necessary dependencies:

npm i

This command installs all required packages, including Langchain and any dependencies specified in the project.

Step 2: Set Up Environment Variables

I am using SendGrid API to send emails. Create an environment file and add your Send Grid email API key as below.

SENDGRID_API_KEY=SG._xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Step 3: Run the Application

Finally, start the application by running:

npm run dev

This command initiates your application, allowing you to asking questions like:

  • How many customers are there?
  • Please find the customer with the highest number of orders.
  • Please find the customer with the highest number of order and send an email stating that he is now eligible for a free order.

Have a look at the database schema in /src/app/database.ts to learn more about the data structure.

Future possibilities

  • Integrating Firebase notifications to mobile apps after storing FCM tokens in the database.
  • Sending SMS to the user (The phone number shall be saved in the database).
  • Implementing calendar, GPS, CRM etc to track and automate e-commerce workflows.

About

An Agent in Next JS that queries sqlite db and sends email to the desired email address

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors