npm package: @paulstinchcombe/n8n-nodes-sip-client
Description: n8n SIP Client Node - A softphone node for making and receiving calls with real WebRTC audio streaming
Author: Paul Stinchcombe
Latest version: 0.0.3

# n8n SIP Client Node

A powerful n8n community node that enables SIP (Session Initiation Protocol) functionality within your n8n workflows. Make and receive calls directly from your automation workflows with real WebRTC audio streaming.

## 🚀 Features

### **Core SIP Functionality**

- **Make Outgoing Calls**: Initiate calls to any SIP URI or phone number
- **Receive Incoming Calls**: Handle incoming calls with automatic detection
- **Call Management**: Hang up calls, get call status, and monitor call states
- **Real-time Audio**: WebRTC audio streaming for high-quality voice communication

### **SIP Server Support**

- **Asterisk**: Full compatibility with Asterisk PBX systems
- **FreeSWITCH**: Native support for FreeSWITCH servers
- **3CX**: Works seamlessly with 3CX phone systems
- **Custom SIP Servers**: Connect to any standard SIP server

### **WebRTC Integration**

- **ICE Servers**: Configurable STUN/TURN servers for NAT traversal
- **Audio Codecs**: Support for Opus, PCMU, PCMA, and G722 codecs
- **Real-time Streaming**: Low-latency audio communication
- **Cross-platform**: Works on any platform that supports WebRTC

### **n8n Integration**

- **Workflow Automation**: Integrate calling into your automation workflows
- **Error Handling**: Robust error handling with detailed error messages
- **Status Monitoring**: Real-time call status and monitoring
- **Event-driven**: Trigger workflows based on call events

## 📦 Installation

### **npm Installation (Recommended)**

```bash
# Install the n8n SIP client node
npm install @paulstinchcombe/n8n-nodes-sip-client

# Or using yarn
yarn add @paulstinchcombe/n8n-nodes-sip-client

# Or using pnpm
pnpm add @paulstinchcombe/n8n-nodes-sip-client
```

## 🔧 Configuration

### **SIP Server Setup**

The node supports various SIP servers. Here are example configurations:

#### **Asterisk Configuration**

```json
{
  "sipServer": "asterisk.example.com",
  "sipPort": 5060,
  "username": "your_username",
  "password": "your_password",
  "displayName": "n8n SIP Client"
}
```

#### **FreeSWITCH Configuration**

```json
{
  "sipServer": "freeswitch.example.com",
  "sipPort": 5060,
  "username": "your_username",
  "password": "your_password",
  "displayName": "n8n SIP Client"
}
```

#### **3CX Configuration**

```json
{
  "sipServer": "3cx.example.com",
  "sipPort": 5060,
  "username": "your_extension",
  "password": "your_password",
  "displayName": "n8n SIP Client"
}
```

### **WebRTC Configuration**

Configure WebRTC settings for optimal performance:

```json
{
  "webrtcConfig": {
    "iceServers": "stun:stun.l.google.com:19302,stun:stun1.l.google.com:19302",
    "audioCodec": "Opus"
  }
}
```

## 📋 Usage

### **Making Calls**

1. **Add the SIP Client node to your workflow**
2. **Select "Make Call" operation**
3. **Configure SIP settings**:
   - SIP Server: Your SIP server address
   - Username: Your SIP username
   - Password: Your SIP password
   - Destination: The number or SIP URI to call
4. **Configure call parameters**:
   - Duration: Maximum call duration (0 for unlimited)
5. **Run the workflow**

### **Receiving Calls**

1. **Add the SIP Client node to your workflow**
2. **Select "Receive Call" operation**
3. **Configure SIP settings** (same as above)
4. **The node will wait for incoming calls**
5. **Handle the call data in subsequent nodes**

### **Call Management**

- **Hang Up**: End the current active call
- **Get Status**: Retrieve current call status and information

## 🔗 Workflow Examples

### **Example 1: Automated Customer Support**

```mermaid
graph LR
    A[Webhook Trigger] --> B[SIP Client - Make Call]
    B --> C[Wait for Answer]
    C --> D[Play IVR Message]
    D --> E[SIP Client - Hang Up]
```

### **Example 2: Call Monitoring**

```mermaid
graph LR
    A[SIP Client - Receive Call] --> B[Log Call Details]
    B --> C[Send Notification]
    C --> D[SIP Client - Answer Call]
```

### **Example 3: Integration with CRM**

```mermaid
graph LR
    A[CRM Trigger] --> B[Get Customer Info]
    B --> C[SIP Client - Make Call]
    C --> D[Update CRM with Call Result]
```

## 🛠️ Operations

### **Make Call**

- **Purpose**: Initiate an outgoing call to a destination
- **Parameters**: SIP configuration, destination, duration
- **Returns**: Call ID, status, timestamp

### **Receive Call**

- **Purpose**: Wait for and handle incoming calls
- **Parameters**: SIP configuration
- **Returns**: Call ID, caller information, status

### **Hang Up**

- **Purpose**: End the current active call
- **Parameters**: None (uses current call)
- **Returns**: Status confirmation

### **Get Status**

- **Purpose**: Get current call status and information
- **Parameters**: None
- **Returns**: Current status, active call details

## 🔧 Parameters

### **SIP Configuration**

- **SIP Server**: Your SIP server address (required)
- **SIP Port**: Server port (default: 5060)
- **Username**: SIP username for authentication (required)
- **Password**: SIP password for authentication (required)
- **Display Name**: Optional display name for the client

### **WebRTC Configuration**

- **ICE Servers**: Comma-separated list of STUN/TURN servers
- **Audio Codec**: Preferred audio codec (Opus, PCMU, PCMA, G722)

### **Call Parameters**

- **Destination**: SIP URI or phone number to call
- **Duration**: Maximum call duration in seconds (0 for unlimited)

## 🚨 Error Handling

The node provides comprehensive error handling:

- **Connection Errors**: Clear messages for server connectivity issues
- **Authentication Errors**: Specific messages for credential problems
- **Call Errors**: Detailed information about call failures
- **Configuration Errors**: Validation of required parameters

All errors include:

- Item index for debugging
- Detailed error description
- Suggested solutions
- Operation context

## 📞 Supported SIP Servers

### **Asterisk**

- ✅ Full compatibility
- ✅ WebRTC support
- ✅ Audio codec support
- ✅ Call management

### **FreeSWITCH**

- ✅ Native support
- ✅ WebRTC integration
- ✅ Multi-codec support
- ✅ Advanced call features

### **3CX**

- ✅ Seamless integration
- ✅ Extension support
- ✅ Call routing
- ✅ Status monitoring

### **Custom SIP Servers**

- ✅ Standard SIP protocol
- ✅ WebRTC compatibility
- ✅ Configurable settings
- ✅ Flexible deployment

## 🔒 Security

- **Password Protection**: Secure credential handling
- **WebRTC Security**: Encrypted audio streams
- **SIP Security**: Standard SIP security protocols
- **No Data Storage**: No sensitive data is stored

## 📊 Performance

- **Low Latency**: Real-time audio communication
- **High Quality**: WebRTC audio streaming
- **Scalable**: Support for multiple concurrent calls
- **Efficient**: Optimized resource usage

## 🤝 Support

### **Getting Help**

- **Documentation**: Comprehensive guides and examples
- **Issues**: Report bugs on GitHub
- **Community**: Join n8n community discussions
- **Examples**: See workflow examples in documentation

### **Troubleshooting**

- **Connection Issues**: Check SIP server configuration
- **Authentication**: Verify username and password
- **Audio Problems**: Check WebRTC configuration
- **Call Failures**: Review error messages for guidance

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## 🙏 Acknowledgments

- **n8n Team**: For the excellent n8n platform
- **SIP.js**: For the SIP protocol implementation
- **WebRTC**: For real-time communication capabilities
- **Community**: For feedback and contributions

---

**Ready to integrate SIP calling into your n8n workflows?** 🚀

Install the node and start building powerful voice-enabled automations today!