SendAfrica logoSendAfricaDocs

Self-Hosting the Agent

Run the SendAfrica Agent yourself — environment variables, serving the webhook server, running as an MCP server, and Docker deployment.


The agent is a Python package (sendafrica-agent) managed with uv. Clone the repo and configure credentials:

#1. Configure environment

.env
bash
cp .env.example .env
.env
ini
SENDAFRICA_API_BASE=https://api.sendafrica.online/v1
SENDAFRICA_API_KEY=SA-your-key-here

MAILAFRICA_API_BASE=https://api.mailafrica.online
MAILAFRICA_API_KEY=MA-your-key-here

NGAMIA_BASE_URL=https://api.ngamia.cc/v1
NGAMIA_API_KEY=ngm_your_key_here
NGAMIA_MODEL=openai/gpt-4o-mini

#2. Run the webhook (chat) server

serve.sh
bash
uv run sendafrica-agent serve
# Starts FastAPI server on http://0.0.0.0:8000

# Endpoints:
#   GET  /health              → {"status": "ok"}
#   POST /v1/agent/chat       → dashboard assistant
#   POST /webhooks/sendafrica → signed platform events

#3. Or run as a stdio MCP server

mcp.sh
bash
uv run sendafrica-agent mcp

#Docker deployment

docker.sh
bash
docker build -t sendafrica-agent .
docker run -d --name sendafrica-agent \
  --env-file .env \
  -p 8000:8000 \
  sendafrica-agent

# deploy.sh wraps build + push + remote restart for production hosts

#Wiring into the core API

Point the Go core API at the agent with AGENT_SERVICE_URL; the dashboard's POST /v1/support/chat route proxies to the agent's /v1/agent/chat. Session history persists in agent_sessions / agent_messages tables so conversations survive restarts.

VariablePurpose
AGENT_SERVICE_URLBase URL of the agent service (core API side)
NGAMIA_MODELLLM used for the tool-calling loop (default openai/gpt-4o-mini)
SENDAFRICA_WEBHOOK_SECRETHMAC secret verifying inbound platform events

License

The agent is MIT-licensed — fork it, extend the tool set in mcp_server.py, and add your own knowledge-base entries.