Files
pipecat/examples/pcc-dialin-server/simple-python/README.md
2025-03-20 12:31:08 -07:00

1.7 KiB

Daily PSTN/SIP Server

A FastAPI server that handles PSTN (Public Switched Telephone Network) and SIP (Session Initiation Protocol) calls using the Daily API.

Requirements

  • Python 3.8+
  • FastAPI
  • Uvicorn
  • Python-dotenv
  • Requests
  • Pydantic
  • Loguru

Setup

  1. Clone the repository
  2. Install dependencies:
    pip install -r requirements.txt
    
  3. Copy .env.example to .env:
    cp .env.example .env
    
  4. Update .env with your credentials:
    • AGENT_NAME: Your Daily agent name
    • DAILY_API_KEY: Your Daily API key
    • PINLESS_HMAC_SECRET: Your HMAC secret for request verification

Running the Server

Start the server with:

python server.py

The server will run on http://localhost:3000

API Endpoints

GET /

Health check endpoint that returns a "Hello, World!" message.

POST /api/dial

Initiates a PSTN/SIP call with the following request body format:

{
  "To": "+14152251493",
  "From": "+14158483432",
  "callId": "string-contains-uuid",
  "callDomain": "string-contains-uuid",
  "dialout_settings": [
    {
      "phoneNumber": "+14158483432",
      "callerId": "+14152251493"
    }
  ],
  "voicemail_detection": {
    "testInPrebuilt": true
  },
  "call_transfer": {
    "mode": "dialout",
    "speakSummary": true,
    "storeSummary": true,
    "operatorNumber": "+14152250006",
    "testInPrebuilt": true
  }
}

Response

Returns a JSON object containing:

  • status: Success/failure status
  • data: Response from Daily API
  • room_properties: Properties of the created Daily room

Error Handling

  • 401: Invalid signature
  • 500: Server errors (missing API key, network issues)
  • Other status codes are passed through from the Daily API