A .NET library for creating and managing vCons (Virtual Conversations).
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#.
dotnet add package VConSharp
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();
using VConSharp;
string jsonString = "..."; // Your vCon JSON string
var vcon = VCon.BuildFromJson(jsonString);
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");
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");
using VConSharp;
var vcon = VCon.BuildNew();
// Add a tag
vcon.AddTag("category", "support");
// Get a tag
string category = vcon.GetTag("category");
The main class for working with vCons.
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
Class for representing parties in a vCon.
Tel
: Telephone numberStir
: STIR identifierMailto
: Email addressName
: Display nameValidation
: Validation informationGmlpos
: GML positionCivicAddress
: Civic addressUuid
: UUIDRole
: RoleContactList
: Contact listMeta
: Additional metadata
Class for representing dialogs in a vCon.
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
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
dotnet build
dotnet test
dotnet run --project VConSharp.Examples/VConSharp.Examples.csproj
Please see our contributing guidelines for how to contribute to this project.
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.
MIT