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 = options;try const token = await helpscouttoken; // Get a result console;catchex // Catch an error console;;
- 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 = options;try const refresh_token = ".................."; const token = await helpscouttoken; // Get a result console;catchex // Catch an error console;;
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 = options;try // List mailboxes const mailboxes = await helpscoutmailbox; // Get a result console;catchex // Catch an error console;;
// import `helpscout-v2` and pass your `options` value.const helpscout = options;try // Get information from mailbox id `1` const mailbox = await helpscoutmailbox; // Get a result console;catchex // Catch an error console;;
- 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 = options;try // List mailboxes const mailboxes = await helpscoutmailbox; // Get a result console;catchex // Catch an error console;;
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 = options;try // List conversations const conversations = await helpscoutconversation; // Get a result console;catchex // Catch an error console;;
- 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 = options;try // Get a conversation const conversation = await helpscoutconversation; // Get a result console;catchex // Catch an error console;;