Skip to main content
Want to chat with your Craft Agent from your phone? Or get responses in Slack without opening a terminal? This guide shows you how to make your agent accessible from any chat platform.

How It Works

The architecture is simple:
  1. Host your agent as an HTTP service on a cloud platform
  2. Connect chat platforms via webhooks
  3. Messages flow: Chat app → Your server → Craft Agent → Response back
Chat from anywhere architecture diagram

Step 1: Wrap Your Agent as an HTTP Service

Create a simple server that calls the Craft CLI:
// server.js
import express from "express";
import { execFile } from "child_process";

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

app.post("/chat", (req, res) => {
  const message = req.body.message ?? "";
  const agent = req.body.agent ?? ""; // optional: specific sub-agent

  const args = [
    "-w", process.env.CRAFT_MCP_URL,
    "-p", message,
    "--output-format", "text"
  ];

  if (agent) {
    args.push("-a", agent);
  }

  execFile("craft", args, { timeout: 120000 }, (err, stdout, stderr) => {
    if (err) {
      console.error("Agent error:", err, stderr);
      return res.status(500).json({ error: "agent_failed" });
    }
    res.json({ reply: stdout.trim() });
  });
});

const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`Agent server on :${port}`));
Now you have a single endpoint: POST /chat { message } → { reply }

Step 2: Deploy to a Cloud Platform

Render is the easiest option - push your repo and it just works.
1

Create a Web Service

In Render dashboard, create a new Web Service and connect your Git repo.
2

Configure build settings

  • Build Command: curl -fsSL https://agents.craft.do/install.sh | bash && npm install
  • Start Command: node server.js
3

Add environment variables

  • CRAFT_ANTHROPIC_API_KEY - Your Anthropic API key
  • CRAFT_MCP_URL - Your workspace MCP URL
4

Deploy

Render builds and deploys automatically. You’ll get a URL like https://your-bot.onrender.com
Render’s free tier spins down after 15 minutes of inactivity. The first request after sleep takes 30 seconds. For always-on service, use a paid plan ($7/month).

Railway

Railway is similar - Git deploy with a simple dashboard.
1

Create a project

Connect your GitHub repo to a new Railway project.
2

Add environment variables

Set CRAFT_ANTHROPIC_API_KEY and CRAFT_MCP_URL in the Variables tab.
3

Configure start command

Railway auto-detects Node.js. Set start command if needed.
Pricing: Pay-per-use with a free trial. Hobby plan ~$5/month.

Step 3: Connect Chat Platforms

Slack

Best for team/workspace use. No app review needed for internal bots.
1

Create a Slack App

Go to api.slack.com/apps and create a new app.
2

Enable Event Subscriptions

  • Turn on Event Subscriptions
  • Set Request URL: https://your-bot.onrender.com/slack/events
  • Subscribe to message.channels and/or message.im events
3

Add bot permissions

Under OAuth & Permissions, add scopes:
  • chat:write - to send messages
  • channels:history - to read channel messages
  • im:history - to read DMs
4

Install to workspace

Install the app and copy the Bot User OAuth Token.
Add a Slack handler to your server:
import fetch from "node-fetch";

const SLACK_BOT_TOKEN = process.env.SLACK_BOT_TOKEN;

app.post("/slack/events", async (req, res) => {
  // Slack URL verification
  if (req.body.type === "url_verification") {
    return res.json({ challenge: req.body.challenge });
  }

  const event = req.body.event;

  // Ignore bot messages to prevent loops
  if (event.bot_id || event.subtype === "bot_message") {
    return res.sendStatus(200);
  }

  // Acknowledge immediately (Slack times out after 3s)
  res.sendStatus(200);

  // Process message async
  const message = event.text;
  const channel = event.channel;

  try {
    // Call your /chat endpoint
    const response = await fetch("http://localhost:3000/chat", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ message })
    });

    const { reply } = await response.json();

    // Send reply to Slack
    await fetch("https://slack.com/api/chat.postMessage", {
      method: "POST",
      headers: {
        "Authorization": `Bearer ${SLACK_BOT_TOKEN}`,
        "Content-Type": "application/json"
      },
      body: JSON.stringify({ channel, text: reply })
    });
  } catch (err) {
    console.error("Slack handler error:", err);
  }
});

Telegram

Very bot-friendly with minimal setup.
1

Create a bot

Message @BotFather on Telegram and use /newbot to create your bot. Save the token.
2

Set webhook

Call the Telegram API to point at your server:
curl "https://api.telegram.org/bot<TOKEN>/setWebhook?url=https://your-bot.onrender.com/telegram/webhook"
Add a Telegram handler:
const TELEGRAM_TOKEN = process.env.TELEGRAM_TOKEN;

app.post("/telegram/webhook", async (req, res) => {
  const message = req.body.message;
  if (!message?.text) return res.sendStatus(200);

  const chatId = message.chat.id;
  const text = message.text;

  res.sendStatus(200);

  try {
    const response = await fetch("http://localhost:3000/chat", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ message: text })
    });

    const { reply } = await response.json();

    await fetch(`https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage`, {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ chat_id: chatId, text: reply })
    });
  } catch (err) {
    console.error("Telegram handler error:", err);
  }
});

Discord

Discord supports HTTP interactions for webhook-based bots.
1

Create a Discord Application

Go to Discord Developer Portal and create an app.
2

Configure interactions endpoint

Set Interactions Endpoint URL to https://your-bot.onrender.com/discord/interactions
3

Add bot to server

Generate an OAuth2 URL with bot and applications.commands scopes.
Discord requires signature verification - see Discord’s interaction documentation for the full handler setup.

Messenger (Facebook/Instagram)

More setup steps, but doable:
  1. Create a Meta app at developers.facebook.com
  2. Add the Messenger product
  3. Connect to a Facebook Page
  4. Configure webhook URL and verify token
  5. Handle incoming messages via the webhook, reply via Send API
Some Messenger features require app review for public use. For personal/testing use, you can skip review.

WhatsApp

Not recommended for AI chatbots. Meta’s updated WhatsApp Business API terms (effective January 15, 2026) prohibit general-purpose AI assistants. Only structured bots for specific business functions (support, bookings, notifications) are allowed.
If your use case fits within “business support bot” rather than “general AI assistant,” you can use the WhatsApp Cloud API, but it requires:
  • Meta Business account
  • WhatsApp Business account verification
  • Cloud API setup

Platform Comparison

PlatformSetup DifficultyBest For
SlackEasyTeam/workspace use
TelegramEasiestPersonal use, public bots
DiscordModerateCommunities, servers
MessengerModerateFacebook/Instagram users
WhatsAppHard + restrictedBusiness support only

Tips

These are the easiest to set up. Get one working before adding more platforms.
Chat platforms expect quick responses (Slack times out after 3 seconds). Acknowledge immediately and process async.
Prevent abuse by limiting requests per user/channel. Simple in-memory tracking works for low-volume bots.
Log incoming messages and responses for debugging. Cloud platforms provide built-in logging.
Free tier hosts spin down when idle. Either upgrade to paid, or set up a health check ping to keep the service warm.

Cost Summary

For light personal use:
ComponentCost
Render/Railway (free tier)$0 (with sleep)
Render/Railway (always-on)~$5-7/month
Slack/Telegram/DiscordFree
Anthropic APIPay per use
Total: $0-7/month + API costs