glassix

1.0.80 • Public • Published

Official JavaScript client library of the Glassix REST API

NPM version NPM downloads

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:

const payload = {
    participants: [
      {
        type: "Client",
        protocolType: "Mail",
        subProtocolType: "MailTo",
        name: "David Gilmour",
        identifier: "david.gilmour@gmail.com"
      }
    ],
    tags: [
      "Info"
    ]
  };
const newTicket = await client.tickets.create(payload);

Get:

const ticket = await client.tickets.get(ticketId);
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);
const payload = {
    text: 'Hello!'
};
const result = await client.tickets.send(ticketId, payload);
  const payload = {
      nextState: "Closed"
  };
  const result = await client.tickets.setState(ticketId, payload);
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);
const payload = {
    id: 1,
    name: "Brenda Rahman"
};
const result = await client.tickets.setParticipantName(ticketId, payload);
const payload = {
    nextOwnerUserName: "alinamiss@acme.com",
    keepCurrentOwnerInConversation: false
};
const result = await client.tickets.setOwner(ticketId, payload);
const result = await client.tickets.assignAvailableUser(ticketId);
const payload = {
  departmentId: '5baf94b7-4ebb-4442-81a5-27ac4dd1f03f'
};
const result = await client.tickets.setDepartment(ticketId, payload);
const newTags = ['Sales', 'Excel'];
const nextTags = await client.tickets.addTags(ticketId, newTags);
const payload = {
  tag: 'Sales'
};
const result = await client.tickets.removeTag(ticketId, payload);
const payload = {
  text: 'Ye on properly handsome returned throwing am no whatever.'
};
const result = await client.tickets.addNote(ticketId, payload);
const result = await client.tickets.scramble(ticketId);

PDF:

const payload = {
  includeDetails: true,
  includeConversationLink: false,
  includeNotes: true
};
const result = await client.tickets.pdf(ticketId, payload);
const payload = {
  includeDetails: true,
  includeConversationLink: false,
  includeNotes: true
};
const result = await client.tickets.html(ticketId, payload);
const payload = {
  surveyId: 73993,
  participantId: 1
};
const result = await client.tickets.generateSurveyLink(ticketId, payload);

Users:

const users = await client.users.getAll();
const payload = {
    nextStatus: "Break"
};
const result = await client.users.setStatus(payload);
const status = await client.users.getStatus();

Add:

const params = {
    role: "SystemUser", 
    userType: "AGENT"
};
const payload = [{
    uniqueArgument: "exampleValue", 
    userName: "john.doe@gmail.com"
}];
const result = await client.users.add(payload, params);
const userName = {
    userName: "john.doe@gmail.com"
};
const result = await client.users.delete(userName);
const uniqueArgument = {
    nextUniqueArgument: "John Doe's unique argument"
};
const result = await client.users.setUniqueArgument(uniqueArgument);
const payload = {
        shortName: "John",
        fullName: "John Doe",
        jobTitle: "customer support representative"
    };
const result = await client.users.update(payload);
const uniqueArgument = {
    uniqueArgument: "John Doe's unique argument"
};
const user = await client.users.getByUniqueArgument(uniqueArgument);
const userName = {
    userName: "john.doe@gmail.com"
};
const roles = ["DepartmentAdmin", "SystemUser"];
const result = await client.users.setRoles(roles, userName);

Tenants:

const parameters = {
    departmentId: "YOUR_API_KEY", 
    protocolType: "Mail"
};
const result = await client.tenants.isOnline(parameters);
const tags = await client.tenants.getTags();

Contacts:

Get:

const contact = await client.contacts.get(contactId);
const payload = {
    nextName: "Jane Doe"
};
const result = await client.contacts.setName(contactId, payload);
const payload = {
    forceMerge: false, 
    identifierType: "MailAddress", 
    identifier: "jane.doe@gmail.com"
};
const result = await client.contacts.addIdentifier(contactId, payload);
const payload = {
    nextUniqueArgument: "Jane Doe's unique argument"
};
const result = await client.contacts.setUniqueArgument(contactId, payload);
const params = {
    contactIdentifierId: 1
};
const result = await client.contacts.deleteIdentifier(contactId, params);

Canned Replies:

const cannedReplies = await client.cannedReplies.getAll();

Interactive documents:

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:

const payload = {
    protocolType: "Whatsapp",
    text: "Hi",
    from: "972524646214",
    to: "972547101833"
};
const result = await client.protocols.send(payload);

Phone Calls:

const payload = {
    dateTime: "24/12/2020 11:20:00:22"
};
const result = await client.phoneCalls.started(ticketId, payload);
const payload = {
    dateTime: "24/12/2020 11:25:00:22"
};
const result = await client.phoneCalls.ended(ticketId, payload);
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:

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 = "john.doe@gmail.com";
const result = await client.getToken(userName);

License

Apache-2.0

Readme

Keywords

Package Sidebar

Install

npm i glassix

Weekly Downloads

41

Version

1.0.80

License

Apache-2.0

Unpacked Size

150 kB

Total Files

26

Last publish

Collaborators

  • glassix.com