Primeros pasos

Construye tu primer chatbot de IA

Crea un chatbot conversacional desde cero utilizando los modelos de NovaAI Chat.

Learn how to build a simple AI chatbot using NovaAI Chat models. By the end of this guide, you'll have a working chatbot capable of receiving user messages and generating intelligent responses.

Overview

In this guide, you'll build a basic chatbot using the NovaAI SDK. The chatbot will:

  • Accept user input

  • Send messages to NovaAI

  • Receive AI-generated responses

  • Continue a conversation using message history

Estimated time: 10–15 minutes

Prerequisites

Before you begin, make sure you have completed:

  • Installation

  • Authentication

  • Your First Request

You'll also need:

  • Node.js 18+

  • A NovaAI API key

  • A JavaScript project

Tip: If you haven't configured your API key yet, complete the Authentication guide before continuing.

Tip: If you haven't configured your API key yet, complete the Authentication guide before continuing.

1

Install the SDK

If you haven't already installed the SDK, run:

npm install @novaai/sdk
1

Install the SDK

If you haven't already installed the SDK, run:

npm install @novaai/sdk
2

Initialize the Client

Create a new file named chatbot.js.

import { NovaAI } from "@novaai/sdk";
 
const client = new NovaAI({
apiKey: process.env.NOVA_API_KEY,
});

The client is now ready to communicate with NovaAI.

2

Initialize the Client

Create a new file named chatbot.js.

import { NovaAI } from "@novaai/sdk";
 
const client = new NovaAI({
apiKey: process.env.NOVA_API_KEY,
});

The client is now ready to communicate with NovaAI.

3

Send Your First Message

Create a simple chat completion request.

const response = await client.chat.create({
model: "nova-chat-4",
messages: [
{
role: "user",
content: "Hello! Who are you?"
}
]
});
 
console.log(response.output);
3

Send Your First Message

Create a simple chat completion request.

const response = await client.chat.create({
model: "nova-chat-4",
messages: [
{
role: "user",
content: "Hello! Who are you?"
}
]
});
 
console.log(response.output);

You should receive a response similar to:

Hello! I'm NovaAI, your AI assistant. How can I help you today?

4

Keep Conversation History

To maintain context, send previous messages with every request.

const messages = [
{
role: "system",
content: "You are a helpful assistant."
}
];
 
messages.push({
role: "user",
content: "Explain APIs."
});
 
const response = await client.chat.create({
model: "nova-chat-4",
messages
});
 
messages.push({
role: "assistant",
content: response.output
});
4

Keep Conversation History

To maintain context, send previous messages with every request.

const messages = [
{
role: "system",
content: "You are a helpful assistant."
}
];
 
messages.push({
role: "user",
content: "Explain APIs."
});
 
const response = await client.chat.create({
model: "nova-chat-4",
messages
});
 
messages.push({
role: "assistant",
content: response.output
});

Conversation Flow

Rendering diagram…

Project Structure

Rendering diagram…

Best Practices

Recommendation

Benefit

Include a system message

Produces more consistent responses.

Preserve conversation history

Maintains context between messages.

Limit message history

Reduces token usage and latency.

Handle API errors

Improves reliability and user experience.

Chat models do not remember previous requests automatically. Your application is responsible for sending conversation history with each request.

Chat models do not remember previous requests automatically. Your application is responsible for sending conversation history with each request.

Completed

Congratulations!

You've built your first NovaAI chatbot. From here, you can enhance it by adding:

  • Streaming responses

  • Function Calling

  • Memory

  • Knowledge retrieval with Embeddings

  • AI Agents

¿Te resultó útil?

¿Te resultó útil?

Create a free website with Framer, the website builder loved by startups, designers and agencies.