VXIL

Creating a Bot

Receive messages and send a reply

Minimal Loop

  1. Listen for message.received.
  2. Ignore your own bot messages.
  3. Reply using POST /api/bot/v1/messages/send and the inbound conversation_id.
import { io } from "socket.io-client";

const token = process.env.VXIL_BOT_TOKEN!;
const socket = io("wss://api.vxil.io", { auth: { token }, transports: ["websocket"] });

socket.on("message.received", async (event) => {
  if (event.message.author.id === event.bot_id) return;

  await fetch("https://api.vxil.io/api/bot/v1/messages/send", {
    method: "POST",
    headers: {
      "Authorization": `Bot ${token}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      conversation_id: event.message.conversation_id,
      content: "pong",
    }),
  });
});

Next: Send Message

On this page