CloudContactAI.CCAI.NET 1.4.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.4.0
                    
NuGet\Install-Package CloudContactAI.CCAI.NET -Version 1.4.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.4.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.4.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.4.0
                    
#r "nuget: CloudContactAI.CCAI.NET, 1.4.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.4.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.4.0
                    
Install as a Cake Addin
#tool nuget:?package=CloudContactAI.CCAI.NET&version=1.4.0
                    
Install as a Cake Tool

C# client for CloudContactAI API with SMS, MMS, Email, and Webhook support. Enhanced webhook support with new CloudContact event format, environment variable configuration, and comprehensive examples.

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

# CCAI.NET v1.4.0 Release Notes - [CloudContactAI](https://cloudcontactai.com/)

## 🚀 New Features

### Enhanced Webhook Support
- **New CloudContact Webhook Format**: Added support for the new CloudContact webhook event structure with 5 event types:
 - `message.sent` - Message successfully sent to recipient
 - `message.incoming` - Incoming message from recipient
 - `message.excluded` - Message excluded during campaign creation
 - `message.error.carrier` - Carrier-level delivery errors
 - `message.error.cloudcontact` - CloudContact system errors

- **New Webhook Classes**:
 - `CloudContactWebhookEvent` - Main webhook event wrapper
 - `WebhookEventData` - Comprehensive event data with pricing, segments, and error details
 - Enhanced `WebhookService` with `ParseCloudContactEvent()` method

### Updated Event Types
- **Breaking Change**: Renamed `MessageReceived` to `MessageIncoming` for consistency
- **Legacy Support**: Maintained backward compatibility with existing webhook implementations
- **New Event Classes**: Added `MessageIncomingEvent` to replace deprecated `MessageReceivedEvent`

## 🔧 Improvements

### Environment Variable Support
- **BasicExample**: Now loads `ClientId`, `ApiKey`, `FirstName`, `LastName`, and `Phone` from environment variables
- **Flexible Configuration**: Falls back to sensible defaults when environment variables are not set

### Code Quality
- **Cleaned Examples**: Removed 18+ redundant example files for better maintainability
- **Fixed Build Warnings**: Resolved all unreachable code and entry point conflicts
- **Improved Structure**: Streamlined examples directory with 10 core, comprehensive examples

## 📝 Enhanced Examples

### New Webhook Examples
- **webhook_cloudcontact_example.cs**: Demonstrates parsing new CloudContact webhook format
- **webhook_endpoint_example.cs**: Production-ready ASP.NET Core webhook controller
- **Enhanced webhook server**: Updated with emoji indicators and event-specific processing

### Updated Examples
- **BasicExample.cs**: Environment variable integration for account data
- **WebhookExample.cs**: Updated to use new `MessageIncoming` event type
- All webhook registration examples updated with new event types

## 🛠️ Technical Changes

### Webhook Service Enhancements
```csharp
// New method for parsing CloudContact webhooks
public CloudContactWebhookEvent? ParseCloudContactEvent(string json)

// Enhanced event data with new properties
public record WebhookEventData
{
   public decimal? TotalPrice { get; init; }
   public int? Segments { get; init; }
   public string? ExcludedReason { get; init; }
   public string? ErrorCode { get; init; }
   public string? ErrorMessage { get; init; }
   // ... and more
}
```

### Environment Variables
- `CCAI_CLIENT_ID` - Your CloudContact client ID
- `CCAI_API_KEY` - Your CloudContact API key
- `CCAI_FIRST_NAME` - Test recipient first name (optional)
- `CCAI_LAST_NAME` - Test recipient last name (optional)
- `CCAI_PHONE` - Test recipient phone number (optional)

## 🔄 Migration Guide

### Webhook Event Types
```csharp
// Old (deprecated)
WebhookEventType.MessageReceived

// New
WebhookEventType.MessageIncoming
```

### Webhook Event Classes
```csharp
// Old (deprecated)
MessageReceivedEvent receivedEvent

// New
MessageIncomingEvent incomingEvent
```

## 📦 Dependencies
- No new dependencies added
- Maintained compatibility with .NET 8.0
- DotNetEnv package already included for environment variable support

## 🐛 Bug Fixes
- Fixed build warnings related to unreachable code
- Resolved entry point conflicts in examples project
- Fixed webhook event type references in all examples

---

**Full Changelog**: Compare changes from v1.3.0 to v1.4.0 for complete details.