SoluCX JS SDK
How to use
- First you must to configure the SDK Client with your API Key provided by SoluCX.
- For each survey, you must first require the survey.
- This step will ask for the server for the current customer. It will return the a Survey or it will throw an error.
Installing
npm install --save @solucx/survey-js-sdk
Using Example
import { Survey } from "@solucx/survey-js-sdk";
const apiKey = "{CHAVE DA API}";
const surveyRequestData = {
storeId: "1234",
employeeId: "1234",
name: "Fulano da Silva",
email: "fulano@email.com",
amount: 1.99,
journey: "e-commerce",
};
const survey = await Survey.createSurvey(apiKey, surveyRequestData);
survey.rating = 10;
survey.comment = "Somme Comment";
survey.anonymous = false;
survey.items[0].score = 1;
survey.items[0].rating = "negative";
survey.items[1].score = 2;
survey.items[1].rating = "positive";
survey.items[2].score = 1;
survey.items[2].rating = "neutral";
const result = await survey.submitRating();
Survey Request Data Options
transactionId : alphanumeric Field with a unique transaction id from the company itself to establish a direct link in the exports of the reports. - ex 564425232
clientId : numeric Field with unique customer id from the company itself to establish a direct link in the exports of - ex reports 3445667
storeId : alphanumeric Mandatory Field with unit id from the company itself to establish a direct link in the exports of the reports. Must be registered in the system - ex 12332
employeeId : alphanumeric Mandatory Field with id of the employee participating in the sale from the company itself to establish a direct link in the exports of the reports, if not provided a generic will be assigned. - ex 3424342
name : Mandatory text Customer Name - ex Maria
email : Mandatory text Customer Email - ex maria@email.com
phone : 10/11-digit Customer Telephone number - ex 11999990000
phone2 : numeric Second Customer phone number with 10 or 11 digits - ex 11999991111
cpf : Customer CPF number - ex 01234567890
gender : "M", "F" or "-" Gender of Customer - ex F
birthDate : YYYY-mm-dd Customer Birth Date - ex 1980-12-31
amount : positive decimal Mandatory Transaction amount - ex 87.20
rating : numeric score that will be marked in the survey, value from 0 to 10. - ex 10
journey : Journey of what the customer performed the transaction - ex: e-commerce
source : Source that the survey is being collected - ex 'email'
Survey Response Parameters
transactionId
attemptId
storeId
employeeId
rating
comment
anonymous
items
parameters
Survey Parameters
export interface JourneyParameters {
sendButtonText?: string;
surveyTitle?: string;
name?: string;
logo?: string;
color?: string;
question?: string;
displayType?: DisplayType;
inputType?: InputType;
npsColor?: boolean;
classesLabel?: string;
commentLabel?: string;
commentNegativeLabel?: string;
classesNotRequired?: boolean;
showClasses?: boolean;
allowHtml?: boolean;
showComment?: boolean;
showAnonymous?: boolean;
showEmailEnrichment?: boolean;
showPhoneEnrichment?: boolean;
showMoreThan6Classes?: boolean;
showInHouseAds?: boolean;
customAcknowledgmentHTML?: string;
showDocumentEnrichment?: boolean;
showSendButton?: boolean;
saveInitialRating?: boolean;
successTitle?: string;
successMessage?: string;
thanksMessage?: string;
dateTimeMessage?: string;
template?: string;
customStyle?: string;
hideCredits?: boolean;
privacyLinks?: PrivacyLink[];
preEnrich?: boolean;
}
Items parameters
export interface ClassItem {
classId: number;
name: string;
order: number;
type: ClassItemType;
rating?: ClassRating;
score?: number