Overview
This quickstart guide will help you set up VoicePact and create your first voice-powered contract with automated escrow in under 10 minutes.
What you’ll build: A complete contract workflow from voice recording to SMS confirmation to escrow setup.
Prerequisites
Before you begin, ensure you have:
Python 3.11+ installed
Node.js 18+ installed
Redis server running
An Africa’s Talking Sandbox account
ngrok installed (for webhook tunneling)
Step 1: Clone and Setup Backend
Clone the repository
git clone https://github.com/mutuiris/voicepact.git
cd voicepact
Navigate to server directory
Create and activate virtual environment
python -m venv venv
source venv/bin/activate
Install dependencies
pip install -r requirements.txt
This installs all required packages including:
fastapi - Async web framework
africastalking - Africa’s Talking SDK
sqlalchemy - Database ORM
redis - Caching and sessions
cryptography - Ed25519 signatures
Configure environment variables
Create a .env file in the server directory: # Africa's Talking Configuration
AT_USERNAME = sandbox
AT_API_KEY = your_api_key_here
AT_VOICE_NUMBER = +254XXXXXXXXX
AT_PAYMENT_PRODUCT_NAME = VoicePact
AT_USSD_SERVICE_CODE = *483 #
# Database Configuration
DATABASE_URL = sqlite:///./voicepact.db
REDIS_URL = redis://localhost:6379/0
# Security Configuration
SECRET_KEY = your_secret_key_here
SIGNATURE_PRIVATE_KEY = your_ed25519_private_key_here
# Webhook Configuration
WEBHOOK_BASE_URL = https://your-ngrok-url.ngrok.io
# Application Settings
ENVIRONMENT = development
DEBUG = true
LOG_LEVEL = INFO
Replace your_api_key_here with your actual Africa’s Talking API key from the sandbox dashboard .
Step 2: Start Redis
Redis is required for caching and session management.
macOS (Homebrew)
Linux
Docker
Windows
brew services start redis
Step 3: Setup Webhook Tunnel
Africa’s Talking needs to send callbacks to your local server. Use ngrok to create a public URL:
Copy the HTTPS URL
ngrok will display a URL like https://abc123.ngrok.io. Copy this URL.
Update your .env file
Update the WEBHOOK_BASE_URL in your .env file: WEBHOOK_BASE_URL = https://abc123.ngrok.io
Step 4: Start the Backend Server
Start the FastAPI server
From the server directory with your virtual environment activated: uvicorn main:app --reload --port 8000
You should see output like: INFO: Started server process [12345]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8000
Verify the server is running
Open a new terminal and test the health endpoint: curl http://localhost:8000/health
You should receive a response with status "healthy": {
"status" : "healthy" ,
"services" : {
"database" : "healthy" ,
"redis" : "healthy"
},
"timestamp" : 1234567890.123
}
Step 5: Create Your First Contract
Now let’s create a manual contract to test the system:
Create a test contract using the API
curl -X POST http://localhost:8000/api/v1/contracts/create/manual \
-H "Content-Type: application/json" \
-d '{
"product": "Maize (White)",
"quantity": "50",
"unit": "bags",
"unit_price": 3500,
"total_amount": 175000,
"currency": "KES",
"delivery_location": "Nairobi Market",
"delivery_deadline": "2026-03-15",
"quality_requirements": "Grade A, moisture content < 13%",
"parties": [
{
"phone": "+254712345678",
"role": "seller",
"name": "John Kamau"
},
{
"phone": "+254798765432",
"role": "buyer",
"name": "Jane Wanjiku"
}
],
"contract_type": "agricultural_supply"
}'
View the contract response
You’ll receive a response containing your contract details: {
"contract_id" : "VP-AGR-1234567890" ,
"status" : "pending" ,
"created_at" : "2026-03-06T10:30:00" ,
"total_amount" : 175000.0 ,
"currency" : "KES" ,
"parties" : [
{
"phone_number" : "+254712345678" ,
"role" : "seller" ,
"name" : "John Kamau"
},
{
"phone_number" : "+254798765432" ,
"role" : "buyer" ,
"name" : "Jane Wanjiku"
}
],
"contract_hash" : "blake2b_hash_here"
}
SMS confirmation messages are automatically sent to both parties in the background.
Check contract status
Query the contract status to see signature progress: curl http://localhost:8000/api/v1/contracts/VP-AGR-1234567890/status
Response: {
"contract_id" : "VP-AGR-1234567890" ,
"status" : "pending" ,
"signatures" : [
{
"phone_number" : "+254712345678" ,
"status" : "pending" ,
"signed_at" : null
},
{
"phone_number" : "+254798765432" ,
"status" : "pending" ,
"signed_at" : null
}
],
"progress" : {
"signed" : 0 ,
"total" : 2 ,
"complete" : false
}
}
Simulate party confirmation
In a real scenario, parties would reply to the SMS. For testing, confirm manually: curl -X POST "http://localhost:8000/api/v1/contracts/VP-AGR-1234567890/confirm?phone_number=%2B254712345678"
Repeat for the second party: curl -X POST "http://localhost:8000/api/v1/contracts/VP-AGR-1234567890/confirm?phone_number=%2B254798765432"
After both parties confirm, the contract status changes to "confirmed".
Step 6: Setup the Client Dashboard (Optional)
The Next.js client provides a web interface for managing contracts.
Navigate to client directory
Configure environment
Create .env.local in the client directory: NEXT_PUBLIC_API_BASE_URL = http://localhost:8000
NEXT_PUBLIC_WEBSOCKET_BASE = ws://localhost:8000
NEXT_PUBLIC_FEATURE_LOW_DATA_MODE = true
NEXT_PUBLIC_FEATURE_ESCROW_TIMELINE = true
NEXT_PUBLIC_FEATURE_ROLE_AWARE_DASHBOARD = false
Start the development server
Next Steps
Installation Guide Complete installation and configuration reference
API Reference Explore all available API endpoints
Voice Processing Learn about voice-to-contract workflows
Escrow Integration Understand automated payment escrow
Troubleshooting
Ensure Redis is running: Should return PONG. If not, start Redis using the instructions in Step 2.
Africa's Talking API errors
Verify your API key is correct in the .env file
Check you’re using the correct username (sandbox for sandbox mode)
Ensure your ngrok URL is updated in WEBHOOK_BASE_URL
Database initialization errors
The database is automatically created on first run. If you encounter issues: rm voicepact.db # Remove old database
# Restart the server - it will create a fresh database
In sandbox mode, SMS only works with numbers registered in your Africa’s Talking sandbox. Add test numbers in the sandbox settings .
What You’ve Learned
You’ve successfully:
✅ Set up the VoicePact backend with FastAPI
✅ Configured Africa’s Talking integration
✅ Created your first contract via API
✅ Tested the SMS confirmation workflow
✅ (Optional) Set up the web dashboard
You’re now ready to explore advanced features like voice processing, automated escrow, and USSD integration!