@zervise/zervise-api
v1.0.0
Published
A Promise based Node.js wrapper of Zervise API for easily integrating any node app with Zervise's customer support portal and ticketing system.
Downloads
17
Readme
A Promise based Node.js wrapper of Zervise API for easily integrating any Node app with Zervise's customer support portal and ticketing system.
Table of Contents
Zervise
- Add an efficient ticketing system for free, Free Plan comes with No credit card, upto 5 agents
- Unlimited Users
- Unlimited Tickets
- SLA Management
- Email Notification
- Ticket Creation by Web
- Ticket creation through Chat
- Real Time Chat with Agent
- Real Time Ticket Update
Features
- Integrate your Zervise subdomain with your other app.
- Add an efficient ticketing system for your customers.
- View tickets to manage your customer complaints.
- Authenticate your users in Zervise subdomain with their email.
- Show the FAQs for your Zervise subdomain in your other apps.
Installing
- Using npm:
$ npm install @zervise/zervise-api
- Using yarn:
$ yarn add @zervise/zervise-api
Your Zervise Subdomain
Sign Up in Zervise
For using this package you need a Zervise account and a Zervise subdomain.
To create a Free Zervise Account and get your own Zervise subdomain
head over to this link 👉 Sign Up in Zervise.
Find your Zervise subdomain
Upon succesfull sign up you should receive one email with your zervise subdomain link in the registered email address.
Example
If your link is https://zervisefree-qee_ro1a8jwr.zervise.com/
, then your zervise subdoamin is zervisefree-qee_ro1a8jwr
.
Examples
Import to your project
import {
authenticate,
createTicket,
authAndCreate,
getUserTickets,
replyAsUser,
getUserFaqs,
} from 'zervise-integration';
or,
const {
authenticate,
createTicket,
authAndCreate,
getUserTickets,
replyAsUser,
getUserFaqs,
} = require('zervise-integration');
Authenticate and Create Tickets
- 2 step process
// Step 1: Authenticate user
authenticate('zervisefree-qee_ro1a8jwr', {
name: 'test-user',
email: '[email protected]',
mobile: '+918555198553', // optional
appName: 'my-app', // optional
})
.then((data) => {
console.log(data);
// Step 2: Create a ticket with the tocken recived
createTicket(data.token, 'zervisefree-qee_ro1a8jwr', {
description: 'Issue described by your user',
priority: 'high', // optional
tags: ['refund', 'return'], // optional
}).then((ticketData) => {
// Ticket created in your Zervise Subdomain
console.log(ticketData);
});
// View the tickets created by the user
getUserTickets(data.token).then((data) => console.log(data));
})
.catch((err) => console.log(err));
- 1 step process
// Authenticate user and create a ticket in a single step
authAndCreate('zervisefree-qee_ro1a8jwr', {
name: 'test-user',
email: '[email protected]',
mobile: '+918555198553', // optional
appName: 'my-app', // optional
description: 'Issue described by your user',
priority: 'high', // optional
tags: ['refund', 'return'], // optional
})
.then((data) => {
console.log(data);
// View the tickets created by the user
getUserTickets(data.token).then((data) => console.log(data));
})
.catch((err) => console.log(err));
Reply to a ticket as the user
let token;
authenticate('zervisefree-qee_ro1a8jwr', {
name: 'test-user',
email: '[email protected]',
mobile: '+918555198553', // optional
appName: 'my-app', // optional
})
.then((data) => {
console.log(data);
// save the token
token = data.token;
// Get the tickets created by the user
getUserTickets(data.token)
.then((tickets) => {
console.log(tickets);
/* tickets array
[
{
"_id": "612cd35301992244bb806ae6",
"ticketDescription": "tciekt description text.",
"ticketHeading": "ticket heading text.",
"clientId": "6318f23840609d218f30019d",
"createdPersonId": "61609dfc01992114bb806adf",
"dateCreated": "2021-08-18T09:30:59.906Z",
...
},
{...},
...
]
*/
// Replying to the 1st ticket
// You can reply to any of the tickets
// using its "_id".
replyAsUser(token, tickets[0]._id, {
message: 'Reply message text',
})
.then((ticket) => {
// Reply successfull
// Ticket object is returned
console.log(ticket);
})
.catch((err) => console.log(err));
})
.catch((err) => console.log(err));
})
.catch((err) => console.log(err));
Get the FAQ articles of your company for users
getUserFaqs('zervisefree-qee_ro1a8jwr').then((articles) => {
// FAQ articles
console.log(articles);
});
Zervise API
authenticate(subdomain, {name, email[, mobile, appName]})
For authenticating user with your subdomain.
const data = await authenticate('zervisefree-qee_ro1a8jwr', {
name: 'test-user',
email: '[email protected]',
mobile: '+918555198553', // optional
appName: 'my-app', // optional
});
/*
data = {
person: <object with user details>,
token: <authentication token for the user>,
subdomain: <your subdomain URL>
}
*/
createTicket(token, subdomain, {description[, priority, tags]})
For creating a ticket.
const ticket = await createTicket(
data.token, // token received from authenticate() method
'zervisefree-qee_ro1a8jwr',
{
description: 'Issue described by your user',
priority: 'high', // optional
tags: ['refund', 'return'], // optional
}
);
/*
ticket = <ticket object>
*/
authAndCreate(subdomain, {name, email[, mobile, appName, description, priority, tags]})
For authenticating user with your subdomain and create a ticket in a single step.
const data = await authAndCreate('zervisefree-qee_ro1a8jwr', {
name: 'test-user',
email: '[email protected]',
mobile: '+918555198553', // optional
appName: 'my-app', // optional
description: 'Issue described by your user',
priority: 'high', // optional
tags: ['refund', 'return'], // optional
});
/*
data = {
person: <object with user details>,
token: <authentication token for the user>,
ticket: <ticket object>
subdomain: <your subdomain URL>
}
*/
getUserTickets(token)
For getting all the tickets of a specific user with authentication token.
const tickets = await getUserTickets(data.token);
// "data.token" is the token received from authenticate() or authAndCreate() method.
/*
// array of tickets
tickets = [
<ticket object>,
<ticket object>,
<ticket object>,
...
]
*/
replyAsUser(token, ticketId, {message})
For replying to a ticket as an user with the authentication token.
// ticketId is the "_id" field inside a ticket object.
const ticket = await replyAsUser(data.token, ticket._id, {
message: 'Reply message text',
});
// "data.token" is the token received from authenticate() or authAndCreate() method.
/*
ticket = <ticket object>
*/
getUserFaqs(subdomain)
For getting the FAQs of your company.
const faqs = await getUserFaqs('zervisefree-qee_ro1a8jwr');
/*
// array of FAQ articles
faqs = [
<FAQ object>,
<FAQ object>,
<FAQ object>,
...
]
*/
Resources
Issues
If you encounter any issue while using the package please report it here 👉 Zervise API > Issues