helpscout-v2 v0.0.2
Unofficial HelpScout SDK for HelpScout API v2
This is my very first SDK integrated with HelpScout API, please feel free to use. If you have questions or issues, please feel free to open a new issue on this repository.
NPM
npm i --save helpscout-v2
How to use
const helpscout = require('helpscout-v2')(options);
Parameters
All parameters for
options
are listed by below.
Parameter | Description |
---|---|
client_id | A hash string which is generated by HelpScout (App ID) |
client_secret | A hash string which is generated by HelpScout (App Secret) |
access_token | A hash string which can be got it by authentication function. |
Token
- Authentication: helpscout.token.authenticate()
// import `helpscout-v2` and pass your `options` value.
const helpscout = require('helpscout-v2')(options);
try {
const token = await helpscout.token.authenticate();
// Get a result
console.log(token);
}catch(ex) {
// Catch an error
console.log(ex);
};
- Refresh Access Token: helpscout.token.refreshAccessToken(options)
Parameter | Description |
---|---|
refresh_token | A hash string which can be got it by authentication function. |
// import `helpscout-v2` and pass your `options` value.
const helpscout = require('helpscout-v2')(options);
try {
const refresh_token = "..................";
const token = await helpscout.token.refreshAccessToken({ refresh_token });
// Get a result
console.log(token);
}catch(ex) {
// Catch an error
console.log(ex);
};
Mailbox
- List mailboxes: helpscout.mailbox.get([id ,options])
id
| Parameter | Description |
|-------------|-------------|
| id
(optional) | A mailbox id |
options
| Parameter | Description |
|-------------|-------------|
| access_token
(optional) | (Override) A hash string which can be got it by authentication function. |
// import `helpscout-v2` and pass your `options` value.
const helpscout = require('helpscout-v2')(options);
try {
// List mailboxes
const mailboxes = await helpscout.mailbox.get();
// Get a result
console.log(mailboxes);
}catch(ex) {
// Catch an error
console.log(ex);
};
// import `helpscout-v2` and pass your `options` value.
const helpscout = require('helpscout-v2')(options);
try {
// Get information from mailbox id `1`
const mailbox = await helpscout.mailbox.get(1);
// Get a result
console.log(mailbox);
}catch(ex) {
// Catch an error
console.log(ex);
};
- Get mailbox folders: helpscout.mailbox.getFolders(id ,options)
id
| Parameter | Description |
|-------------|-------------|
| id
| A mailbox id |
options
| Parameter | Description |
|-------------|-------------|
| access_token
(optional) | (Override) A hash string which can be got it by authentication function. |
// import `helpscout-v2` and pass your `options` value.
const helpscout = require('helpscout-v2')(options);
try {
// List mailboxes
const mailboxes = await helpscout.mailbox.getFolders(1);
// Get a result
console.log(mailboxes);
}catch(ex) {
// Catch an error
console.log(ex);
};
Conversation
- Get list of conversations: helpscout.conversation.list(options) Please refer to HelpScout document on how to use those parameters. (https://developer.helpscout.com/mailbox-api/endpoints/conversations/list/)
options
Parameter | Description |
---|---|
mailbox | Filters conversations from a specific mailbox id. Use comma separated values for more mailboxes: ?mailbox=123,456 |
folder | Filters conversations from a specific folder id: ?folder=993 |
status | Filter conversation by status (defaults to active ): active open closed pending spam all |
tag | Filter conversation by tags. Use comma separated values for more tags that: ?tag=red,blue |
assigned_to | Filters conversations by assignee id: ?assigned_to=1771 |
modifiedSince | Filters conversations modified after this timestamp - ISO 8061 date time |
number | Looks up conversation by conversation number |
sortField | Sorts the result by specified field: createdAt customerEmail customerName mailboxid modifiedAt number score status subject |
sortOrder | Sort order, either desc or asc , default is desc |
query | Advanced search query. If you use other filtering request parameters, they will be combined with AND operator.For example ?mailbox=567&query=tag:fire effectively means mailbox=567 AND tag=fire . |
page | Page number |
// import `helpscout-v2` and pass your `options` value.
const helpscout = require('helpscout-v2')(options);
try {
// List conversations
const conversations = await helpscout.conversation.list();
// Get a result
console.log(conversations);
}catch(ex) {
// Catch an error
console.log(ex);
};
- Get a conversation: helpscout.conversation.get(id, options) Please refer to HelpScout document on how to use those parameters. (https://developer.helpscout.com/mailbox-api/endpoints/conversations/get/)
id
| Parameter | Description |
|-------------|-------------|
| id
(optional) | A conversation id |
options
| Parameter | Description |
|-------------|-------------|
| access_token
(optional) | (Override) A hash string which can be got it by authentication function. |
// import `helpscout-v2` and pass your `options` value.
const helpscout = require('helpscout-v2')(options);
try {
// Get a conversation
const conversation = await helpscout.conversation.get(123);
// Get a result
console.log(conversation);
}catch(ex) {
// Catch an error
console.log(ex);
};
4 years ago