Use the custom mode when you already have an agent runtime or you want direct control over prompts, memory, tools, transcript policy, and external services.
Minimal example:
python
# handler.py
async def handle_message(text, number, caller, caller_name, session_id, channel, **kwargs):
return f"You said: {text}"
bash
nc-connect --key NC_KEY --handler custom --script handler.py
A more advanced reference exists in examples/openclaw_handler.py. That example shows how to combine conversation history, prompt bootstrap, recall, and asynchronous transcript posting while still returning a plain HandlerResult to NumberClaw.
Webhook equivalents if you want to keep your agent behind HTTP:
python
from flask import Flask, jsonify, request
app = Flask(__name__)
@app.post("/chat")
def chat():
data = request.get_json() or {}
return jsonify({"response": f"Hello {data.get('caller_name', 'caller')}"})
javascript
const express = require('express');
const app = express();
app.use(express.json());
app.post('/chat', (req, res) => {
const { text, caller_name } = req.body;
res.json({ response: `Hello ${caller_name || 'caller'}, you said: ${text}` });
});
app.listen(8080);