Ai Coding Tools

How to Build a Simple Chatbot with Cursor in Under 2 Hours

By BTW Team4 min read

How to Build a Simple Chatbot with Cursor in Under 2 Hours

If you’re a solo founder or indie hacker, you’ve probably thought about how a simple chatbot could streamline your customer interactions. The good news? You can build one in under two hours with Cursor, even if you’re a complete beginner. In this guide, I’ll walk you through the process step-by-step, share the tools you’ll need, and provide tips based on my own experiences.

Prerequisites: What You’ll Need

Before diving in, make sure you have the following:

  1. Cursor Account: Sign up for a free account at Cursor.
  2. Basic Programming Knowledge: Familiarity with JavaScript will help, but I'll guide you through the essentials.
  3. Time: Set aside about 2 hours for this project.

Step 1: Setting Up Your Cursor Environment

  1. Create a New Project:

    • Log into your Cursor account.
    • Click on “New Project” and choose a name for your chatbot.
  2. Install Required Packages:

    • Open the terminal within Cursor and run the following command:
      npm install express body-parser
      
    • This installs the necessary packages to set up a simple server.

Step 2: Writing the Basic Chatbot Code

Here’s the basic structure of your chatbot. Copy and paste this code into your project file:

const express = require('express');
const bodyParser = require('body-parser');

const app = express();
app.use(bodyParser.json());

app.post('/chat', (req, res) => {
  const userMessage = req.body.message;
  const botResponse = `You said: ${userMessage}`; // Simple echo response
  res.json({ response: botResponse });
});

app.listen(3000, () => {
  console.log('Chatbot is running on http://localhost:3000');
});

Expected Output

When you run this code, you should see a message saying, “Chatbot is running on http://localhost:3000”. You can test it by sending a POST request to /chat with a JSON body like:

{
  "message": "Hello!"
}

Step 3: Testing Your Chatbot

  1. Use Postman or Curl:
    • Open Postman or use curl in your terminal to send a test message:
      curl -X POST http://localhost:3000/chat -H "Content-Type: application/json" -d '{"message":"Hello!"}'
      
    • You should receive a response echoing your message.

Step 4: Deploying Your Chatbot

Once you’re happy with your chatbot, it’s time to deploy it. You can use platforms like Heroku or Vercel for easy deployment.

Deployment Steps:

  1. Create a Heroku Account: Sign up for a free account.
  2. Install the Heroku CLI: Follow the instructions here.
  3. Deploy Your Code:
    • Run the following commands in your terminal:
      heroku create your-chatbot-name
      git push heroku master
      

Troubleshooting: What Could Go Wrong

  1. Port Issues: If the server doesn’t run, check for port conflicts. Change the port in the code if necessary.
  2. Deployment Errors: Ensure all dependencies are correctly listed in your package.json.

What’s Next?

Now that you have a basic chatbot, consider enhancing it with more features, like integrating with a database to store user interactions or adding natural language processing for better responses.

Additional Tools to Consider

Here's a list of tools that can help you expand your chatbot functionality:

| Tool | What It Does | Pricing | Best For | Limitations | Our Take | |---------------|----------------------------------------------------|-----------------------------|-----------------------------------|-------------------------------|-----------------------------------| | Dialogflow | NLP for understanding user intents | Free tier + $20/mo pro | NLP-based chatbots | Can be complex for beginners | We use this for advanced intents | | Twilio | SMS and chat integrations | Pay-as-you-go | SMS chatbots | Costs can add up fast | We don’t use this due to cost | | ChatGPT API | AI-generated responses | Free tier + $0.002/1k tokens| Conversational bots | Rate limits apply | We use this for dynamic responses | | Botpress | Open-source chatbot framework | Free + paid options | Customizable chatbots | Requires hosting | We don't use this due to setup time| | ManyChat | Marketing-focused chatbots | Free tier + $10/mo pro | Marketing automation | Limited customization | We don’t use this for our use case | | Landbot | No-code chatbot builder | Free tier + $30/mo pro | No-code solutions | Limited to simple bots | We use this for quick prototypes |

Conclusion: Start Here

Building a chatbot with Cursor is straightforward and can be done in under two hours. Start by following the steps above, and don’t hesitate to iterate on your design. You can always enhance your bot with more advanced features as you learn.

If you’re looking for a reliable tool to start with, I highly recommend sticking with Cursor for its simplicity and ease of use.

Follow Our Building Journey

Weekly podcast episodes on tools we're testing, products we're shipping, and lessons from building in public.

Subscribe

Never miss an episode

Subscribe to Built This Week for weekly insights on AI tools, product building, and startup lessons from Ryz Labs.

Subscribe
Ai Coding Tools

Cursor vs. Codeium: Which AI Tool Optimizes Your Workflow Better?

Cursor vs. Codeium: Which AI Tool Optimizes Your Workflow Better? As a solo founder or indie hacker, you know that every minute spent coding can either be a step closer to launch o

May 13, 20263 min read
Ai Coding Tools

AI Tool Knockout: Codeium vs GitHub Copilot — Which Is Better for 2026?

AI Tool Knockout: Codeium vs GitHub Copilot — Which Is Better for 2026? As we dive into 2026, the landscape of AI coding tools has evolved significantly. For indie hackers and solo

May 13, 20263 min read
Ai Coding Tools

How to Train Your AI Coding Assistant in Under 1 Hour

How to Train Your AI Coding Assistant in Under 1 Hour As a solo founder or indie hacker, you’ve probably faced the frustration of coding tasks that seem to take forever or feel lik

May 13, 20264 min read
Ai Coding Tools

How to Improve Your Coding Speed with AI: A 30-Minute Guide

How to Improve Your Coding Speed with AI: A 30Minute Guide As indie hackers and solo founders, we often find ourselves juggling multiple roles, and coding can feel like an uphill b

May 13, 20264 min read
Ai Coding Tools

Cursor vs GitHub Copilot: Which AI Tool to Choose for 2026?

Cursor vs GitHub Copilot: Which AI Tool to Choose for 2026? As a solo founder or indie hacker, you’re likely on the lookout for tools that can help you code more efficiently. With

May 13, 20263 min read
Ai Coding Tools

How to Get Started with AI Code Assistants in Just 1 Hour

How to Get Started with AI Code Assistants in Just 1 Hour If you're a solo founder or indie hacker, the prospect of using AI code assistants might feel daunting. But what if I told

May 13, 20264 min read