@solucx/survey-js-sdk
v0.1.1
Published
rm
Downloads
6
Readme
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: "[email protected]",
amount: 1.99,
journey: "e-commerce",
};
// Creates a survey to be rated
const survey = await Survey.createSurvey(apiKey, surveyRequestData);
// Set User Response
survey.rating = 10;
survey.comment = "Somme Comment";
survey.anonymous = false;
// Set Items score and rating
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";
// Submit Rating
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 564425232clientId
: numeric Field with unique customer id from the company itself to establish a direct link in the exports of - ex reports 3445667storeId
: 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 12332employeeId
: 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 3424342name
: Mandatory text Customer Name - ex Mariaemail
: Mandatory text Customer Email - ex [email protected]phone
: 10/11-digit Customer Telephone number - ex 11999990000phone2
: numeric Second Customer phone number with 10 or 11 digits - ex 11999991111cpf
: Customer CPF number - ex 01234567890gender
: "M", "F" or "-" Gender of Customer - ex FbirthDate
: YYYY-mm-dd Customer Birth Date - ex 1980-12-31amount
: positive decimal Mandatory Transaction amount - ex 87.20rating
: numeric score that will be marked in the survey, value from 0 to 10. - ex 10journey
: Journey of what the customer performed the transaction - ex: e-commercesource
: 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 {
/** id da classe a ser avaliada */
classId: number;
/** texto da classe */
name: string;
/** Ordem q a classe vai aparecer */
order: number;
/** Tipo da classe */
type: ClassItemType;
/** Avaliação do item */
rating?: ClassRating;
/** Nota do item */
score?: number