dec-client v1.0.12
Digital Experience Cloud Client
Unofficial client for the Sitefinity Digital Experience Cloud.
For additional information, please see the Digital Experience Cloud documentation.
Installing
npm install dec-clientThen within your application, you can reference the client with the following:
var DECClient = require('dec-client');Usage
Create a new DECClient(). Make sure to provide your data center API key, and a source label.
var client = new DECClient({
     apiKey: 'your-api-key',
     source: 'your-datasource-label'
});Writing Sentences
client.writeSentence({
    subjectKey: 'the-subject-key',
    predicate: 'the-predicate',
    object: 'the-object'
});Tracking Subject Metadata
Subject Metadata documentation
client.writeSubjectMetadata('the-subject-key', {
    FirstName: 'first-name',
    LastName: 'last-name',
    Email: 'contact-email'
    // additional meta fields...
});Adding Subject Mapping
client.addMapping('the-subject-key', 'second-subject-key', 'second-datasource-label');Sending Sentences to the Digital Experience Cloud
The client allows you to write multiple interactions sentences at a time. Once all interactions have been written, you must flushData() to actually send them to the DEC.
// returns a promise
client.flushData();Personalization
You can make a call to the DEC to retrieve information about the subject's Personas, Campaigns, and Lead Scores.
Create a new DECClient(). Make sure to provide your data center API key, a source label, and an authToken.
var client = new DECClient({
     apiKey: 'your-api-key',
     source: 'your-datasource-label',
     authToken: 'appauth your-app-auth-key'
});The authToken is used by an authorized application to request data from the personalization end-points. You can construct the token by concatenating the "appauth " string with the Access Key of the authorized application, for example: "appauth 94e8b2d2-931e-cd01-b57b-07fa2013cb24".
An Authorized Application can be configured by navigating to the "Authorized applications" in the Administration section of your Data Center.
client.isInPersonas('1', 'the-subject-key')
.then(function (response) {
    var personas = JSON.parse(response).items;
    if (personas.length) {
        // do something
    }
})Example Response
{"items":[{"Id":1,"Score":100,"ThresholdPassedOn":"2017-08-11T01:45:21.120Z","Threshold":100}]}