logoRocketFlow

API Reference

Complete API reference for Rocket Flow's endpoints and SDK.

API Reference

REST API Endpoints

Chatbot Management

Create Chatbot

POST /api/chatbot/create
Content-Type: application/json
 
{
  "name": "string",
  "description": "string",
  "initialMessage": "string",
  "theme": "light" | "dark"
}

Train Chatbot

POST /api/chatbot/train
Content-Type: application/json
 
{
  "chatbotId": "string",
  "data": {
    "urls": string[],
    "documents": File[],
    "faqs": Array<{ question: string, answer: string }>
  }
}

Test Chatbot

POST /api/chatbot/test
Content-Type: application/json
 
{
  "chatbotId": "string",
  "message": "string"
}

Message Management

Send Message

POST /api/messages
Content-Type: application/json
 
{
  "chatbotId": "string",
  "message": "string",
  "sessionId": "string"
}

Get Message History

GET /api/messages?chatbotId={chatbotId}&sessionId={sessionId}

Web Crawler

Crawl Website

POST /api/crawl
Content-Type: application/json
 
{
  "url": "string",
  "depth": number,
  "selector": "string"
}

React SDK

Widget Component

import { Widget } from "@rkt/widget/widget";
 
interface WidgetProps {
  chatId: string;
  theme?: "light" | "dark";
  position?: {
    bottom?: number;
    right?: number;
  };
  className?: string;
  initialMessage?: string;
  onMessage?: (message: Message) => void;
  onError?: (error: Error) => void;
}

Hooks

useChat

import { useChat } from "@rkt/widget/hooks";
 
const { 
  messages,
  sendMessage,
  isLoading,
  error
} = useChat({
  chatId: "your-chat-id"
});

useChatbot

import { useChatbot } from "@rkt/widget/hooks";
 
const {
  chatbot,
  train,
  test,
  isTraining,
  error
} = useChatbot({
  chatbotId: "your-chatbot-id"
});

Events

The widget emits the following events:

interface ChatEvents {
  "message:sent": (message: Message) => void;
  "message:received": (message: Message) => void;
  "error": (error: Error) => void;
  "ready": () => void;
}

Types

Message

interface Message {
  id: string;
  content: string;
  role: "user" | "assistant";
  timestamp: string;
  metadata?: Record<string, any>;
}

Chatbot

interface Chatbot {
  id: string;
  name: string;
  description?: string;
  theme: "light" | "dark";
  initialMessage?: string;
  createdAt: string;
  updatedAt: string;
}

For implementation examples and best practices, check out our Configuration Guide.

Last updated on

On this page