Decision engine Javascript library
CustomerForge Decision engine NodeJs/Javascript client library.
Learn more about API endpoint definitions here https://customerforge.ai/docs
Installation
npm install @customerforgejs/decision-js
Getting started guide
const CF = require('@customerforgejs/decision-js');
CF.Auth.set({
clientId: 'your_client_id',
clientSecret: 'your_client_secret'
}
Create a simple journey
Create your simple journey with an event.
const Journey = new CF.Journey('simple-journey');
await Journey.create(
[
{
event_id: 'login',
},
]
)
Track user interactions
Your user will be created in a segment with the given properties. In this instance, our team will receive a Slack message after a the user's login.
const Profile = new CF.Profile('user_id');
const profile = await Profile.identify({user_properties: {name: 'Foo'}})
const Interaction = new CF.Interaction(profile._id);
await Interaction.track('login')
Subscribe to a destination
You can implement your own destination or utilse destinations in the marketplace. All secrets are encrypted at rest using he Advanced Encryption Standard (AES) algorithm, AES-256 and this API always communicates over a secure HTTP(s) connection.
const details = {
url: "https://slack.com/api/chat.postMessage",
data: {
channel: "C04BJK2GYT1",
text: "{user.fullName} has logged in!"
},
auth: {
bearer_token: 'slack-auth-token'
}
method: "post"
}
const Destination = new CF.Destination('Slack')
await Destination.subscribe('journey-id', details)
Realtime achievement listener
const Achievement = new CF.Achievement('profileId')
Achievement.onGain(data => {
console.log(data)
})