CloudContactAI.CCAI.NET 1.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package CloudContactAI.CCAI.NET --version 1.3.0
                    
NuGet\Install-Package CloudContactAI.CCAI.NET -Version 1.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CloudContactAI.CCAI.NET" Version="1.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CloudContactAI.CCAI.NET" Version="1.3.0" />
                    
Directory.Packages.props
<PackageReference Include="CloudContactAI.CCAI.NET" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CloudContactAI.CCAI.NET --version 1.3.0
                    
#r "nuget: CloudContactAI.CCAI.NET, 1.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CloudContactAI.CCAI.NET@1.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CloudContactAI.CCAI.NET&version=1.3.0
                    
Install as a Cake Addin
#tool nuget:?package=CloudContactAI.CCAI.NET&version=1.3.0
                    
Install as a Cake Tool

C# client for CloudContactAI API with SMS, MMS, Email, and Webhook support. Includes comprehensive documentation, examples, and testing framework.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.4.3 54 9/5/2025
1.4.2 128 9/4/2025
1.4.1 106 9/3/2025
1.4.0 98 9/3/2025
1.3.0 170 8/27/2025
1.2.0 138 8/14/2025
1.1.0 133 8/14/2025
1.0.0 273 6/9/2025

# CloudContactAI.CCAI.NET v1.3.0 Release Notes

**Release Date**: August 26, 2025  
**Package**: CloudContactAI.CCAI.NET v1.3.0  
**Compatibility**: Fully backward compatible with v1.2.0, v1.1.0, and v1.0.0

## 🎉 What's New in v1.3.0

### 🔧 Enhanced SMS Custom Data Support
Major improvements to SMS functionality with comprehensive custom data support for webhook integration:

- **🏷️ Custom Data Parameters**: Full support for custom data fields in SMS messages for enhanced webhook tracking
- **🔗 Webhook Integration**: Seamless integration with webhook callbacks including custom data in payloads
- **📊 Enhanced Testing Framework**: Comprehensive testing suite for custom data webhook functionality
- **🧪 Live Testing Examples**: Working examples for testing custom data webhook integration

### 🌐 Environment Variable Configuration
Flexible configuration system supporting both production and test environments:

- **⚙️ Environment-Based URLs**: Support for configurable API endpoints via environment variables
- **🔄 Test Environment Support**: Seamless switching between production and test environments
- **🛡️ Secure Configuration**: Environment variable support for sensitive configuration data
- **📋 Configuration Templates**: Sample environment files for easy setup

## 🚀 New Features

### Custom Data SMS Functionality
```csharp
// Send SMS with custom data for webhook tracking
var response = await ccai.SMS.SendSingleAsync(
   firstName: "John",
   lastName: "Doe",
   phone: "+1234567890",
   message: "Hello ${FirstName}! Your order #12345 is ready.",
   title: "Order Notification",
   customData: "OrderID:12345,CustomerType:Premium,Source:WebApp"
);

// Custom data will be included in webhook callbacks
Console.WriteLine($"Message sent with custom data: {response.Id}");
```

### Environment Variable Configuration
```csharp
// Configure using environment variables
var config = new CCAIConfig
{
   ClientId = Environment.GetEnvironmentVariable("CCAI_CLIENT_ID"),
   ApiKey = Environment.GetEnvironmentVariable("CCAI_API_KEY"),
   UseTestEnvironment = true  // Automatically uses test URLs from env vars
};

// URLs are automatically resolved from environment variables:
// CCAI_BASE_URL / CCAI_TEST_BASE_URL
// CCAI_EMAIL_BASE_URL / CCAI_TEST_EMAIL_BASE_URL  
// CCAI_AUTH_BASE_URL / CCAI_TEST_AUTH_BASE_URL
```

### Enhanced Webhook Testing
```csharp
// Complete webhook testing with custom data
var customData = $"TestData_{Guid.NewGuid().ToString()[..8]}";
var response = await ccai.SMS.SendSingleAsync(
   firstName: "Test",
   lastName: "User",
   phone: "+1234567890",
   message: "Webhook test message with tracking data",
   title: "Webhook Test Campaign",
   customData: customData
);

// Webhook payload will include:
// - CustomData field with your tracking information
// - Message delivery status updates
// - Inbound reply message notifications
```

## 🔧 Technical Improvements

### SMS Service Enhancements
- **Custom Data Support**: Native support for custom data parameters in all SMS methods
- **Webhook Integration**: Enhanced webhook payload structure with custom data fields
- **Request/Response Models**: Updated SMS request and response models with custom data properties
- **Validation**: Improved parameter validation and error handling

### Configuration System
- **Environment Variables**: Automatic resolution of API endpoints from environment variables
- **Test Environment**: Seamless switching between production and test environments
- **URL Flexibility**: Support for custom API endpoints while maintaining defaults
- **Backward Compatibility**: Existing hardcoded configurations continue to work

### Testing Framework
- **Custom Data Tests**: Comprehensive test suite for custom data functionality
- **Webhook Testing**: Live webhook testing examples with real payload validation
- **Environment Testing**: Tests for both production and test environment configurations
- **Integration Tests**: End-to-end testing of SMS with webhook callbacks

## 📦 New Examples and Documentation

### SMS Custom Data Examples
- **`sms-custom-data-test/`**: Complete example project for testing custom data functionality
- **`sms_custom_data_webhook_test.cs`**: Standalone example for webhook testing with custom data
- **Live Testing Guide**: Step-by-step instructions for testing webhook integration

### Environment Configuration
- **`.env.sample`**: Updated sample environment file with all supported variables
- **Configuration Examples**: Multiple examples showing different configuration approaches
- **Test Environment Setup**: Complete guide for setting up test environment

### Webhook Integration
- **Enhanced Webhook Examples**: Updated webhook examples with custom data handling
- **Payload Documentation**: Complete documentation of webhook payload structure
- **Testing Workflows**: End-to-end testing workflows for webhook integration

## 🔄 API Changes and Enhancements

### SMS Service Methods
```csharp
// Enhanced SendSingleAsync with custom data support
public async Task<SMSResponse> SendSingleAsync(
   string firstName,
   string lastName,
   string phone,
   string message,
   string title,
   string? customData = null,  // NEW: Custom data parameter
   SMSOptions? options = null,
   CancellationToken cancellationToken = default)

// Enhanced SendAsync with custom data support  
public async Task<SMSResponse> SendAsync(
   SMSRequest request,  // SMSRequest now includes CustomData property
   CancellationToken cancellationToken = default)
```

### Configuration Enhancements
```csharp
public record CCAIConfig
{
   // Environment variable support with fallback defaults
   public string BaseUrl { get; init; } =
       Environment.GetEnvironmentVariable("CCAI_BASE_URL") ??
       "https://core.cloudcontactai.com/api";
       
   public string EmailBaseUrl { get; init; } =
       Environment.GetEnvironmentVariable("CCAI_EMAIL_BASE_URL") ??
       "https://email-campaigns.cloudcontactai.com/";
       
   public string AuthBaseUrl { get; init; } =
       Environment.GetEnvironmentVariable("CCAI_AUTH_BASE_URL") ??
       "https://auth.cloudcontactai.com/";
       
   // Test environment support
   public bool UseTestEnvironment { get; init; } = false;
   
   // Dynamic URL resolution based on environment
   public string GetBaseUrl() { /* ... */ }
   public string GetEmailBaseUrl() { /* ... */ }
   public string GetAuthBaseUrl() { /* ... */ }
}
```

### Request/Response Models
```csharp
// Enhanced SMS request with custom data
public class SMSRequest
{
   public IEnumerable<Account> Accounts { get; set; }
   public string Message { get; set; }
   public string Title { get; set; }
   public string? CustomData { get; set; }  // NEW: Custom data field
   public SMSOptions? Options { get; set; }
}

// Enhanced SMS response with additional metadata
public class SMSResponse
{
   public string Id { get; set; }
   public string Status { get; set; }
   public string? CampaignId { get; set; }
   public int? MessagesSent { get; set; }
   public string? Timestamp { get; set; }
   public Dictionary<string, object>? AdditionalData { get; set; }
}
```

## 🌍 Environment Variable Reference

### Production Environment
```bash
# Production API endpoints
CCAI_BASE_URL=https://core.cloudcontactai.com/api
CCAI_EMAIL_BASE_URL=https://email-campaigns.cloudcontactai.com/  
CCAI_AUTH_BASE_URL=https://auth.cloudcontactai.com/
```

### Test Environment  
```bash
# Test API endpoints
CCAI_TEST_BASE_URL=https://core-test-cloudcontactai.allcode.com/api
CCAI_TEST_EMAIL_BASE_URL=https://email-campaigns-test-cloudcontactai.allcode.com/
CCAI_TEST_AUTH_BASE_URL=https://auth-test-cloudcontactai.allcode.com/
```

### Authentication
```bash
# API credentials
CCAI_CLIENT_ID=your-client-id
CCAI_API_KEY=your-api-key
```

## 🧪 Testing and Validation

### Custom Data Webhook Testing
1. **Setup Environment**: Configure webhook URL in CCAI dashboard
2. **Send Test SMS**: Use custom data examples to send test messages
3. **Monitor Webhooks**: Verify custom data appears in webhook payloads
4. **Validate Responses**: Confirm delivery status and reply handling

### Environment Configuration Testing
1. **Production Testing**: Verify production environment connectivity
2. **Test Environment**: Validate test environment functionality  
3. **URL Override**: Test custom URL configuration
4. **Fallback Behavior**: Verify default URL fallback when env vars not set

## 🔄 Migration Guide

### From v1.2.0 to v1.3.0
**No breaking changes!** Simply update your package reference:

```bash
dotnet add package CloudContactAI.CCAI.NET --version 1.3.0
```

### Leveraging New Features
```csharp
// Add custom data to existing SMS calls
var response = await smsService.SendSingleAsync(
   firstName: "John",
   lastName: "Doe",
   phone: "+1234567890",
   message: "Your message",
   title: "Campaign Title",
   customData: "TrackingID:12345"  // NEW: Add this parameter
);

// Use environment variables for configuration
var config = new CCAIConfig
{
   ClientId = Environment.GetEnvironmentVariable("CCAI_CLIENT_ID"),
   ApiKey = Environment.GetEnvironmentVariable("CCAI_API_KEY"),
   UseTestEnvironment = true  // NEW: Enable test environment
};
```

## 📊 Performance and Reliability

### Enhanced Error Handling
- **Validation**: Improved parameter validation with descriptive error messages
- **Retry Logic**: Enhanced retry mechanisms for failed requests
- **Timeout Handling**: Better timeout management for long-running operations
- **Connection Management**: Optimized HTTP client usage and connection pooling

### Webhook Reliability
- **Payload Validation**: Comprehensive validation of webhook payloads
- **Custom Data Integrity**: Ensures custom data is properly transmitted and received
- **Delivery Tracking**: Enhanced delivery status tracking and reporting
- **Error Recovery**: Improved error handling for webhook delivery failures

## 🐛 Bug Fixes

- **Phone Number Validation**: Fixed phone number format validation in examples
- **Environment Loading**: Improved environment variable loading and error handling
- **Custom Data Encoding**: Fixed custom data encoding issues in webhook payloads
- **Test Environment URLs**: Corrected test environment URL resolution logic
- **Example Projects**: Fixed compilation issues in example projects

## 📞 Support and Resources

### Documentation
- **API Reference**: Complete XML documentation for all new methods
- **Examples**: Working examples for all new functionality
- **Webhook Guide**: Comprehensive webhook integration guide
- **Environment Setup**: Step-by-step environment configuration guide

### Testing Resources
- **Test Projects**: Complete test projects for validation
- **Sample Data**: Sample custom data formats and examples
- **Webhook Payloads**: Example webhook payload structures
- **Troubleshooting**: Common issues and solutions guide

## 🎯 What's Next

Future releases may include:
- **Advanced Custom Data**: Structured custom data with schema validation
- **Webhook Filtering**: Advanced webhook filtering based on custom data
- **Batch Operations**: Enhanced batch processing with custom data support
- **Analytics Integration**: Built-in analytics and reporting for custom data
- **Template Engine**: Advanced message templating with custom data integration

---

**CloudContactAI.CCAI.NET v1.3.0 - Enhanced SMS functionality with comprehensive custom data support and flexible environment configuration! 🚀📱**

*This version significantly enhances SMS capabilities with custom data support for advanced webhook integration while maintaining full backward compatibility and adding flexible environment-based configuration.*