🤖 AI Customer Support

5 mins • Easy

🤖 AI Customer Support

In this tutorial we will create an AI model that can answer customer support questions via email.

Users will be able to ask questions like "What kind of services do you provide?" and get an automated response email sent to your user's email address.

You can customize the AI model to include your own company information, and host it on TurboQ's cloud for free. Then you will be able to easily trigger the AI model programatically from your own application.

What the heck is TurboQ?

If you're new here TurboQ is a NodeJS framework for building resilient background workflows easily. We also provide a cloud platform to run your workflows at scale.

Third-party Tools

As an AI model, we will use OpenAI's API (opens in a new tab), and Resend (opens in a new tab) for sending emails. All the tools used in this tutorial are free to use, but you may need to sign up for an account.

Create a TurboQ account

If you haven't already, create a free account on TurboQ (opens in a new tab).

Project Setup

Create a new turboq project from the ai-customer-support template. With this we will have most of the boilerplate code already set up for us.

npx @turboq/sdk@latest create --template ai-customer-support

Your new project comes with a .env file, that expects two environment variables:

  • OPENAI_API_KEY: Your OpenAI API key.
  • RESEND_API_KEY: Your Resend API key.

Let's set those up!

OpenAI API Key

  1. Sign up for an account on OpenAI's API (opens in a new tab).
  2. Create a new API key from your dashboard (opens in a new tab).
  3. Copy the generated API key and paste it in the .env file.

Resend API Key

  1. Sign up for an account on Resend (opens in a new tab).
  2. Create a new API key from your dashboard (opens in a new tab).
  3. Copy the generated API key and paste it in the .env file.

Start Turboq

All set! Let's start our model locally. This will run a mini queue system on your local machine, and open TurboQ's development dashboard in your browser.

npm run start

Test

Open the development dashboard (opens in a new tab) and create a new job.

  1. Click the Create Job button.
  2. Select the 🤖 AI Customer Support queue from the dropdown.
  3. Enter the input of your job. For example:
{
  "email": "<YOUR_EMAIL_ADDRESS>",
  "question": "Hello! What kind of services do you provide? Can you help me with mobile development? Thanks!"
}
💡

Note that resend will only allow you to send emails to your own email address until you setup a custom domain. So use your own email address for testing.

Submit the job, and if everything is set up correctly, you should receive an email with the response from the AI model.

Customize

Head to the src/queues/customerSupport.ts file and look for the answer step to tweak the AI model with your own company information.

Deploy

You can run this model for free on TurboQ's cloud. To deploy your AI customer support, run:

# If you haven't logged in yet
npm run login
 
# Deploy to production for free
npm run deploy

Programatically trigger your AI model

Creating a job from the dashboard is great for testing, but you can also create jobs programatically using the TurboQ client.

After your application deployed head to your app settings (opens in a new tab), and generate a new API key.

Regardless of what application you are using, let that be Next.js, an Express server, or a script, you can use the TurboQ client to create jobs.

In your application install the TurboQ client:

npm install @turboq/client

And use it to create a job:

import { TurboqClient } from "@turboq/client";
 
const turboq = new TurboqClient({
  apiKey: process.env.TURBOQ_API_KEY,
});
 
// Rest of your applcation...
 
await turboqClient.createJob({
  queue: "🤖 AI Customer Support",
  input: {
    email: user.email,
    question: req.body.question,
  },
});

To Learn more about the concepts behind TurboQ, check out the Concepts section.