VConSharp 0.2.1
dotnet add package VConSharp --version 0.2.1
NuGet\Install-Package VConSharp -Version 0.2.1
<PackageReference Include="VConSharp" Version="0.2.1" />
<PackageVersion Include="VConSharp" Version="0.2.1" />
<PackageReference Include="VConSharp" />
paket add VConSharp --version 0.2.1
#r "nuget: VConSharp, 0.2.1"
#:package VConSharp@0.2.1
#addin nuget:?package=VConSharp&version=0.2.1
#tool nuget:?package=VConSharp&version=0.2.1
VConSharp
A .NET library for creating and managing vCons (Virtual Conversations).
Overview
VConSharp is a .NET implementation of the vCon specification, converted from the original vcon-js TypeScript library. It allows you to create, manipulate, and analyze virtual conversations in C#.
Installation
dotnet add package VConSharp
Usage
Creating a new vCon
using VConSharp;
// Create a new vCon
var vcon = VCon.BuildNew();
// Add parties
var party1 = new Party(new Dictionary<string, object>
{
["tel"] = "+1234567890",
["name"] = "John Doe"
});
var party2 = new Party(new Dictionary<string, object>
{
["tel"] = "+0987654321",
["name"] = "Jane Smith"
});
vcon.AddParty(party1);
vcon.AddParty(party2);
// Add a dialog
var dialog = new Dialog(
"text/plain",
DateTime.UtcNow,
new[] { 0, 1 }
);
dialog.Body = "Hello, this is a conversation!";
dialog.Mimetype = "text/plain";
vcon.AddDialog(dialog);
// Convert to JSON
string json = vcon.ToJson();
Loading from JSON
using VConSharp;
string jsonString = "..."; // Your vCon JSON string
var vcon = VCon.BuildFromJson(jsonString);
Working with Attachments
using VConSharp;
var vcon = VCon.BuildNew();
// Add an attachment
var attachment = vcon.AddAttachment(
"application/pdf",
"base64EncodedContent",
Encoding.Base64
);
// Find an attachment by type
var pdfAttachment = vcon.FindAttachmentByType("application/pdf");
Working with Analysis
using VConSharp;
var vcon = VCon.BuildNew();
// Add analysis
vcon.AddAnalysis(new Dictionary<string, object>
{
["type"] = "sentiment",
["dialog"] = 0, // Reference to dialog index
["vendor"] = "sentiment-analyzer",
["body"] = new Dictionary<string, object>
{
["score"] = 0.8,
["label"] = "positive"
}
});
// Find analysis by type
var sentimentAnalysis = vcon.FindAnalysisByType("sentiment");
Working with Tags
using VConSharp;
var vcon = VCon.BuildNew();
// Add a tag
vcon.AddTag("category", "support");
// Get a tag
string category = vcon.GetTag("category");
API Reference
VCon
The main class for working with vCons.
Methods
static BuildNew()
: Creates a new vConstatic BuildFromJson(jsonString)
: Creates a vCon from JSONAddParty(party)
: Adds a party to the vConAddDialog(dialog)
: Adds a dialog to the vConAddAttachment(type, body, encoding)
: Adds an attachmentAddAnalysis(parameters)
: Adds analysis dataAddTag(tagName, tagValue)
: Adds a tagFindPartyIndex(by, val)
: Finds a party indexFindDialog(by, val)
: Finds a dialogFindAttachmentByType(type)
: Finds an attachment by typeFindAnalysisByType(type)
: Finds analysis by typeGetTag(tagName)
: Gets a tag valueToJson()
: Converts the vCon to JSONSign(privateKey)
: Signs the vCon with JWSVerify(publicKey)
: Verifies the vCon signatureGenerateKeyPair()
: Generates a new RSA key pair for signing
Party
Class for representing parties in a vCon.
Properties
Tel
: Telephone numberStir
: STIR identifierMailto
: Email addressName
: Display nameValidation
: Validation informationGmlpos
: GML positionCivicAddress
: Civic addressUuid
: UUIDRole
: RoleContactList
: Contact listMeta
: Additional metadata
Dialog
Class for representing dialogs in a vCon.
Properties
Type
: Dialog typeStart
: Start timeParties
: Party indicesOriginator
: Originator party indexMimetype
: MIME typeFilename
: FilenameBody
: Dialog contentEncoding
: Content encodingUrl
: External URLSignature
: Digital signatureDuration
: Duration in secondsMeta
: Additional metadata
Methods
AddExternalData(url, filename, mimetype)
: Adds external dataAddInlineData(body, filename, mimetype)
: Adds inline dataIsExternalData()
: Checks if dialog has external dataIsInlineData()
: Checks if dialog has inline dataIsText()
: Checks if dialog is textIsAudio()
: Checks if dialog is audioIsVideo()
: Checks if dialog is videoIsEmail()
: Checks if dialog is email
Development
Building the Project
dotnet build
Running Tests
dotnet test
Running Examples
dotnet run --project VConSharp.Examples/VConSharp.Examples.csproj
Contributing
Please see our contributing guidelines for how to contribute to this project.
Versioning and Releases
We use SemVer for versioning. The GitHub Actions workflow will automatically build, test, and publish new releases to NuGet.org when you create a tag with the format vX.Y.Z
.
To create a new release:
- Ensure all tests pass
- Create a tag:
git tag v1.0.0
- Push the tag to GitHub:
git push origin v1.0.0
The version number in the NuGet package will be derived from the tag name.
License
MIT
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. 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. |
-
net9.0
- Microsoft.Extensions.Http (>= 9.0.6)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.6)
- System.Text.Json (>= 9.0.6)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on VConSharp:
Package | Downloads |
---|---|
VConSharp.Examples
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.