mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
🔀 Merge branch 'feature/helpscout-node' of https://github.com/RicardoE105/n8n into RicardoE105-feature/helpscout-node
This commit is contained in:
commit
6e6bb7781b
|
@ -0,0 +1,46 @@
|
|||
import {
|
||||
ICredentialType,
|
||||
NodePropertyTypes,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export class HelpScoutOAuth2Api implements ICredentialType {
|
||||
name = 'helpScoutOAuth2Api';
|
||||
extends = [
|
||||
'oAuth2Api',
|
||||
];
|
||||
displayName = 'HelpScout OAuth2 API';
|
||||
properties = [
|
||||
{
|
||||
displayName: 'Authorization URL',
|
||||
name: 'authUrl',
|
||||
type: 'hidden' as NodePropertyTypes,
|
||||
default: 'https://secure.helpscout.net/authentication/authorizeClientApplication',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Access Token URL',
|
||||
name: 'accessTokenUrl',
|
||||
type: 'hidden' as NodePropertyTypes,
|
||||
default: 'https://api.helpscout.net/v2/oauth2/token',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Scope',
|
||||
name: 'scope',
|
||||
type: 'hidden' as NodePropertyTypes,
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Auth URI Query Parameters',
|
||||
name: 'authQueryParameters',
|
||||
type: 'hidden' as NodePropertyTypes,
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Authentication',
|
||||
name: 'authentication',
|
||||
type: 'hidden' as NodePropertyTypes,
|
||||
default: 'body',
|
||||
},
|
||||
];
|
||||
}
|
598
packages/nodes-base/nodes/HelpScout/ConversationDescription.ts
Normal file
598
packages/nodes-base/nodes/HelpScout/ConversationDescription.ts
Normal file
|
@ -0,0 +1,598 @@
|
|||
import { INodeProperties } from "n8n-workflow";
|
||||
|
||||
export const conversationOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'conversation',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a new conversation',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete a conversation',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a conversation',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get all conversations',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const conversationFields = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* conversation:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Mailbox',
|
||||
name: 'mailboxId',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getMailboxes',
|
||||
},
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'conversation',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'ID of a mailbox where the conversation is being created',
|
||||
},
|
||||
{
|
||||
displayName: 'Status',
|
||||
name: 'status',
|
||||
type: 'options',
|
||||
required: true,
|
||||
options: [
|
||||
{
|
||||
name: 'Active',
|
||||
value: 'active',
|
||||
},
|
||||
{
|
||||
name: 'Closed',
|
||||
value: 'closed',
|
||||
},
|
||||
{
|
||||
name: 'Pending',
|
||||
value: 'pending',
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'conversation',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Conversation status',
|
||||
},
|
||||
{
|
||||
displayName: 'Subject',
|
||||
name: 'subject',
|
||||
type: 'string',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'conversation',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: `Conversation’s subject`,
|
||||
},
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'type',
|
||||
required: true,
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Chat',
|
||||
value: 'chat',
|
||||
},
|
||||
{
|
||||
name: 'Email',
|
||||
value: 'email',
|
||||
},
|
||||
{
|
||||
name: 'Phone',
|
||||
value: 'phone',
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'conversation',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Conversation type',
|
||||
},
|
||||
{
|
||||
displayName: 'Resolve Data',
|
||||
name: 'resolveData',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'conversation',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'By default the response only contain the ID to resource<br />. If this option gets activated it<br />will resolve the data automatically.',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'conversation',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Assign To',
|
||||
name: 'assignTo',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
description: 'The Help Scout user assigned to the conversation.',
|
||||
},
|
||||
{
|
||||
displayName: 'Auto Reply',
|
||||
name: 'autoReply',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: `When autoReply is set to true, an auto reply will be sent</br>
|
||||
as long as there is at least one customer thread in the conversation.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Closed At',
|
||||
name: 'closedAt',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: `When the conversation was closed, only applicable for imported conversations`,
|
||||
},
|
||||
{
|
||||
displayName: 'Created At',
|
||||
name: 'createdAt',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: `When this conversation was created - ISO 8601 date time`,
|
||||
},
|
||||
{
|
||||
displayName: 'Customer Email',
|
||||
name: 'customerEmail',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Customer ID',
|
||||
name: 'customerId',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
},
|
||||
{
|
||||
displayName: 'Imported',
|
||||
name: 'imported',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: `When imported is set to true, no outgoing emails or notifications will be generated.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Tags',
|
||||
name: 'tags',
|
||||
type: 'multiOptions',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTags',
|
||||
},
|
||||
default: [],
|
||||
description: 'List of tags to be be added to the conversation',
|
||||
},
|
||||
{
|
||||
displayName: 'User ID',
|
||||
name: 'user',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
description: 'ID of the user who is adding the conversation and threads.',
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Threads',
|
||||
name: 'threadsUi',
|
||||
placeholder: 'Add Thread',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'conversation',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Thread',
|
||||
name: 'threadsValues',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'type',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Chat',
|
||||
value: 'chat'
|
||||
},
|
||||
{
|
||||
name: 'Customer',
|
||||
value: 'customer'
|
||||
},
|
||||
{
|
||||
name: 'Note',
|
||||
value: 'note'
|
||||
},
|
||||
{
|
||||
name: 'Phone',
|
||||
value: 'phone'
|
||||
},
|
||||
{
|
||||
name: 'Reply',
|
||||
value: 'reply'
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Text',
|
||||
name: 'text',
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true
|
||||
},
|
||||
default: '',
|
||||
description: 'The message text, '
|
||||
},
|
||||
{
|
||||
displayName: 'Bcc',
|
||||
name: 'bcc',
|
||||
displayOptions: {
|
||||
show: {
|
||||
type: [
|
||||
'customer'
|
||||
],
|
||||
},
|
||||
},
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
multipleValueButtonText: 'Add Email',
|
||||
},
|
||||
default: [],
|
||||
description: 'Email addresses.'
|
||||
},
|
||||
{
|
||||
displayName: 'Cc',
|
||||
name: 'cc',
|
||||
displayOptions: {
|
||||
show: {
|
||||
type: [
|
||||
'customer'
|
||||
],
|
||||
},
|
||||
},
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
multipleValueButtonText: 'Add Email',
|
||||
},
|
||||
default: [],
|
||||
description: 'Email addresses.'
|
||||
},
|
||||
{
|
||||
displayName: 'Draft',
|
||||
name: 'draft',
|
||||
displayOptions: {
|
||||
show: {
|
||||
type: [
|
||||
'reply'
|
||||
],
|
||||
},
|
||||
},
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'If set to true, a draft reply is created',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* conversation:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Conversation ID',
|
||||
name: 'conversationId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'conversation',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'conversation ID',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* conversation:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Conversation ID',
|
||||
name: 'conversationId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'conversation',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'conversation ID',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* conversation:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Option',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'conversation',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Embed',
|
||||
name: 'embed',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Threads',
|
||||
value: 'threads',
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
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',
|
||||
name: 'folder',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Filters conversations from a specific folder id',
|
||||
},
|
||||
{
|
||||
displayName: 'Status',
|
||||
name: 'status',
|
||||
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: {
|
||||
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',
|
||||
name: 'modifiedSince',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Returns only conversations that were modified after this date',
|
||||
},
|
||||
{
|
||||
displayName: 'Number',
|
||||
name: 'number',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
typeOptions: {
|
||||
minValue: 0,
|
||||
},
|
||||
description: 'Looks up conversation by conversation number',
|
||||
},
|
||||
{
|
||||
displayName: 'Sort Field',
|
||||
name: 'sortField',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Created At',
|
||||
value: 'createdAt',
|
||||
},
|
||||
{
|
||||
name: 'customer Email',
|
||||
value: 'customerEmail',
|
||||
},
|
||||
{
|
||||
name: 'customer Name',
|
||||
value: 'customerName',
|
||||
},
|
||||
{
|
||||
name: 'Mailbox ID',
|
||||
value: 'mailboxid',
|
||||
},
|
||||
{
|
||||
name: 'Modified At',
|
||||
value: 'modifiedAt',
|
||||
},
|
||||
{
|
||||
name: 'Number',
|
||||
value: 'number',
|
||||
},
|
||||
{
|
||||
name: 'Score',
|
||||
value: 'score',
|
||||
},
|
||||
{
|
||||
name: 'Status',
|
||||
value: 'status',
|
||||
},
|
||||
{
|
||||
name: 'Subject',
|
||||
value: 'subject',
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
description: 'Sorts the result by specified field',
|
||||
},
|
||||
{
|
||||
displayName: 'Sort Order',
|
||||
name: 'sortOrder',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'ASC',
|
||||
value: 'asc',
|
||||
},
|
||||
{
|
||||
name: 'Desc',
|
||||
value: 'desc',
|
||||
},
|
||||
],
|
||||
default: 'desc',
|
||||
},
|
||||
{
|
||||
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>'
|
||||
},
|
||||
],
|
||||
},
|
||||
] as INodeProperties[];
|
18
packages/nodes-base/nodes/HelpScout/ConversationInterface.ts
Normal file
18
packages/nodes-base/nodes/HelpScout/ConversationInterface.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { IDataObject } from "n8n-workflow";
|
||||
|
||||
export interface IConversation {
|
||||
assignTo?: number;
|
||||
autoReply?: boolean;
|
||||
closedAt?: string;
|
||||
createdAt?: string;
|
||||
customer?: IDataObject;
|
||||
fields?: IDataObject[];
|
||||
imported?: boolean;
|
||||
mailboxId?: number; //
|
||||
status?: string; //
|
||||
subject?: string; //
|
||||
tags?: IDataObject[];
|
||||
threads?: IDataObject[];
|
||||
type?: string; //
|
||||
user?: number;
|
||||
}
|
1579
packages/nodes-base/nodes/HelpScout/CountriesCodes.ts
Normal file
1579
packages/nodes-base/nodes/HelpScout/CountriesCodes.ts
Normal file
File diff suppressed because it is too large
Load diff
811
packages/nodes-base/nodes/HelpScout/CustomerDescription.ts
Normal file
811
packages/nodes-base/nodes/HelpScout/CustomerDescription.ts
Normal file
|
@ -0,0 +1,811 @@
|
|||
import { INodeProperties } from "n8n-workflow";
|
||||
|
||||
export const customerOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'customer',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a new customer',
|
||||
},
|
||||
{
|
||||
name: 'Properties',
|
||||
value: 'properties',
|
||||
description: 'Get customer property definitions',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a customer',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get all customers',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update a customer',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const customerFields = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* customer:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Resolve Data',
|
||||
name: 'resolveData',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'customer',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'By default the response only contain the ID to resource<br />. If this option gets activated it<br />will resolve the data automatically.',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'customer',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Age',
|
||||
name: 'age',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
},
|
||||
default: 1,
|
||||
description: `Customer’s age`,
|
||||
},
|
||||
{
|
||||
displayName: 'Notes',
|
||||
name: 'background',
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true,
|
||||
},
|
||||
default: '',
|
||||
description: `Notes`,
|
||||
},
|
||||
{
|
||||
displayName: 'First Name',
|
||||
name: 'firstName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: `First name of the customer. When defined it must be between 1 and 40 characters.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Gender',
|
||||
name: 'gender',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Female',
|
||||
value: 'female',
|
||||
},
|
||||
{
|
||||
name: 'Male',
|
||||
value: 'male',
|
||||
},
|
||||
{
|
||||
name: 'Unknown',
|
||||
value: 'unknown',
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
description: 'Gender of this customer.',
|
||||
},
|
||||
{
|
||||
displayName: 'Job Title',
|
||||
name: 'jobTitle',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Job title. Max length 60 characters.',
|
||||
},
|
||||
{
|
||||
displayName: 'Last Name',
|
||||
name: 'lastName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Last name of the customer',
|
||||
},
|
||||
{
|
||||
displayName: 'Location',
|
||||
name: 'location',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Location of the customer.',
|
||||
},
|
||||
{
|
||||
displayName: 'Organization',
|
||||
name: 'organization',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Organization',
|
||||
},
|
||||
{
|
||||
displayName: 'Photo Url',
|
||||
name: 'photoUrl',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'URL of the customer’s photo',
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Address',
|
||||
name: 'addressUi',
|
||||
placeholder: 'Add Address',
|
||||
type: 'fixedCollection',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'customer',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Address',
|
||||
name: 'addressValue',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Line 1',
|
||||
name: 'line1',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'line1',
|
||||
},
|
||||
{
|
||||
displayName: 'Line 2',
|
||||
name: 'line2',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'line2',
|
||||
},
|
||||
{
|
||||
displayName: 'City',
|
||||
name: 'city',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'City',
|
||||
},
|
||||
{
|
||||
displayName: 'State',
|
||||
name: 'state',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'State',
|
||||
},
|
||||
{
|
||||
displayName: 'Country',
|
||||
name: 'country',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getCountriesCodes',
|
||||
},
|
||||
default: '',
|
||||
description: 'Country',
|
||||
},
|
||||
{
|
||||
displayName: 'Postal Code',
|
||||
name: 'postalCode',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Postal code',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Chat Handles',
|
||||
name: 'chatsUi',
|
||||
placeholder: 'Add Chat Handle',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'customer',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Chat Handle',
|
||||
name: 'chatsValues',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'type',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'aim',
|
||||
value: 'aim',
|
||||
},
|
||||
{
|
||||
name: 'gtalk',
|
||||
value: 'gtalk',
|
||||
},
|
||||
{
|
||||
name: 'icq',
|
||||
value: 'icq',
|
||||
},
|
||||
{
|
||||
name: 'msn',
|
||||
value: 'msn',
|
||||
},
|
||||
{
|
||||
name: 'other',
|
||||
value: 'other',
|
||||
},
|
||||
{
|
||||
name: 'qq',
|
||||
value: 'qq',
|
||||
},
|
||||
{
|
||||
name: 'skype',
|
||||
value: 'skype',
|
||||
},
|
||||
{
|
||||
name: 'xmpp',
|
||||
value: 'xmpp',
|
||||
},
|
||||
{
|
||||
name: 'yahoo',
|
||||
value: 'yahoo',
|
||||
},
|
||||
],
|
||||
description: 'Chat type',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Value',
|
||||
name: 'value',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Chat handle',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Emails',
|
||||
name: 'emailsUi',
|
||||
placeholder: 'Add Email',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'customer',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'emailsValues',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'type',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Home',
|
||||
value: 'home',
|
||||
},
|
||||
{
|
||||
name: 'Other',
|
||||
value: 'other',
|
||||
},
|
||||
{
|
||||
name: 'Work',
|
||||
value: 'work',
|
||||
},
|
||||
],
|
||||
description: 'Location for this email address',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Value',
|
||||
name: 'value',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Email',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Phones',
|
||||
name: 'phonesUi',
|
||||
placeholder: 'Add Phone',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'customer',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'phonesValues',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'type',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Fax',
|
||||
value: 'fax',
|
||||
},
|
||||
{
|
||||
name: 'Home',
|
||||
value: 'home',
|
||||
},
|
||||
{
|
||||
name: 'Other',
|
||||
value: 'other',
|
||||
},
|
||||
{
|
||||
name: 'Pager',
|
||||
value: 'pager',
|
||||
},
|
||||
{
|
||||
name: 'Work',
|
||||
value: 'work',
|
||||
},
|
||||
],
|
||||
description: 'Location for this phone',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Value',
|
||||
name: 'value',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Phone',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Social Profiles',
|
||||
name: 'socialProfilesUi',
|
||||
placeholder: 'Add Social Profile',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'customer',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Social Profile',
|
||||
name: 'socialProfilesValues',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'type',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'About Me',
|
||||
value: 'aboutMe',
|
||||
},
|
||||
{
|
||||
name: 'Facebook',
|
||||
value: 'facebook',
|
||||
},
|
||||
{
|
||||
name: 'Flickr',
|
||||
value: 'flickr',
|
||||
},
|
||||
{
|
||||
name: 'Forsquare',
|
||||
value: 'forsquare',
|
||||
},
|
||||
{
|
||||
name: 'Google',
|
||||
value: 'google',
|
||||
},
|
||||
{
|
||||
name: 'Google Plus',
|
||||
value: 'googleplus',
|
||||
},
|
||||
{
|
||||
name: 'Linkedin',
|
||||
value: 'linkedin',
|
||||
},
|
||||
{
|
||||
name: 'Other',
|
||||
value: 'other',
|
||||
},
|
||||
{
|
||||
name: 'Quora',
|
||||
value: 'quora',
|
||||
},
|
||||
{
|
||||
name: 'Tungleme',
|
||||
value: 'tungleme',
|
||||
},
|
||||
{
|
||||
name: 'Twitter',
|
||||
value: 'twitter',
|
||||
},
|
||||
{
|
||||
name: 'Youtube',
|
||||
value: 'youtube',
|
||||
},
|
||||
],
|
||||
description: 'Type of social profile',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Value',
|
||||
name: 'value',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Social Profile handle (url for example)',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Websites',
|
||||
name: 'websitesUi',
|
||||
placeholder: 'Add Website',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'customer',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Website',
|
||||
name: 'websitesValues',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Value',
|
||||
name: 'value',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Website URL',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* customer:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Option',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'customer',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Mailbox ID',
|
||||
name: 'mailbox',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Filters customers from a specific mailbox',
|
||||
},
|
||||
{
|
||||
displayName: 'First Name',
|
||||
name: 'firstName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Filters customers by first name',
|
||||
},
|
||||
{
|
||||
displayName: 'Last Name',
|
||||
name: 'lastName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Filters customers by last name',
|
||||
},
|
||||
{
|
||||
displayName: 'Modified Since',
|
||||
name: 'modifiedSince',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Returns only customers that were modified after this date',
|
||||
},
|
||||
{
|
||||
displayName: 'Sort Field',
|
||||
name: 'sortField',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Score',
|
||||
value: 'score',
|
||||
},
|
||||
{
|
||||
name: 'First Name',
|
||||
value: 'firstName',
|
||||
},
|
||||
{
|
||||
name: 'Last Name',
|
||||
value: 'lastName',
|
||||
},
|
||||
{
|
||||
name: 'Modified At',
|
||||
value: 'modifiedAt',
|
||||
},
|
||||
],
|
||||
default: 'score',
|
||||
description: 'Sorts the result by specified field',
|
||||
},
|
||||
{
|
||||
displayName: 'Sort Order',
|
||||
name: 'sortOrder',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'ASC',
|
||||
value: 'asc',
|
||||
},
|
||||
{
|
||||
name: 'Desc',
|
||||
value: 'desc',
|
||||
},
|
||||
],
|
||||
default: 'desc',
|
||||
},
|
||||
{
|
||||
displayName: 'Query',
|
||||
name: 'query',
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true,
|
||||
},
|
||||
default: '',
|
||||
description: 'Advanced search <a href="https://developer.helpscout.com/mailbox-api/endpoints/customers/list/#query">Examples</a>'
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* customer:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Customer ID',
|
||||
name: 'customerId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'customer',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'Customer ID',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* customer:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Customer ID',
|
||||
name: 'customerId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: [
|
||||
'customer',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'Customer ID',
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: [
|
||||
'customer',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Age',
|
||||
name: 'age',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
},
|
||||
default: 1,
|
||||
description: `Customer’s age`,
|
||||
},
|
||||
{
|
||||
displayName: 'Notes',
|
||||
name: 'background',
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true,
|
||||
},
|
||||
default: '',
|
||||
description: `Notes`,
|
||||
},
|
||||
{
|
||||
displayName: 'First Name',
|
||||
name: 'firstName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: `First name of the customer. When defined it must be between 1 and 40 characters.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Gender',
|
||||
name: 'gender',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Female',
|
||||
value: 'female',
|
||||
},
|
||||
{
|
||||
name: 'Male',
|
||||
value: 'male',
|
||||
},
|
||||
{
|
||||
name: 'Unknown',
|
||||
value: 'unknown',
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
description: 'Gender of this customer.',
|
||||
},
|
||||
{
|
||||
displayName: 'Job Title',
|
||||
name: 'jobTitle',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Job title. Max length 60 characters.',
|
||||
},
|
||||
{
|
||||
displayName: 'Last Name',
|
||||
name: 'lastName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Last name of the customer',
|
||||
},
|
||||
{
|
||||
displayName: 'Location',
|
||||
name: 'location',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Location of the customer.',
|
||||
},
|
||||
{
|
||||
displayName: 'Organization',
|
||||
name: 'organization',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Organization',
|
||||
},
|
||||
{
|
||||
displayName: 'Photo Url',
|
||||
name: 'photoUrl',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'URL of the customer’s photo',
|
||||
},
|
||||
]
|
||||
},
|
||||
] as INodeProperties[];
|
20
packages/nodes-base/nodes/HelpScout/CustomerInterface.ts
Normal file
20
packages/nodes-base/nodes/HelpScout/CustomerInterface.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { IDataObject } from "n8n-workflow";
|
||||
|
||||
export interface ICustomer {
|
||||
address?: IDataObject;
|
||||
age?: string;
|
||||
background?: string;
|
||||
chats?: IDataObject[];
|
||||
emails?: IDataObject[];
|
||||
firstName?: string;
|
||||
gender?: string;
|
||||
jobTitle?: string;
|
||||
lastName?: string;
|
||||
location?: string;
|
||||
organization?: string;
|
||||
phones?: IDataObject[];
|
||||
photoUrl?: string;
|
||||
properties?: IDataObject;
|
||||
socialProfiles?: IDataObject[];
|
||||
websites?: IDataObject[];
|
||||
}
|
69
packages/nodes-base/nodes/HelpScout/GenericFunctions.ts
Normal file
69
packages/nodes-base/nodes/HelpScout/GenericFunctions.ts
Normal file
|
@ -0,0 +1,69 @@
|
|||
import { OptionsWithUri } from 'request';
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IExecuteSingleFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
IHookFunctions,
|
||||
} from 'n8n-core';
|
||||
import {
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
get,
|
||||
} from 'lodash';
|
||||
|
||||
export async function helpscoutApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
let options: OptionsWithUri = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
method,
|
||||
body,
|
||||
qs,
|
||||
uri: uri || `https://api.helpscout.net${resource}`,
|
||||
json: true
|
||||
};
|
||||
try {
|
||||
if (Object.keys(option).length !== 0) {
|
||||
options = Object.assign({}, options, option);
|
||||
}
|
||||
if (Object.keys(body).length === 0) {
|
||||
delete options.body;
|
||||
}
|
||||
//@ts-ignore
|
||||
return await this.helpers.requestOAuth.call(this, 'helpScoutOAuth2Api', options);
|
||||
} catch (error) {
|
||||
if (error.response && error.response.body
|
||||
&& error.response.body._embedded
|
||||
&& error.response.body._embedded.errors) {
|
||||
// Try to return the error prettier
|
||||
//@ts-ignore
|
||||
throw new Error(`HelpScout error response [${error.statusCode}]: ${error.response.body.message} - ${error.response.body._embedded.errors.map(error => {
|
||||
return `${error.path} ${error.message}`;
|
||||
}).join('-')}`);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function helpscoutApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
query.size = 50;
|
||||
let uri;
|
||||
|
||||
do {
|
||||
responseData = await helpscoutApiRequest.call(this, method, endpoint, body, query, uri);
|
||||
uri = get(responseData, '_links.next.href');
|
||||
returnData.push.apply(returnData, get(responseData, propertyName));
|
||||
} while (
|
||||
responseData['_links'] !== undefined &&
|
||||
responseData['_links'].next !== undefined &&
|
||||
responseData['_links'].next.href !== undefined
|
||||
);
|
||||
|
||||
return returnData;
|
||||
}
|
410
packages/nodes-base/nodes/HelpScout/HelpScout.node.ts
Normal file
410
packages/nodes-base/nodes/HelpScout/HelpScout.node.ts
Normal file
|
@ -0,0 +1,410 @@
|
|||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
INodeTypeDescription,
|
||||
INodeType,
|
||||
ILoadOptionsFunctions,
|
||||
INodePropertyOptions,
|
||||
IBinaryKeyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
helpscoutApiRequest,
|
||||
helpscoutApiRequestAllItems,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import {
|
||||
conversationOperations,
|
||||
conversationFields,
|
||||
} from './ConversationDescription';
|
||||
|
||||
import {
|
||||
customerOperations,
|
||||
customerFields,
|
||||
} from './CustomerDescription';
|
||||
|
||||
import {
|
||||
mailboxOperations,
|
||||
mailboxFields,
|
||||
} from './MailboxDescription';
|
||||
|
||||
import {
|
||||
threadOperations,
|
||||
threadFields,
|
||||
} from './ThreadDescription';
|
||||
|
||||
import {
|
||||
ICustomer,
|
||||
} from './CustomerInterface';
|
||||
|
||||
import {
|
||||
IConversation,
|
||||
} from './ConversationInterface';
|
||||
|
||||
import {
|
||||
IThread,
|
||||
IAttachment,
|
||||
} from './ThreadInterface';
|
||||
|
||||
import {
|
||||
countriesCodes
|
||||
} from './CountriesCodes';
|
||||
|
||||
export class HelpScout implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'HelpScout',
|
||||
name: 'helpScout',
|
||||
icon: 'file:helpScout.png',
|
||||
group: ['input'],
|
||||
version: 1,
|
||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||
description: 'Consume Help Scout API.',
|
||||
defaults: {
|
||||
name: 'HelpScout',
|
||||
color: '#1392ee',
|
||||
},
|
||||
inputs: ['main'],
|
||||
outputs: ['main'],
|
||||
credentials: [
|
||||
{
|
||||
name: 'helpScoutOAuth2Api',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Conversation',
|
||||
value: 'conversation',
|
||||
},
|
||||
{
|
||||
name: 'Customer',
|
||||
value: 'customer',
|
||||
},
|
||||
{
|
||||
name: 'Mailbox',
|
||||
value: 'mailbox',
|
||||
},
|
||||
{
|
||||
name: 'Thread',
|
||||
value: 'thread',
|
||||
},
|
||||
],
|
||||
default: 'conversation',
|
||||
description: 'The resource to operate on.',
|
||||
},
|
||||
...conversationOperations,
|
||||
...conversationFields,
|
||||
...customerOperations,
|
||||
...customerFields,
|
||||
...mailboxOperations,
|
||||
...mailboxFields,
|
||||
...threadOperations,
|
||||
...threadFields,
|
||||
],
|
||||
};
|
||||
|
||||
methods = {
|
||||
loadOptions: {
|
||||
// Get all the countries codes to display them to user so that he can
|
||||
// select them easily
|
||||
async getCountriesCodes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
for (const countryCode of countriesCodes) {
|
||||
const countryCodeName = `${countryCode.name} - ${countryCode.alpha2}`;
|
||||
const countryCodeId = countryCode.alpha2;
|
||||
returnData.push({
|
||||
name: countryCodeName,
|
||||
value: countryCodeId,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
// Get all the tags to display them to user so that he can
|
||||
// select them easily
|
||||
async getTags(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const tags = await helpscoutApiRequestAllItems.call(this, '_embedded.tags', 'GET', '/v2/tags');
|
||||
for (const tag of tags) {
|
||||
const tagName = tag.name;
|
||||
const tagId = tag.id;
|
||||
returnData.push({
|
||||
name: tagName,
|
||||
value: tagId,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
// Get all the mailboxes to display them to user so that he can
|
||||
// select them easily
|
||||
async getMailboxes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const mailboxes = await helpscoutApiRequestAllItems.call(this, '_embedded.mailboxes', 'GET', '/v2/mailboxes');
|
||||
for (const mailbox of mailboxes) {
|
||||
const mailboxName = mailbox.name;
|
||||
const mailboxId = mailbox.id;
|
||||
returnData.push({
|
||||
name: mailboxName,
|
||||
value: mailboxId,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: IDataObject[] = [];
|
||||
const length = items.length as unknown as number;
|
||||
const qs: IDataObject = {};
|
||||
let responseData;
|
||||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
for (let i = 0; i < length; i++) {
|
||||
if (resource === 'conversation') {
|
||||
//https://developer.helpscout.com/mailbox-api/endpoints/conversations/create
|
||||
if (operation === 'create') {
|
||||
const mailboxId = this.getNodeParameter('mailboxId', i) as number;
|
||||
const status = this.getNodeParameter('status', i) as string;
|
||||
const subject = this.getNodeParameter('subject', i) as string;
|
||||
const type = this.getNodeParameter('type', i) as string;
|
||||
const resolveData = this.getNodeParameter('resolveData', i) as boolean;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const threads = (this.getNodeParameter('threadsUi', i) as IDataObject).threadsValues as IDataObject[];
|
||||
const body: IConversation = {
|
||||
mailboxId,
|
||||
status,
|
||||
subject,
|
||||
type,
|
||||
};
|
||||
Object.assign(body, additionalFields);
|
||||
if (additionalFields.customerId) {
|
||||
body.customer = {
|
||||
id: additionalFields.customerId,
|
||||
};
|
||||
//@ts-ignore
|
||||
delete body.customerId;
|
||||
}
|
||||
if (additionalFields.customerEmail) {
|
||||
body.customer = {
|
||||
email: additionalFields.customerEmail,
|
||||
};
|
||||
//@ts-ignore
|
||||
delete body.customerEmail;
|
||||
}
|
||||
if (body.customer === undefined) {
|
||||
throw new Error('Either customer email or customer ID must be set');
|
||||
}
|
||||
if (threads) {
|
||||
for (let i = 0; i < threads.length; i++) {
|
||||
if (threads[i].type === '' || threads[i].text === '') {
|
||||
throw new Error('Chat Threads cannot be empty');
|
||||
}
|
||||
if (threads[i].type !== 'note') {
|
||||
threads[i].customer = body.customer;
|
||||
}
|
||||
}
|
||||
body.threads = threads;
|
||||
}
|
||||
responseData = await helpscoutApiRequest.call(this, 'POST', '/v2/conversations', body, qs, undefined, { resolveWithFullResponse: true });
|
||||
const id = responseData.headers['resource-id'];
|
||||
const uri = responseData.headers.location;
|
||||
if (resolveData) {
|
||||
responseData = await helpscoutApiRequest.call(this, 'GET', '', {}, {}, uri);
|
||||
} else {
|
||||
responseData = {
|
||||
id,
|
||||
uri,
|
||||
};
|
||||
}
|
||||
}
|
||||
//https://developer.helpscout.com/mailbox-api/endpoints/conversations/delete
|
||||
if (operation === 'delete') {
|
||||
const conversationId = this.getNodeParameter('conversationId', i) as string;
|
||||
responseData = await helpscoutApiRequest.call(this, 'DELETE', `/v2/conversations/${conversationId}`);
|
||||
responseData = { success: true };
|
||||
}
|
||||
//https://developer.helpscout.com/mailbox-api/endpoints/conversations/get
|
||||
if (operation === 'get') {
|
||||
const conversationId = this.getNodeParameter('conversationId', i) as string;
|
||||
responseData = await helpscoutApiRequest.call(this, 'GET', `/v2/conversations/${conversationId}`);
|
||||
}
|
||||
//https://developer.helpscout.com/mailbox-api/endpoints/conversations/list
|
||||
if (operation === 'getAll') {
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
Object.assign(qs, options);
|
||||
responseData = await helpscoutApiRequestAllItems.call(this, '_embedded.conversations', 'GET', '/v2/conversations', {}, qs);
|
||||
}
|
||||
}
|
||||
if (resource === 'customer') {
|
||||
//https://developer.helpscout.com/mailbox-api/endpoints/customers/create
|
||||
if (operation === 'create') {
|
||||
const resolveData = this.getNodeParameter('resolveData', i) as boolean;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const chats = (this.getNodeParameter('chatsUi', i) as IDataObject).chatsValues as IDataObject[];
|
||||
const address = (this.getNodeParameter('addressUi', i) as IDataObject).addressValue as IDataObject;
|
||||
const emails = (this.getNodeParameter('emailsUi', i) as IDataObject).emailsValues as IDataObject[];
|
||||
const phones = (this.getNodeParameter('phonesUi', i) as IDataObject).phonesValues as IDataObject[];
|
||||
const socialProfiles = (this.getNodeParameter('socialProfilesUi', i) as IDataObject).socialProfilesValues as IDataObject[];
|
||||
const websites = (this.getNodeParameter('websitesUi', i) as IDataObject).websitesValues as IDataObject[];
|
||||
let body: ICustomer = {};
|
||||
body = Object.assign({}, additionalFields);
|
||||
if (body.age) {
|
||||
body.age = body.age.toString();
|
||||
}
|
||||
if (chats) {
|
||||
body.chats = chats;
|
||||
}
|
||||
if (address) {
|
||||
body.address = address;
|
||||
body.address.lines = [address.line1, address.line2];
|
||||
}
|
||||
if (emails) {
|
||||
body.emails = emails;
|
||||
}
|
||||
if (phones) {
|
||||
body.phones = phones;
|
||||
}
|
||||
if (socialProfiles) {
|
||||
body.socialProfiles = socialProfiles;
|
||||
}
|
||||
if (websites) {
|
||||
body.websites = websites;
|
||||
}
|
||||
if (Object.keys(body).length === 0) {
|
||||
throw new Error('You have to set at least one field');
|
||||
}
|
||||
responseData = await helpscoutApiRequest.call(this, 'POST', '/v2/customers', body, qs, undefined, { resolveWithFullResponse: true });
|
||||
const id = responseData.headers['resource-id'];
|
||||
const uri = responseData.headers.location;
|
||||
if (resolveData) {
|
||||
responseData = await helpscoutApiRequest.call(this, 'GET', '', {}, {}, uri);
|
||||
} else {
|
||||
responseData = {
|
||||
id,
|
||||
uri,
|
||||
};
|
||||
}
|
||||
}
|
||||
//https://developer.helpscout.com/mailbox-api/endpoints/customer_properties/list
|
||||
if (operation === 'properties') {
|
||||
responseData = await helpscoutApiRequestAllItems.call(this, '_embedded.customer-properties', 'GET', '/v2/customer-properties', {}, qs);
|
||||
}
|
||||
//https://developer.helpscout.com/mailbox-api/endpoints/customers/get
|
||||
if (operation === 'get') {
|
||||
const customerId = this.getNodeParameter('customerId', i) as string;
|
||||
responseData = await helpscoutApiRequest.call(this, 'GET', `/v2/customers/${customerId}`);
|
||||
}
|
||||
//https://developer.helpscout.com/mailbox-api/endpoints/customers/list
|
||||
if (operation === 'getAll') {
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
Object.assign(qs, options);
|
||||
responseData = await helpscoutApiRequestAllItems.call(this, '_embedded.customers', 'GET', '/v2/customers', {}, qs);
|
||||
}
|
||||
//https://developer.helpscout.com/mailbox-api/endpoints/customers/overwrite/
|
||||
if (operation === 'update') {
|
||||
const customerId = this.getNodeParameter('customerId', i) as string;
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
let body: ICustomer = {};
|
||||
body = Object.assign({}, updateFields);
|
||||
if (body.age) {
|
||||
body.age = body.age.toString();
|
||||
}
|
||||
if (Object.keys(body).length === 0) {
|
||||
throw new Error('You have to set at least one field');
|
||||
}
|
||||
responseData = await helpscoutApiRequest.call(this, 'PUT', `/v2/customers/${customerId}`, body, qs, undefined, { resolveWithFullResponse: true });
|
||||
responseData = { success: true };
|
||||
}
|
||||
}
|
||||
if (resource === 'mailbox') {
|
||||
//https://developer.helpscout.com/mailbox-api/endpoints/mailboxes/get
|
||||
if (operation === 'get') {
|
||||
const mailboxId = this.getNodeParameter('mailboxId', i) as string;
|
||||
responseData = await helpscoutApiRequest.call(this, 'GET', `/v2/mailboxes/${mailboxId}`, {}, qs);
|
||||
}
|
||||
//https://developer.helpscout.com/mailbox-api/endpoints/mailboxes/list
|
||||
if (operation === 'getAll') {
|
||||
responseData = await helpscoutApiRequestAllItems.call(this, '_embedded.mailboxes', 'GET', '/v2/mailboxes', {}, qs);
|
||||
}
|
||||
}
|
||||
if (resource === 'thread') {
|
||||
//https://developer.helpscout.com/mailbox-api/endpoints/conversations/threads/chat
|
||||
if (operation === 'create') {
|
||||
const conversationId = this.getNodeParameter('conversationId', i) as string;
|
||||
const type = this.getNodeParameter('type', i) as string;
|
||||
const text = this.getNodeParameter('text', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const attachments = this.getNodeParameter('attachmentsUi', i) as IDataObject;
|
||||
const body: IThread = {
|
||||
text,
|
||||
attachments: [],
|
||||
};
|
||||
Object.assign(body, additionalFields);
|
||||
if (additionalFields.customerId) {
|
||||
body.customer = {
|
||||
id: additionalFields.customerId,
|
||||
};
|
||||
//@ts-ignore
|
||||
delete body.customerId;
|
||||
}
|
||||
if (additionalFields.customerEmail) {
|
||||
body.customer = {
|
||||
email: additionalFields.customerEmail,
|
||||
};
|
||||
//@ts-ignore
|
||||
delete body.customerEmail;
|
||||
}
|
||||
if (body.customer === undefined) {
|
||||
throw new Error('Either customer email or customer ID must be set');
|
||||
}
|
||||
if (attachments) {
|
||||
if (attachments.attachmentsValues
|
||||
&& (attachments.attachmentsValues as IDataObject[]).length !== 0) {
|
||||
body.attachments?.push.apply(body.attachments, attachments.attachmentsValues as IAttachment[]);
|
||||
}
|
||||
if (attachments.attachmentsBinary
|
||||
&& (attachments.attachmentsBinary as IDataObject[]).length !== 0
|
||||
&& items[i].binary) {
|
||||
const mapFunction = (value: IDataObject): IAttachment => {
|
||||
const binaryProperty = (items[i].binary as IBinaryKeyData)[value.property as string];
|
||||
if (binaryProperty) {
|
||||
return {
|
||||
fileName: binaryProperty.fileName || 'unknown',
|
||||
data: binaryProperty.data,
|
||||
mimeType: binaryProperty.mimeType,
|
||||
};
|
||||
} else {
|
||||
throw new Error(`Binary property ${value.property} does not exist on input`);
|
||||
}
|
||||
};
|
||||
body.attachments?.push.apply(body.attachments, (attachments.attachmentsBinary as IDataObject[]).map(mapFunction) as IAttachment[]);
|
||||
}
|
||||
}
|
||||
responseData = await helpscoutApiRequest.call(this, 'POST', `/v2/conversations/${conversationId}/chats`, body);
|
||||
responseData = { success: true };
|
||||
}
|
||||
//https://developer.helpscout.com/mailbox-api/endpoints/conversations/threads/list
|
||||
if (operation === 'getAll') {
|
||||
const conversationId = this.getNodeParameter('conversationId', i) as string;
|
||||
responseData = await helpscoutApiRequestAllItems.call(this, '_embedded.threads', 'GET', `/v2/conversations/${conversationId}/threads`);
|
||||
}
|
||||
}
|
||||
if (Array.isArray(responseData)) {
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
} else if (responseData !== undefined) {
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
}
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
}
|
||||
}
|
202
packages/nodes-base/nodes/HelpScout/HelpScoutTrigger.node.ts
Normal file
202
packages/nodes-base/nodes/HelpScout/HelpScoutTrigger.node.ts
Normal file
|
@ -0,0 +1,202 @@
|
|||
import {
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
INodeTypeDescription,
|
||||
INodeType,
|
||||
IWebhookResponseData,
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
helpscoutApiRequest,
|
||||
helpscoutApiRequestAllItems,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import { createHmac } from 'crypto';
|
||||
|
||||
export class HelpScoutTrigger implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'HelpScout Trigger',
|
||||
name: 'helpScoutTrigger',
|
||||
icon: 'file:helpScout.png',
|
||||
group: ['trigger'],
|
||||
version: 1,
|
||||
description: 'Starts the workflow when HelpScout events occure.',
|
||||
defaults: {
|
||||
name: 'HelpScout Trigger',
|
||||
color: '#1392ee',
|
||||
},
|
||||
inputs: [],
|
||||
outputs: ['main'],
|
||||
credentials: [
|
||||
{
|
||||
name: 'helpScoutOAuth2Api',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
webhooks: [
|
||||
{
|
||||
name: 'default',
|
||||
httpMethod: 'POST',
|
||||
responseMode: 'onReceived',
|
||||
path: 'webhook',
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Events',
|
||||
name: 'events',
|
||||
type: 'multiOptions',
|
||||
options: [
|
||||
{
|
||||
name: 'convo.agent.reply.created',
|
||||
value: 'convo.agent.reply.created',
|
||||
},
|
||||
{
|
||||
name: 'convo.assigned',
|
||||
value: 'convo.assigned',
|
||||
},
|
||||
{
|
||||
name: 'convo.created',
|
||||
value: 'convo.created',
|
||||
},
|
||||
{
|
||||
name: 'convo.customer.reply.created',
|
||||
value: 'convo.customer.reply.created',
|
||||
},
|
||||
{
|
||||
name: 'convo.deleted',
|
||||
value: 'convo.deleted',
|
||||
},
|
||||
{
|
||||
name: 'convo.merged',
|
||||
value: 'convo.merged',
|
||||
},
|
||||
{
|
||||
name: 'convo.moved',
|
||||
value: 'convo.moved',
|
||||
},
|
||||
{
|
||||
name: 'convo.note.created',
|
||||
value: 'convo.note.created',
|
||||
},
|
||||
{
|
||||
name: 'convo.status',
|
||||
value: 'convo.status',
|
||||
},
|
||||
{
|
||||
name: 'convo.tags',
|
||||
value: 'convo.tags',
|
||||
},
|
||||
{
|
||||
name: 'customer.created',
|
||||
value: 'customer.created',
|
||||
},
|
||||
{
|
||||
name: 'satisfaction.ratings',
|
||||
value: 'satisfaction.ratings',
|
||||
},
|
||||
],
|
||||
default: [],
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const events = this.getNodeParameter('events') as string;
|
||||
|
||||
// Check all the webhooks which exist already if it is identical to the
|
||||
// one that is supposed to get created.
|
||||
const endpoint = '/v2/webhooks';
|
||||
const data = await helpscoutApiRequestAllItems.call(this, '_embedded.webhooks', 'GET', endpoint, {});
|
||||
|
||||
for (const webhook of data) {
|
||||
if (webhook.url === webhookUrl) {
|
||||
for (const event of events) {
|
||||
if (!webhook.events.includes(event)
|
||||
&& webhook.state === 'enabled') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Set webhook-id to be sure that it can be deleted
|
||||
webhookData.webhookId = webhook.id as string;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
async create(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const events = this.getNodeParameter('events') as string;
|
||||
|
||||
const endpoint = '/v2/webhooks';
|
||||
|
||||
const body = {
|
||||
url: webhookUrl,
|
||||
events,
|
||||
secret: Math.random().toString(36).substring(2, 15),
|
||||
};
|
||||
|
||||
const responseData = await helpscoutApiRequest.call(this, 'POST', endpoint, body, {}, undefined, { resolveWithFullResponse: true });
|
||||
|
||||
if (responseData.headers['resource-id'] === undefined) {
|
||||
// Required data is missing so was not successful
|
||||
return false;
|
||||
}
|
||||
|
||||
webhookData.webhookId = responseData.headers['resource-id'] as string;
|
||||
webhookData.secret = body.secret;
|
||||
return true;
|
||||
},
|
||||
async delete(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
if (webhookData.webhookId !== undefined) {
|
||||
|
||||
const endpoint = `/v2/webhooks/${webhookData.webhookId}`;
|
||||
try {
|
||||
await helpscoutApiRequest.call(this, 'DELETE', endpoint);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove from the static workflow data so that it is clear
|
||||
// that no webhooks are registred anymore
|
||||
delete webhookData.webhookId;
|
||||
delete webhookData.secret;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
|
||||
const req = this.getRequestObject();
|
||||
const bodyData = this.getBodyData();
|
||||
const headerData = this.getHeaderData() as IDataObject;
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
if (headerData['x-helpscout-signature'] === undefined) {
|
||||
return {};
|
||||
}
|
||||
//@ts-ignore
|
||||
const computedSignature = createHmac('sha1', webhookData.secret as string).update(req.rawBody).digest('base64');
|
||||
if (headerData['x-helpscout-signature'] !== computedSignature) {
|
||||
return {};
|
||||
}
|
||||
return {
|
||||
workflowData: [
|
||||
this.helpers.returnJsonArray(bodyData),
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
54
packages/nodes-base/nodes/HelpScout/MailboxDescription.ts
Normal file
54
packages/nodes-base/nodes/HelpScout/MailboxDescription.ts
Normal file
|
@ -0,0 +1,54 @@
|
|||
import { INodeProperties } from "n8n-workflow";
|
||||
|
||||
export const mailboxOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'mailbox',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get data of a mailbox',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get all mailboxes',
|
||||
},
|
||||
],
|
||||
default: 'get',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const mailboxFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* mailbox:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Mailbox ID',
|
||||
name: 'mailboxId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'mailbox',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
] as INodeProperties[];
|
257
packages/nodes-base/nodes/HelpScout/ThreadDescription.ts
Normal file
257
packages/nodes-base/nodes/HelpScout/ThreadDescription.ts
Normal file
|
@ -0,0 +1,257 @@
|
|||
import { INodeProperties } from "n8n-workflow";
|
||||
|
||||
export const threadOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'thread',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a new chat thread',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get all chat threads',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const threadFields = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* thread:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Conversation ID',
|
||||
name: 'conversationId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'thread',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'conversation ID',
|
||||
},
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'type',
|
||||
type: 'options',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'thread',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Chat',
|
||||
value: 'chat'
|
||||
},
|
||||
{
|
||||
name: 'Customer',
|
||||
value: 'customer'
|
||||
},
|
||||
{
|
||||
name: 'Note',
|
||||
value: 'note'
|
||||
},
|
||||
{
|
||||
name: 'Phone',
|
||||
value: 'phone'
|
||||
},
|
||||
{
|
||||
name: 'Reply',
|
||||
value: 'reply'
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Text',
|
||||
name: 'text',
|
||||
type: 'string',
|
||||
default: '',
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true,
|
||||
},
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'thread',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'The chat text',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'thread',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Customer Email',
|
||||
name: 'customerEmail',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Customer ID',
|
||||
name: 'customerId',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
},
|
||||
{
|
||||
displayName: 'Draft',
|
||||
name: 'draft',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/type': [
|
||||
'note',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'If set to true, a draft reply is created',
|
||||
},
|
||||
{
|
||||
displayName: 'Imported',
|
||||
name: 'imported',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'When imported is set to true, no outgoing emails or notifications will be generated.',
|
||||
},
|
||||
{
|
||||
displayName: 'Created At',
|
||||
name: 'createdAt',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Attachments',
|
||||
name: 'attachmentsUi',
|
||||
placeholder: 'Add Attachments',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'thread',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'attachmentsValues',
|
||||
displayName: 'Attachments Values',
|
||||
values: [
|
||||
{
|
||||
displayName: 'FileName',
|
||||
name: 'fileName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Attachment’s file name',
|
||||
},
|
||||
{
|
||||
displayName: 'Mime Type',
|
||||
name: 'mimeType',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Attachment’s mime type',
|
||||
},
|
||||
{
|
||||
displayName: 'Data',
|
||||
name: 'data',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'ZXhhbXBsZSBmaWxl',
|
||||
description: 'Base64-encoded stream of data.',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'attachmentsBinary',
|
||||
displayName: 'Attachments Binary',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Property',
|
||||
name: 'property',
|
||||
type: 'string',
|
||||
default: 'data',
|
||||
description: 'Name of the binary properties which contain data which should be added to email as attachment',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
description: 'Array of supported attachments to add to the message.',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* thread:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Conversation ID',
|
||||
name: 'conversationId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'thread',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'conversation ID',
|
||||
},
|
||||
] as INodeProperties[];
|
15
packages/nodes-base/nodes/HelpScout/ThreadInterface.ts
Normal file
15
packages/nodes-base/nodes/HelpScout/ThreadInterface.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { IDataObject } from "n8n-workflow";
|
||||
|
||||
export interface IAttachment {
|
||||
fileName?: string;
|
||||
mimeType?: string;
|
||||
data?: string;
|
||||
}
|
||||
|
||||
export interface IThread {
|
||||
createdAt?: string;
|
||||
customer?: IDataObject;
|
||||
imported?: boolean;
|
||||
text?: string;
|
||||
attachments?: IAttachment[];
|
||||
}
|
BIN
packages/nodes-base/nodes/HelpScout/helpScout.png
Normal file
BIN
packages/nodes-base/nodes/HelpScout/helpScout.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
|
@ -44,6 +44,7 @@
|
|||
"dist/credentials/GitlabApi.credentials.js",
|
||||
"dist/credentials/GoogleApi.credentials.js",
|
||||
"dist/credentials/GoogleOAuth2Api.credentials.js",
|
||||
"dist/credentials/HelpScoutOAuth2Api.credentials.js",
|
||||
"dist/credentials/HttpBasicAuth.credentials.js",
|
||||
"dist/credentials/HttpDigestAuth.credentials.js",
|
||||
"dist/credentials/HttpHeaderAuth.credentials.js",
|
||||
|
@ -124,6 +125,8 @@
|
|||
"dist/nodes/Google/GoogleDrive.node.js",
|
||||
"dist/nodes/Google/GoogleSheets.node.js",
|
||||
"dist/nodes/GraphQL/GraphQL.node.js",
|
||||
"dist/nodes/HelpScout/HelpScout.node.js",
|
||||
"dist/nodes/HelpScout/HelpScoutTrigger.node.js",
|
||||
"dist/nodes/HtmlExtract/HtmlExtract.node.js",
|
||||
"dist/nodes/HttpRequest.node.js",
|
||||
"dist/nodes/Hubspot/Hubspot.node.js",
|
||||
|
|
Loading…
Reference in a new issue