glassix
v1.0.92
Published
Glassix Client API
Downloads
233
Readme
Glassix
Official JavaScript client library of the Glassix REST API
Installation:
NPM:
npm i glassix
Usage:
Import:
import glassix from 'glassix';
Or using require:
const glassix = require('glassix');
Create a client:
const clientOptions = {
// Your glassix subdomain
workspace: process.env.WORKSPACE,
// Find your key and secret on Settings → Developers → Api keys
apiKey: process.env.API_KEY,
apiSecret: process.env.API_SECRET,
// A user with access to your department, preferably an API user
userName: process.env.USER_NAME
};
const client = new glassix(clientOptions);
Methods:
Tickets:
Create:
const payload = {
participants: [
{
type: "Client",
protocolType: "Mail",
subProtocolType: "MailTo",
name: "David Gilmour",
identifier: "[email protected]"
}
],
tags: [
"Info"
]
};
const newTicket = await client.tickets.create(payload);
Get:
const ticket = await client.tickets.get(ticketId);
List:
let payload = {
since: '01/07/2023 00:00:00:00',
until: '30/07/2023 23:59:59:00'
};
const tickets = await client.tickets.list(payload);
Send:
const payload = {
text: 'Hello!'
};
const result = await client.tickets.send(ticketId, payload);
Set state:
const payload = {
nextState: "Closed"
};
const result = await client.tickets.setState(ticketId, payload);
Set fields:
let payload = {
field1: "The great gig in the sky",
uniqueArgument: "8bc5812f-22cb-4dda-89a4-7dc93a123ede",
details: {
source: {
title: "My Landing Page",
uri: "https://www.example.com/landing-page"
}
}
};
const result = await client.tickets.setFields(ticketId, payload);
Set participant name:
const payload = {
id: 1,
name: "Brenda Rahman"
};
const result = await client.tickets.setParticipantName(ticketId, payload);
Set ticket owner:
const payload = {
nextOwnerUserName: "[email protected]",
keepCurrentOwnerInConversation: false
};
const result = await client.tickets.setOwner(ticketId, payload);
Assign available user:
const result = await client.tickets.assignAvailableUser(ticketId);
Set department:
const payload = {
departmentId: '5baf94b7-4ebb-4442-81a5-27ac4dd1f03f'
};
const result = await client.tickets.setDepartment(ticketId, payload);
Add tags:
const newTags = ['Sales', 'Excel'];
const nextTags = await client.tickets.addTags(ticketId, newTags);
Remove tag:
const payload = {
tag: 'Sales'
};
const result = await client.tickets.removeTag(ticketId, payload);
Add note:
const payload = {
text: 'Ye on properly handsome returned throwing am no whatever.'
};
const result = await client.tickets.addNote(ticketId, payload);
Scramble:
const result = await client.tickets.scramble(ticketId);
PDF:
const payload = {
includeDetails: true,
includeConversationLink: false,
includeNotes: true
};
const result = await client.tickets.pdf(ticketId, payload);
HTML:
const payload = {
includeDetails: true,
includeConversationLink: false,
includeNotes: true
};
const result = await client.tickets.html(ticketId, payload);
Generate survey link:
const payload = {
surveyId: 73993,
participantId: 1
};
const result = await client.tickets.generateSurveyLink(ticketId, payload);
Users:
Get all:
const users = await client.users.getAll();
Set status:
const payload = {
nextStatus: "Break"
};
const result = await client.users.setStatus(payload);
Get status:
const status = await client.users.getStatus();
Add:
const params = {
role: "SystemUser",
userType: "AGENT"
};
const payload = [{
uniqueArgument: "exampleValue",
userName: "[email protected]"
}];
const result = await client.users.add(payload, params);
Delete:
const userName = {
userName: "[email protected]"
};
const result = await client.users.delete(userName);
Set unique argument:
const uniqueArgument = {
nextUniqueArgument: "John Doe's unique argument"
};
const result = await client.users.setUniqueArgument(uniqueArgument);
Update:
const payload = {
shortName: "John",
fullName: "John Doe",
jobTitle: "customer support representative"
};
const result = await client.users.update(payload);
Get by unique argument:
const uniqueArgument = {
uniqueArgument: "John Doe's unique argument"
};
const user = await client.users.getByUniqueArgument(uniqueArgument);
Set roles:
const userName = {
userName: "[email protected]"
};
const roles = ["DepartmentAdmin", "SystemUser"];
const result = await client.users.setRoles(roles, userName);
Tenants:
Is online:
const parameters = {
departmentId: "YOUR_API_KEY",
protocolType: "Mail"
};
const result = await client.tenants.isOnline(parameters);
Get tags:
const tags = await client.tenants.getTags();
Contacts:
Get:
const contact = await client.contacts.get(contactId);
Set name:
const payload = {
nextName: "Jane Doe"
};
const result = await client.contacts.setName(contactId, payload);
Add identifier:
const payload = {
forceMerge: false,
identifierType: "MailAddress",
identifier: "[email protected]"
};
const result = await client.contacts.addIdentifier(contactId, payload);
Set unique argument:
const payload = {
nextUniqueArgument: "Jane Doe's unique argument"
};
const result = await client.contacts.setUniqueArgument(contactId, payload);
Delete identifier:
const params = {
contactIdentifierId: 1
};
const result = await client.contacts.deleteIdentifier(contactId, params);
Canned Replies:
Get all:
const cannedReplies = await client.cannedReplies.getAll();
Interactive documents:
Send:
const payload = {
shouldLockDocument: false,
baseTemplateId: 20,
message: "Please enter your full name in the document.",
fields: [
{
type: "Text",
name: "fullName_1"
}
]
};
const result = await client.interactiveDocuments.send(ticketId, payload);
Protocols:
Send:
const payload = {
protocolType: "Whatsapp",
text: "Hi",
from: "972524646214",
to: "972547101833"
};
const result = await client.protocols.send(payload);
Phone Calls:
Started:
const payload = {
dateTime: "24/12/2020 11:20:00:22"
};
const result = await client.phoneCalls.started(ticketId, payload);
Ended:
const payload = {
dateTime: "24/12/2020 11:25:00:22"
};
const result = await client.phoneCalls.ended(ticketId, payload);
Audio Link:
const payload = {
audioUri: "https://file-examples-com.github.io/uploads/2017/11/file_example_OOG_1MG.ogg"
};
const result = await client.phoneCalls.audioLink(ticketId, payload);
Files:
Upload:
const payload = new FormData();
const response = await fetch('https://example.com/some-file.txt');
const blob = await response.blob();
const file = new File([blob], "downloaded_example.txt", {
type: "text/plain",
});
payload.append(0, file);
const result = await client.files.upload(payload);
Token:
Get:
const userName = "[email protected]";
const result = await client.getToken(userName);
Events:
Get Events:
const payload = {
deleteEvent: "false"
};
const result = await client.webhooks.getevents(payload);
License
Apache-2.0