Improved HelpScout-Nodes

This commit is contained in:
Jan Oberhauser 2020-03-29 19:10:54 +02:00
parent 6e6bb7781b
commit 83e6e8bf11
13 changed files with 1259 additions and 1256 deletions

View file

@ -1,4 +1,4 @@
import { INodeProperties } from "n8n-workflow"; import { INodeProperties } from 'n8n-workflow';
export const conversationOperations = [ export const conversationOperations = [
{ {
@ -310,7 +310,7 @@ export const conversationFields = [
alwaysOpenEditWindow: true alwaysOpenEditWindow: true
}, },
default: '', default: '',
description: 'The message text, ' description: 'The message text.'
}, },
{ {
displayName: 'Bcc', displayName: 'Bcc',
@ -428,6 +428,13 @@ export const conversationFields = [
}, },
}, },
options: [ options: [
{
displayName: 'Assign To',
name: 'assignTo',
type: 'number',
default: 0,
description: 'Filters conversations by assignee id',
},
{ {
displayName: 'Embed', displayName: 'Embed',
name: 'embed', name: 'embed',
@ -441,13 +448,6 @@ export const conversationFields = [
default: '', default: '',
description: 'Allows embedding/loading of sub-entities', description: 'Allows embedding/loading of sub-entities',
}, },
{
displayName: 'Mailbox ID',
name: 'mailbox',
type: 'string',
default: '',
description: 'Filters conversations from a specific mailbox',
},
{ {
displayName: 'Folder ID', displayName: 'Folder ID',
name: 'folder', name: 'folder',
@ -456,54 +456,11 @@ export const conversationFields = [
description: 'Filters conversations from a specific folder id', description: 'Filters conversations from a specific folder id',
}, },
{ {
displayName: 'Status', displayName: 'Mailbox ID',
name: 'status', name: 'mailbox',
type: 'options', type: 'string',
options: [ default: '',
{ description: 'Filters conversations from a specific mailbox',
name: 'Active',
value: 'active',
},
{
name: 'All',
value: 'all',
},
{
name: 'Closed',
value: 'closed',
},
{
name: 'Open',
value: 'open',
},
{
name: 'Pending',
value: 'pending',
},
{
name: 'Spam',
value: 'spam',
},
],
default: 'active',
description: 'Filter conversation by status',
},
{
displayName: 'Tags',
name: 'tags',
type: 'multiOptions',
typeOptions: {
loadOptionsMethod: 'getTags',
},
default: [],
description: 'Filter conversation by tags',
},
{
displayName: 'Assign To',
name: 'assignTo',
type: 'number',
default: 0,
description: 'Filters conversations by assignee id',
}, },
{ {
displayName: 'Modified Since', displayName: 'Modified Since',
@ -522,6 +479,16 @@ export const conversationFields = [
}, },
description: 'Looks up conversation by conversation number', description: 'Looks up conversation by conversation number',
}, },
{
displayName: 'Query',
name: 'query',
type: 'string',
typeOptions: {
alwaysOpenEditWindow: true,
},
default: '',
description: 'Advanced search <a href="https://developer.helpscout.com/mailbox-api/endpoints/conversations/list/#query">Examples</a>'
},
{ {
displayName: 'Sort Field', displayName: 'Sort Field',
name: 'sortField', name: 'sortField',
@ -584,14 +551,47 @@ export const conversationFields = [
default: 'desc', default: 'desc',
}, },
{ {
displayName: 'Query', displayName: 'Status',
name: 'query', name: 'status',
type: 'string', type: 'options',
options: [
{
name: 'Active',
value: 'active',
},
{
name: 'All',
value: 'all',
},
{
name: 'Closed',
value: 'closed',
},
{
name: 'Open',
value: 'open',
},
{
name: 'Pending',
value: 'pending',
},
{
name: 'Spam',
value: 'spam',
},
],
default: 'active',
description: 'Filter conversation by status',
},
{
displayName: 'Tags',
name: 'tags',
type: 'multiOptions',
typeOptions: { typeOptions: {
alwaysOpenEditWindow: true, loadOptionsMethod: 'getTags',
}, },
default: '', default: [],
description: 'Advanced search <a href="https://developer.helpscout.com/mailbox-api/endpoints/conversations/list/#query">Examples</a>' description: 'Filter conversation by tags',
}, },
], ],
}, },

View file

@ -1,4 +1,4 @@
import { IDataObject } from "n8n-workflow"; import { IDataObject } from 'n8n-workflow';
export interface IConversation { export interface IConversation {
assignTo?: number; assignTo?: number;
@ -8,11 +8,11 @@ export interface IConversation {
customer?: IDataObject; customer?: IDataObject;
fields?: IDataObject[]; fields?: IDataObject[];
imported?: boolean; imported?: boolean;
mailboxId?: number; // mailboxId?: number;
status?: string; // status?: string;
subject?: string; // subject?: string;
tags?: IDataObject[]; tags?: IDataObject[];
threads?: IDataObject[]; threads?: IDataObject[];
type?: string; // type?: string;
user?: number; user?: number;
} }

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
import { INodeProperties } from "n8n-workflow"; import { INodeProperties } from 'n8n-workflow';
export const customerOperations = [ export const customerOperations = [
{ {
@ -18,11 +18,6 @@ export const customerOperations = [
value: 'create', value: 'create',
description: 'Create a new customer', description: 'Create a new customer',
}, },
{
name: 'Properties',
value: 'properties',
description: 'Get customer property definitions',
},
{ {
name: 'Get', name: 'Get',
value: 'get', value: 'get',
@ -33,6 +28,11 @@ export const customerOperations = [
value: 'getAll', value: 'getAll',
description: 'Get all customers', description: 'Get all customers',
}, },
{
name: 'Properties',
value: 'properties',
description: 'Get customer property definitions',
},
{ {
name: 'Update', name: 'Update',
value: 'update', value: 'update',
@ -92,16 +92,6 @@ export const customerFields = [
default: 1, default: 1,
description: `Customers age`, description: `Customers age`,
}, },
{
displayName: 'Notes',
name: 'background',
type: 'string',
typeOptions: {
alwaysOpenEditWindow: true,
},
default: '',
description: `Notes`,
},
{ {
displayName: 'First Name', displayName: 'First Name',
name: 'firstName', name: 'firstName',
@ -151,6 +141,16 @@ export const customerFields = [
default: '', default: '',
description: 'Location of the customer.', description: 'Location of the customer.',
}, },
{
displayName: 'Notes',
name: 'background',
type: 'string',
typeOptions: {
alwaysOpenEditWindow: true,
},
default: '',
description: `Notes`,
},
{ {
displayName: 'Organization', displayName: 'Organization',
name: 'organization', name: 'organization',
@ -267,39 +267,39 @@ export const customerFields = [
type: 'options', type: 'options',
options: [ options: [
{ {
name: 'aim', name: 'AIM',
value: 'aim', value: 'aim',
}, },
{ {
name: 'gtalk', name: 'Google Talk',
value: 'gtalk', value: 'gtalk',
}, },
{ {
name: 'icq', name: 'ICQ',
value: 'icq', value: 'icq',
}, },
{ {
name: 'msn', name: 'MSN',
value: 'msn', value: 'msn',
}, },
{ {
name: 'other', name: 'Other',
value: 'other', value: 'other',
}, },
{ {
name: 'qq', name: 'QQ',
value: 'qq', value: 'qq',
}, },
{ {
name: 'skype', name: 'Skype',
value: 'skype', value: 'skype',
}, },
{ {
name: 'xmpp', name: 'XMPP',
value: 'xmpp', value: 'xmpp',
}, },
{ {
name: 'yahoo', name: 'Yahoo',
value: 'yahoo', value: 'yahoo',
}, },
], ],
@ -584,13 +584,6 @@ export const customerFields = [
}, },
}, },
options: [ options: [
{
displayName: 'Mailbox ID',
name: 'mailbox',
type: 'string',
default: '',
description: 'Filters customers from a specific mailbox',
},
{ {
displayName: 'First Name', displayName: 'First Name',
name: 'firstName', name: 'firstName',
@ -605,6 +598,13 @@ export const customerFields = [
default: '', default: '',
description: 'Filters customers by last name', description: 'Filters customers by last name',
}, },
{
displayName: 'Mailbox ID',
name: 'mailbox',
type: 'string',
default: '',
description: 'Filters customers from a specific mailbox',
},
{ {
displayName: 'Modified Since', displayName: 'Modified Since',
name: 'modifiedSince', name: 'modifiedSince',
@ -733,16 +733,6 @@ export const customerFields = [
default: 1, default: 1,
description: `Customers age`, description: `Customers age`,
}, },
{
displayName: 'Notes',
name: 'background',
type: 'string',
typeOptions: {
alwaysOpenEditWindow: true,
},
default: '',
description: `Notes`,
},
{ {
displayName: 'First Name', displayName: 'First Name',
name: 'firstName', name: 'firstName',
@ -792,6 +782,16 @@ export const customerFields = [
default: '', default: '',
description: 'Location of the customer.', description: 'Location of the customer.',
}, },
{
displayName: 'Notes',
name: 'background',
type: 'string',
typeOptions: {
alwaysOpenEditWindow: true,
},
default: '',
description: `Notes`,
},
{ {
displayName: 'Organization', displayName: 'Organization',
name: 'organization', name: 'organization',
@ -806,6 +806,6 @@ export const customerFields = [
default: '', default: '',
description: 'URL of the customers photo', description: 'URL of the customers photo',
}, },
] ],
}, },
] as INodeProperties[]; ] as INodeProperties[];

View file

@ -1,4 +1,4 @@
import { IDataObject } from "n8n-workflow"; import { IDataObject } from 'n8n-workflow';
export interface ICustomer { export interface ICustomer {
address?: IDataObject; address?: IDataObject;

View file

@ -1,9 +1,9 @@
import { OptionsWithUri } from 'request'; import { OptionsWithUri } from 'request';
import { import {
IHookFunctions,
IExecuteFunctions, IExecuteFunctions,
IExecuteSingleFunctions, IExecuteSingleFunctions,
ILoadOptionsFunctions, ILoadOptionsFunctions,
IHookFunctions,
} from 'n8n-core'; } from 'n8n-core';
import { import {
IDataObject, IDataObject,
@ -43,7 +43,8 @@ export async function helpscoutApiRequest(this: IExecuteFunctions | IExecuteSing
return `${error.path} ${error.message}`; return `${error.path} ${error.message}`;
}).join('-')}`); }).join('-')}`);
} }
throw error;
throw new Error(`HelpScout error response [${error.statusCode}]: ${error.message}`);
} }
} }

View file

@ -3,56 +3,57 @@ import {
} from 'n8n-core'; } from 'n8n-core';
import { import {
IBinaryKeyData,
IDataObject, IDataObject,
ILoadOptionsFunctions,
INodeExecutionData, INodeExecutionData,
INodePropertyOptions,
INodeTypeDescription, INodeTypeDescription,
INodeType, INodeType,
ILoadOptionsFunctions,
INodePropertyOptions,
IBinaryKeyData,
} from 'n8n-workflow'; } from 'n8n-workflow';
import { import {
helpscoutApiRequest, countriesCodes
helpscoutApiRequestAllItems, } from './CountriesCodes';
} from './GenericFunctions';
import { import {
conversationOperations,
conversationFields, conversationFields,
conversationOperations,
} from './ConversationDescription'; } from './ConversationDescription';
import { import {
customerOperations,
customerFields, customerFields,
customerOperations,
} from './CustomerDescription'; } from './CustomerDescription';
import {
mailboxOperations,
mailboxFields,
} from './MailboxDescription';
import {
threadOperations,
threadFields,
} from './ThreadDescription';
import { import {
ICustomer, ICustomer,
} from './CustomerInterface'; } from './CustomerInterface';
import { import {
IConversation, IConversation,
} from './ConversationInterface'; } from './ConversationInterface';
import { import {
IThread, helpscoutApiRequest,
helpscoutApiRequestAllItems,
} from './GenericFunctions';
import {
mailboxFields,
mailboxOperations,
} from './MailboxDescription';
import {
threadFields,
threadOperations,
} from './ThreadDescription';
import {
IAttachment, IAttachment,
} from './ThreadInterface'; IThread,
} from './ThreadInterface';
import {
countriesCodes
} from './CountriesCodes';
export class HelpScout implements INodeType { export class HelpScout implements INodeType {
description: INodeTypeDescription = { description: INodeTypeDescription = {

View file

@ -4,10 +4,10 @@ import {
} from 'n8n-core'; } from 'n8n-core';
import { import {
INodeTypeDescription,
INodeType,
IWebhookResponseData,
IDataObject, IDataObject,
INodeType,
INodeTypeDescription,
IWebhookResponseData,
} from 'n8n-workflow'; } from 'n8n-workflow';
import { import {
@ -51,52 +51,53 @@ export class HelpScoutTrigger implements INodeType {
name: 'events', name: 'events',
type: 'multiOptions', type: 'multiOptions',
options: [ options: [
{ {
name: 'convo.agent.reply.created', name: 'Conversation - Assigned',
value: 'convo.agent.reply.created',
},
{
name: 'convo.assigned',
value: 'convo.assigned', value: 'convo.assigned',
}, },
{ {
name: 'convo.created', name: 'Conversation - Created',
value: 'convo.created', value: 'convo.created',
}, },
{ {
name: 'convo.customer.reply.created', name: 'Conversation - Deleted',
value: 'convo.customer.reply.created',
},
{
name: 'convo.deleted',
value: 'convo.deleted', value: 'convo.deleted',
}, },
{ {
name: 'convo.merged', name: 'Conversation - Merged',
value: 'convo.merged', value: 'convo.merged',
}, },
{ {
name: 'convo.moved', name: 'Conversation - Moved',
value: 'convo.moved', value: 'convo.moved',
}, },
{ {
name: 'convo.note.created', name: 'Conversation - Status',
value: 'convo.note.created',
},
{
name: 'convo.status',
value: 'convo.status', value: 'convo.status',
}, },
{ {
name: 'convo.tags', name: 'Conversation - Tags',
value: 'convo.tags', value: 'convo.tags',
}, },
{ {
name: 'customer.created', name: 'Conversation Agent Reply - Created',
value: 'convo.agent.reply.created',
},
{
name: 'Conversation Customer Reply - Created',
value: 'convo.customer.reply.created',
},
{
name: 'Conversation Note - Created',
value: 'convo.note.created',
},
{
name: 'Customer - Created',
value: 'customer.created', value: 'customer.created',
}, },
{ {
name: 'satisfaction.ratings', name: 'Rating - Received',
value: 'satisfaction.ratings', value: 'satisfaction.ratings',
}, },
], ],

View file

@ -1,4 +1,4 @@
import { INodeProperties } from "n8n-workflow"; import { INodeProperties } from 'n8n-workflow';
export const mailboxOperations = [ export const mailboxOperations = [
{ {

View file

@ -1,4 +1,4 @@
import { INodeProperties } from "n8n-workflow"; import { INodeProperties } from 'n8n-workflow';
export const threadOperations = [ export const threadOperations = [
{ {
@ -128,6 +128,12 @@ export const threadFields = [
}, },
}, },
options: [ options: [
{
displayName: 'Created At',
name: 'createdAt',
type: 'dateTime',
default: '',
},
{ {
displayName: 'Customer Email', displayName: 'Customer Email',
name: 'customerEmail', name: 'customerEmail',
@ -161,12 +167,6 @@ export const threadFields = [
default: false, default: false,
description: 'When imported is set to true, no outgoing emails or notifications will be generated.', description: 'When imported is set to true, no outgoing emails or notifications will be generated.',
}, },
{
displayName: 'Created At',
name: 'createdAt',
type: 'dateTime',
default: '',
},
] ]
}, },
{ {

View file

@ -1,4 +1,4 @@
import { IDataObject } from "n8n-workflow"; import { IDataObject } from 'n8n-workflow';
export interface IAttachment { export interface IAttachment {
fileName?: string; fileName?: string;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 870 B

View file

@ -198,8 +198,8 @@
"@types/gm": "^1.18.2", "@types/gm": "^1.18.2",
"@types/imap-simple": "^4.2.0", "@types/imap-simple": "^4.2.0",
"@types/jest": "^24.0.18", "@types/jest": "^24.0.18",
"@types/lodash.set": "^4.3.6", "@types/lodash.set": "^4.3.6",
"@types/moment-timezone": "^0.5.12", "@types/moment-timezone": "^0.5.12",
"@types/mongodb": "^3.3.6", "@types/mongodb": "^3.3.6",
"@types/node": "^10.10.1", "@types/node": "^10.10.1",
"@types/nodemailer": "^4.6.5", "@types/nodemailer": "^4.6.5",
@ -225,8 +225,8 @@
"imap-simple": "^4.3.0", "imap-simple": "^4.3.0",
"lodash.get": "^4.4.2", "lodash.get": "^4.4.2",
"lodash.set": "^4.3.2", "lodash.set": "^4.3.2",
"lodash.unset": "^4.5.2", "lodash.unset": "^4.5.2",
"moment-timezone": "0.5.28", "moment-timezone": "0.5.28",
"mongodb": "^3.3.2", "mongodb": "^3.3.2",
"mysql2": "^2.0.1", "mysql2": "^2.0.1",
"n8n-core": "~0.20.0", "n8n-core": "~0.20.0",