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 VConSharpusingVConSharp;// Create a new vConvarvcon=VCon.BuildNew();// Add partiesvarparty1=newParty(newDictionary<string,object>{["tel"]="+1234567890",["name"]="John Doe"});varparty2=newParty(newDictionary<string,object>{["tel"]="+0987654321",["name"]="Jane Smith"});vcon.AddParty(party1);vcon.AddParty(party2);// Add a dialogvardialog=newDialog("text/plain",DateTime.UtcNow,new[]{0,1});dialog.Body="Hello, this is a conversation!";dialog.Mimetype="text/plain";vcon.AddDialog(dialog);// Convert to JSONstringjson=vcon.ToJson();usingVConSharp;stringjsonString="...";// Your vCon JSON stringvarvcon=VCon.BuildFromJson(jsonString);usingVConSharp;varvcon=VCon.BuildNew();// Add an attachmentvarattachment=vcon.AddAttachment("application/pdf","base64EncodedContent",Encoding.Base64);// Find an attachment by typevarpdfAttachment=vcon.FindAttachmentByType("application/pdf");usingVConSharp;varvcon=VCon.BuildNew();// Add analysisvcon.AddAnalysis(newDictionary<string,object>{["type"]="sentiment",["dialog"]=0,// Reference to dialog index["vendor"]="sentiment-analyzer",["body"]=newDictionary<string,object>{["score"]=0.8,["label"]="positive"}});// Find analysis by typevarsentimentAnalysis=vcon.FindAnalysisByType("sentiment");usingVConSharp;varvcon=VCon.BuildNew();// Add a tagvcon.AddTag("category","support");// Get a tagstringcategory=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 builddotnet testdotnet run --project VConSharp.Examples/VConSharp.Examples.csprojPlease 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