A Slack bot that allows users to send voice messages to other users via phone calls using Vonage APIs.
- Voice Message Delivery: Send voice messages to Slack users via phone calls
- Slack Connect Support: Works in Slack Connect channels
- Event Tracking: Logs all requests with unique event IDs
- Delivery Status: Receives webhooks about call delivery status
- Thread Support: All responses are posted in threads to keep channels clean
- SQLite Database: Lightweight, file-based database for easy deployment
In any Slack channel where the bot is installed:
@pingring @username Hey, this is an urgent message!
The bot will:
- Look up the phone number of the mentioned user
- Make a call via Vonage APIs
- Play the transcribed message
- Log the event and provide status updates in the thread
- Go 1.21+
- Slack App with Bot Token
- Vonage API credentials with a phone number
Copy .env.example
to .env
and fill in your credentials:
cp .env.example .env
- Clone the repository
- Install dependencies:
go mod download
- Set up environment variables
- Run the application:
go run cmd/pingring/main.go
# Setup development environment
make setup
# Edit .env with your credentials
vim .env
# Run the application
make run
# Create data directory for SQLite database
mkdir -p data
# Copy environment file
cp .env.example .env
# Edit .env with your credentials
# Start the service
make docker-run
- Create a new Slack app at https://api.slack.com/apps
- Enable Bot Token Scopes:
app_mentions:read
chat:write
users:read
- Subscribe to Bot Events:
app_mention
- Set Event Request URL to:
https://your-domain.com/slack/events
- Install the app to your workspace
- Create a Vonage application at https://dashboard.nexmo.com/
- Configure webhook endpoint:
https://your-domain.com/vonage/webhook
- Purchase a phone number for outbound calls
- Set up JWT authentication with your private key
Important: The Vonage JWT implementation is simplified in this code. In production, you must:
- Generate a private key for your Vonage application
- Store it securely
- Implement proper JWT signing in the
generateJWT()
method
POST /slack/events
- Slack event webhookPOST /slack/interactive
- Slack interactive componentsPOST /vonage/webhook
- Vonage delivery status webhookGET /health
- Health check endpoint
The bot uses SQLite with the following schema:
CREATE TABLE events (
id TEXT PRIMARY KEY,
user_id TEXT NOT NULL,
slack_org_id TEXT NOT NULL,
message TEXT NOT NULL,
thread_id TEXT,
channel_id TEXT NOT NULL,
phone_number TEXT NOT NULL,
vonage_call_id TEXT,
status TEXT NOT NULL DEFAULT 'pending',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
The application follows a clean architecture pattern:
cmd/
├── pingring/ # Application entry point
internal/
├── config/ # Configuration management
├── db/ # Database connection and migrations
├── handlers/ # HTTP handlers for Slack and Vonage
├── models/ # Data models
├── repository/ # Data access layer
├── services/ # Business logic
├── slack/ # Slack API client
└── vonage/ # Vonage API client
All bot responses are posted in threads to keep channels clean:
- Initial responses create a new thread from the mention message
- Status updates are posted to the same thread
- Error messages are also posted in threads
- Request signature verification for Slack webhooks
- Environment variable management for sensitive data
- SQLite database with proper file permissions
- JWT token generation for Vonage API (needs proper implementation)
The bot includes comprehensive logging for:
- Incoming Slack events
- Vonage API calls
- Database operations
- Error tracking
make help # Show all available commands
make setup # Setup development environment
make run # Run the application
make build # Build the application
make test # Run tests
make docker-build # Build Docker image
make docker-run # Run with Docker Compose
make logs # View application logs
make fmt # Format code
make lint # Lint code
make clean # Clean build artifacts
Run tests with:
make test
Format code with:
make fmt
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new features
- Run
make fmt
andmake lint
- Submit a pull request
MIT License
For questions or issues, please open an issue on GitHub.