pull:初次提交

This commit is contained in:
Yep_Q
2025-09-08 04:48:28 +08:00
parent 5c0619656d
commit f64f498365
11751 changed files with 1953723 additions and 0 deletions

View File

@@ -0,0 +1,579 @@
import type { INodeProperties } from 'n8n-workflow';
export const conversationOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['conversation'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new conversation',
action: 'Create a conversation',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a conversation',
action: 'Delete a conversation',
},
{
name: 'Get',
value: 'get',
description: 'Get a conversation',
action: 'Get a conversation',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get many conversations',
action: 'Get many conversations',
},
],
default: 'create',
},
];
export const conversationFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* conversation:create */
/* -------------------------------------------------------------------------- */
{
displayName: 'Mailbox Name or ID',
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. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
},
{
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,
displayOptions: {
show: {
operation: ['create'],
resource: ['conversation'],
},
},
default: '',
description: 'Conversations 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'],
},
},
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
description:
'By default the response only contain the ID to resource. If this option gets activated, it 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:
'Whether set to true, an auto reply will be sent 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: 'Whether set to true, no outgoing emails or notifications will be generated',
},
{
displayName: 'Tag Names or IDs',
name: 'tags',
type: 'multiOptions',
typeOptions: {
loadOptionsMethod: 'getTags',
},
default: [],
description:
'List of tags to be added to the conversation. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
},
{
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',
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: 'Whether true, a draft reply is created',
},
],
},
],
},
/* -------------------------------------------------------------------------- */
/* conversation:get */
/* -------------------------------------------------------------------------- */
{
displayName: 'Conversation ID',
name: 'conversationId',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
resource: ['conversation'],
operation: ['get'],
},
},
},
/* -------------------------------------------------------------------------- */
/* conversation:delete */
/* -------------------------------------------------------------------------- */
{
displayName: 'Conversation ID',
name: 'conversationId',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
resource: ['conversation'],
operation: ['delete'],
},
},
},
/* -------------------------------------------------------------------------- */
/* conversation:getAll */
/* -------------------------------------------------------------------------- */
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
operation: ['getAll'],
resource: ['conversation'],
},
},
default: false,
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
operation: ['getAll'],
resource: ['conversation'],
returnAll: [false],
},
},
typeOptions: {
minValue: 1,
},
default: 50,
description: 'Max number of results to return',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add option',
default: {},
displayOptions: {
show: {
resource: ['conversation'],
operation: ['getAll'],
},
},
options: [
{
displayName: 'Assign To',
name: 'assignTo',
type: 'number',
default: 0,
description: 'Filters conversations by assignee ID',
},
{
displayName: 'Embed',
name: 'embed',
type: 'options',
options: [
{
name: 'Threads',
value: 'threads',
},
],
default: '',
description: 'Allows embedding/loading of sub-entities',
},
{
displayName: 'Folder ID',
name: 'folder',
type: 'string',
default: '',
description: 'Filters conversations from a specific folder ID',
},
{
displayName: 'Mailbox ID',
name: 'mailbox',
type: 'string',
default: '',
description: 'Filters conversations from a specific mailbox',
},
{
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: 'Query',
name: 'query',
type: 'string',
default: '',
description:
'Advanced search <a href="https://developer.helpscout.com/mailbox-api/endpoints/conversations/list/#query">Examples</a>',
},
{
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: '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: 'Tag Names or IDs',
name: 'tags',
type: 'multiOptions',
typeOptions: {
loadOptionsMethod: 'getTags',
},
default: [],
description:
'Filter conversation by tags. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
},
],
},
];

View File

@@ -0,0 +1,19 @@
import type { 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;
tag?: IDataObject[];
tags?: IDataObject[];
threads?: IDataObject[];
type?: string;
user?: number;
}

View File

@@ -0,0 +1,782 @@
import type { INodeProperties } from 'n8n-workflow';
export const customerOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['customer'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new customer',
action: 'Create a customer',
},
{
name: 'Get',
value: 'get',
description: 'Get a customer',
action: 'Get a customer',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get many customers',
action: 'Get many customers',
},
{
name: 'Properties',
value: 'properties',
description: 'Get customer property definitions',
action: 'Get customer properties',
},
{
name: 'Update',
value: 'update',
description: 'Update a customer',
action: 'Update a customer',
},
],
default: 'create',
},
];
export const customerFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* customer:create */
/* -------------------------------------------------------------------------- */
{
displayName: 'Resolve Data',
name: 'resolveData',
type: 'boolean',
default: true,
displayOptions: {
show: {
operation: ['create'],
resource: ['customer'],
},
},
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
description:
'By default the response only contain the ID to resource. If this option gets activated, it 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: 'Customers age',
},
{
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: 'Notes',
name: 'background',
type: 'string',
default: '',
},
{
displayName: 'Organization',
name: 'organization',
type: 'string',
default: '',
},
{
displayName: 'Photo Url',
name: 'photoUrl',
type: 'string',
default: '',
description: 'URL of the customers 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: '',
},
{
displayName: 'Line 2',
name: 'line2',
type: 'string',
default: '',
},
{
displayName: 'City',
name: 'city',
type: 'string',
default: '',
},
{
displayName: 'State',
name: 'state',
type: 'string',
default: '',
},
{
displayName: 'Country Name or ID',
name: 'country',
type: 'options',
description:
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
typeOptions: {
loadOptionsMethod: 'getCountriesCodes',
},
default: '',
},
{
displayName: 'Postal Code',
name: 'postalCode',
type: 'string',
default: '',
},
],
},
],
},
{
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: 'Google Talk',
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: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
operation: ['getAll'],
resource: ['customer'],
},
},
default: false,
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
operation: ['getAll'],
resource: ['customer'],
returnAll: [false],
},
},
typeOptions: {
minValue: 1,
},
default: 50,
description: 'Max number of results to return',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add option',
default: {},
displayOptions: {
show: {
resource: ['customer'],
operation: ['getAll'],
},
},
options: [
{
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: 'Mailbox ID',
name: 'mailbox',
type: 'string',
default: '',
description: 'Filters customers from a specific mailbox',
},
{
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',
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'],
},
},
},
/* -------------------------------------------------------------------------- */
/* customer:update */
/* -------------------------------------------------------------------------- */
{
displayName: 'Customer ID',
name: 'customerId',
type: 'string',
default: '',
displayOptions: {
show: {
operation: ['update'],
resource: ['customer'],
},
},
},
{
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: 'Customers age',
},
{
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: 'Notes',
name: 'background',
type: 'string',
default: '',
},
{
displayName: 'Organization',
name: 'organization',
type: 'string',
default: '',
},
{
displayName: 'Photo Url',
name: 'photoUrl',
type: 'string',
default: '',
description: 'URL of the customers photo',
},
],
},
];

View File

@@ -0,0 +1,20 @@
import type { 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[];
}

View File

@@ -0,0 +1,71 @@
import get from 'lodash/get';
import type {
IDataObject,
IExecuteFunctions,
IHookFunctions,
ILoadOptionsFunctions,
JsonObject,
IRequestOptions,
IHttpRequestMethods,
} from 'n8n-workflow';
import { NodeApiError } from 'n8n-workflow';
export async function helpscoutApiRequest(
this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions,
method: IHttpRequestMethods,
resource: string,
body: any = {},
qs: IDataObject = {},
uri?: string,
option: IDataObject = {},
): Promise<any> {
let options: IRequestOptions = {
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 as IDataObject).length === 0) {
delete options.body;
}
return await this.helpers.requestOAuth2.call(this, 'helpScoutOAuth2Api', options);
} catch (error) {
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
export async function helpscoutApiRequestAllItems(
this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions,
propertyName: string,
method: IHttpRequestMethods,
endpoint: string,
body: any = {},
query: IDataObject = {},
): Promise<any> {
const returnData: IDataObject[] = [];
let responseData;
let uri: undefined | string = undefined;
do {
responseData = await helpscoutApiRequest.call(this, method, endpoint, body, query, uri);
uri = get(responseData, '_links.next.href');
returnData.push.apply(returnData, get(responseData, propertyName) as IDataObject[]);
const limit = query.limit as number | undefined;
if (limit && limit <= returnData.length) {
return returnData;
}
} while (responseData._links?.next?.href !== undefined);
return returnData;
}

View File

@@ -0,0 +1,18 @@
{
"node": "n8n-nodes-base.helpScout",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": ["Communication"],
"resources": {
"credentialDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/credentials/helpScout/"
}
],
"primaryDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.helpscout/"
}
]
}
}

View File

@@ -0,0 +1,583 @@
import type {
IExecuteFunctions,
IBinaryKeyData,
IDataObject,
ILoadOptionsFunctions,
INodeExecutionData,
INodePropertyOptions,
INodeType,
INodeTypeDescription,
} from 'n8n-workflow';
import { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
import { isoCountryCodes } from '@utils/ISOCountryCodes';
import { conversationFields, conversationOperations } from './ConversationDescription';
import type { IConversation } from './ConversationInterface';
import { customerFields, customerOperations } from './CustomerDescription';
import type { ICustomer } from './CustomerInterface';
import { helpscoutApiRequest, helpscoutApiRequestAllItems } from './GenericFunctions';
import { mailboxFields, mailboxOperations } from './MailboxDescription';
import { threadFields, threadOperations } from './ThreadDescription';
import type { IAttachment, IThread } from './ThreadInterface';
export class HelpScout implements INodeType {
description: INodeTypeDescription = {
displayName: 'Help Scout',
name: 'helpScout',
icon: 'file:helpScout.svg',
group: ['input'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Consume Help Scout API',
defaults: {
name: 'Help Scout',
},
usableAsTool: true,
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.Main],
credentials: [
{
name: 'helpScoutOAuth2Api',
required: true,
},
],
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Conversation',
value: 'conversation',
},
{
name: 'Customer',
value: 'customer',
},
{
name: 'Mailbox',
value: 'mailbox',
},
{
name: 'Thread',
value: 'thread',
},
],
default: 'conversation',
},
...conversationOperations,
...conversationFields,
...customerOperations,
...customerFields,
...mailboxOperations,
...mailboxFields,
...threadOperations,
...threadFields,
],
};
methods = {
loadOptions: {
// Get all the countries codes to display them to user so that they can
// select them easily
async getCountriesCodes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
for (const countryCode of isoCountryCodes) {
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 they 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;
returnData.push({
name: tagName,
value: tagName,
});
}
return returnData;
},
// Get all the mailboxes to display them to user so that they 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: INodeExecutionData[] = [];
const length = items.length;
const qs: IDataObject = {};
let responseData;
const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0);
for (let i = 0; i < length; i++) {
try {
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);
const additionalFields = this.getNodeParameter('additionalFields', i);
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 NodeOperationError(
this.getNode(),
'Either customer email or customer ID must be set',
{ itemIndex: i },
);
}
if (threads) {
for (let index = 0; index < threads.length; index++) {
if (threads[index].type === '' || threads[index].text === '') {
throw new NodeOperationError(this.getNode(), 'Chat Threads cannot be empty');
}
if (threads[index].type !== 'note') {
threads[index].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 as string);
} 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 returnAll = this.getNodeParameter('returnAll', i);
const options = this.getNodeParameter('options', i);
if (options.tags) {
qs.tag = options.tags.toString();
}
Object.assign(qs, options);
delete qs.tags;
if (returnAll) {
responseData = await helpscoutApiRequestAllItems.call(
this,
'_embedded.conversations',
'GET',
'/v2/conversations',
{},
qs,
);
} else {
qs.limit = this.getNodeParameter('limit', i);
responseData = await helpscoutApiRequestAllItems.call(
this,
'_embedded.conversations',
'GET',
'/v2/conversations',
{},
qs,
);
responseData = responseData.splice(0, qs.limit);
}
}
}
if (resource === 'customer') {
//https://developer.helpscout.com/mailbox-api/endpoints/customers/create
if (operation === 'create') {
const resolveData = this.getNodeParameter('resolveData', i);
const additionalFields = this.getNodeParameter('additionalFields', i);
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 NodeOperationError(this.getNode(), 'You have to set at least one field', {
itemIndex: i,
});
}
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 as string);
} 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 returnAll = this.getNodeParameter('returnAll', i);
const options = this.getNodeParameter('options', i);
Object.assign(qs, options);
if (returnAll) {
responseData = await helpscoutApiRequestAllItems.call(
this,
'_embedded.customers',
'GET',
'/v2/customers',
{},
qs,
);
} else {
qs.limit = this.getNodeParameter('limit', i);
responseData = await helpscoutApiRequestAllItems.call(
this,
'_embedded.customers',
'GET',
'/v2/customers',
{},
qs,
);
responseData = responseData.splice(0, qs.limit);
}
}
//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);
let body: ICustomer = {};
body = Object.assign({}, updateFields);
if (body.age) {
body.age = body.age.toString();
}
if (Object.keys(body).length === 0) {
throw new NodeOperationError(this.getNode(), 'You have to set at least one field', {
itemIndex: i,
});
}
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') {
const returnAll = this.getNodeParameter('returnAll', i);
if (returnAll) {
responseData = await helpscoutApiRequestAllItems.call(
this,
'_embedded.mailboxes',
'GET',
'/v2/mailboxes',
{},
qs,
);
} else {
qs.limit = this.getNodeParameter('limit', i);
responseData = await helpscoutApiRequestAllItems.call(
this,
'_embedded.mailboxes',
'GET',
'/v2/mailboxes',
{},
qs,
);
responseData = responseData.splice(0, qs.limit);
}
}
}
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 text = this.getNodeParameter('text', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i);
const attachments = this.getNodeParameter('attachmentsUi', i) as IDataObject;
let threadType = this.getNodeParameter('type', i) as string;
// We need to update the types to match the API - Avoids a breaking change
const singular = ['reply', 'customer'];
if (!singular.includes(threadType)) {
threadType = `${threadType}s`;
}
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 NodeOperationError(
this.getNode(),
'Either customer email or customer ID must be set',
{ itemIndex: i },
);
}
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 NodeOperationError(
this.getNode(),
`Binary property ${value.property} does not exist on input`,
{ itemIndex: i },
);
}
};
body.attachments?.push.apply(
body.attachments,
(attachments.attachmentsBinary as IDataObject[]).map(mapFunction),
);
}
}
responseData = await helpscoutApiRequest.call(
this,
'POST',
`/v2/conversations/${conversationId}/${threadType}`,
body,
);
responseData = { success: true };
}
//https://developer.helpscout.com/mailbox-api/endpoints/conversations/threads/list
if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i);
const conversationId = this.getNodeParameter('conversationId', i) as string;
if (returnAll) {
responseData = await helpscoutApiRequestAllItems.call(
this,
'_embedded.threads',
'GET',
`/v2/conversations/${conversationId}/threads`,
);
} else {
qs.limit = this.getNodeParameter('limit', i);
responseData = await helpscoutApiRequestAllItems.call(
this,
'_embedded.threads',
'GET',
`/v2/conversations/${conversationId}/threads`,
{},
qs,
);
responseData = responseData.splice(0, qs.limit);
}
}
}
} catch (error) {
if (this.continueOnFail()) {
const executionErrorData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.message }),
{ itemData: { item: i } },
);
returnData.push(...executionErrorData);
continue;
}
throw error;
}
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData as IDataObject[]),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
return [returnData];
}
}

View File

@@ -0,0 +1,18 @@
{
"node": "n8n-nodes-base.helpScoutTrigger",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": ["Communication"],
"resources": {
"credentialDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/credentials/helpScout/"
}
],
"primaryDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.helpscouttrigger/"
}
]
}
}

View File

@@ -0,0 +1,205 @@
import { createHmac } from 'crypto';
import type {
IHookFunctions,
IWebhookFunctions,
IDataObject,
INodeType,
INodeTypeDescription,
IWebhookResponseData,
} from 'n8n-workflow';
import { NodeConnectionTypes, randomString } from 'n8n-workflow';
import { helpscoutApiRequest, helpscoutApiRequestAllItems } from './GenericFunctions';
export class HelpScoutTrigger implements INodeType {
description: INodeTypeDescription = {
displayName: 'Help Scout Trigger',
name: 'helpScoutTrigger',
icon: 'file:helpScout.svg',
group: ['trigger'],
version: 1,
description: 'Starts the workflow when Help Scout events occur',
defaults: {
name: 'Help Scout Trigger',
},
inputs: [],
outputs: [NodeConnectionTypes.Main],
credentials: [
{
name: 'helpScoutOAuth2Api',
required: true,
},
],
webhooks: [
{
name: 'default',
httpMethod: 'POST',
responseMode: 'onReceived',
path: 'webhook',
},
],
properties: [
{
displayName: 'Events',
name: 'events',
type: 'multiOptions',
options: [
{
name: 'Conversation - Assigned',
value: 'convo.assigned',
},
{
name: 'Conversation - Created',
value: 'convo.created',
},
{
name: 'Conversation - Deleted',
value: 'convo.deleted',
},
{
name: 'Conversation - Merged',
value: 'convo.merged',
},
{
name: 'Conversation - Moved',
value: 'convo.moved',
},
{
name: 'Conversation - Status',
value: 'convo.status',
},
{
name: 'Conversation - Tags',
value: 'convo.tags',
},
{
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',
},
{
name: 'Rating - Received',
value: 'satisfaction.ratings',
},
],
default: [],
required: true,
},
],
};
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: randomString(10).toLowerCase(),
};
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 (error) {
return false;
}
// Remove from the static workflow data so that it is clear
// that no webhooks are registered 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 {};
}
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)],
};
}
}

View File

@@ -0,0 +1,82 @@
import type { INodeProperties } from 'n8n-workflow';
export const mailboxOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['mailbox'],
},
},
options: [
{
name: 'Get',
value: 'get',
description: 'Get data of a mailbox',
action: 'Get a mailbox',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get many mailboxes',
action: 'Get many mailboxes',
},
],
default: 'get',
},
];
export const mailboxFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* mailbox:get */
/* -------------------------------------------------------------------------- */
{
displayName: 'Mailbox ID',
name: 'mailboxId',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
resource: ['mailbox'],
operation: ['get'],
},
},
},
/* -------------------------------------------------------------------------- */
/* mailbox:getAll */
/* -------------------------------------------------------------------------- */
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
operation: ['getAll'],
resource: ['mailbox'],
},
},
default: false,
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
operation: ['getAll'],
resource: ['mailbox'],
returnAll: [false],
},
},
typeOptions: {
minValue: 1,
},
default: 50,
description: 'Max number of results to return',
},
];

View File

@@ -0,0 +1,257 @@
import type { INodeProperties } from 'n8n-workflow';
export const threadOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['thread'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new chat thread',
action: 'Create a thread',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get many chat threads',
action: 'Get many threads',
},
],
default: 'create',
},
];
export const threadFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* thread:create */
/* -------------------------------------------------------------------------- */
{
displayName: 'Conversation ID',
name: 'conversationId',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
resource: ['thread'],
operation: ['create'],
},
},
},
{
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: '',
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: 'Created At',
name: 'createdAt',
type: 'dateTime',
default: '',
},
{
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: 'Whether a draft reply is created',
},
{
displayName: 'Imported',
name: 'imported',
type: 'boolean',
default: false,
description: 'Whether no outgoing emails or notifications will be generated',
},
],
},
{
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: 'Attachments file name',
},
{
displayName: 'Mime Type',
name: 'mimeType',
type: 'string',
default: '',
description: 'Attachments 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'],
},
},
},
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
operation: ['getAll'],
resource: ['thread'],
},
},
default: false,
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
operation: ['getAll'],
resource: ['thread'],
returnAll: [false],
},
},
typeOptions: {
minValue: 1,
},
default: 50,
description: 'Max number of results to return',
},
];

View File

@@ -0,0 +1,15 @@
import type { 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[];
}

View File

@@ -0,0 +1,205 @@
{
"type": "object",
"properties": {
"_links": {
"type": "object",
"properties": {
"closedBy": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"createdByUser": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"mailbox": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"primaryCustomer": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"self": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"threads": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"web": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
}
}
},
"closedBy": {
"type": "integer"
},
"closedByUser": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"first": {
"type": "string"
},
"id": {
"type": "integer"
},
"last": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"createdAt": {
"type": "string"
},
"createdBy": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"first": {
"type": "string"
},
"id": {
"type": "integer"
},
"last": {
"type": "string"
},
"photoUrl": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"customerWaitingSince": {
"type": "object",
"properties": {
"friendly": {
"type": "string"
},
"time": {
"type": "string"
}
}
},
"folderId": {
"type": "integer"
},
"mailboxId": {
"type": "integer"
},
"number": {
"type": "integer"
},
"primaryCustomer": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"first": {
"type": "string"
},
"id": {
"type": "integer"
},
"last": {
"type": "string"
},
"photoUrl": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"source": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"via": {
"type": "string"
}
}
},
"state": {
"type": "string"
},
"status": {
"type": "string"
},
"subject": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"type": "object",
"properties": {
"color": {
"type": "string"
},
"id": {
"type": "integer"
},
"tag": {
"type": "string"
}
}
}
},
"threads": {
"type": "integer"
},
"type": {
"type": "string"
},
"userUpdatedAt": {
"type": "string"
}
},
"version": 1
}

View File

@@ -0,0 +1,262 @@
{
"type": "object",
"properties": {
"_links": {
"type": "object",
"properties": {
"assignee": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"closedBy": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"createdByUser": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"mailbox": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"primaryCustomer": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"self": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"threads": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"web": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
}
}
},
"assignee": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"first": {
"type": "string"
},
"id": {
"type": "integer"
},
"last": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"cc": {
"type": "array",
"items": {
"type": "string"
}
},
"closedBy": {
"type": "integer"
},
"closedByUser": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"first": {
"type": "string"
},
"id": {
"type": "integer"
},
"last": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"createdAt": {
"type": "string"
},
"createdBy": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"first": {
"type": "string"
},
"id": {
"type": "integer"
},
"last": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"customerWaitingSince": {
"type": "object",
"properties": {
"friendly": {
"type": "string"
},
"time": {
"type": "string"
}
}
},
"customFields": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"text": {
"type": "string"
},
"value": {
"type": "string"
}
}
}
},
"folderId": {
"type": "integer"
},
"id": {
"type": "integer"
},
"mailboxId": {
"type": "integer"
},
"number": {
"type": "integer"
},
"preview": {
"type": "string"
},
"primaryCustomer": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"first": {
"type": "string"
},
"id": {
"type": "integer"
},
"last": {
"type": "string"
},
"photoUrl": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"source": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"via": {
"type": "string"
}
}
},
"state": {
"type": "string"
},
"status": {
"type": "string"
},
"subject": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"type": "object",
"properties": {
"color": {
"type": "string"
},
"id": {
"type": "integer"
},
"tag": {
"type": "string"
}
}
}
},
"threads": {
"type": "integer"
},
"type": {
"type": "string"
},
"userUpdatedAt": {
"type": "string"
}
},
"version": 1
}

View File

@@ -0,0 +1,482 @@
{
"type": "object",
"properties": {
"_embedded": {
"type": "object",
"properties": {
"threads": {
"type": "array",
"items": {
"type": "object",
"properties": {
"_embedded": {
"type": "object",
"properties": {
"attachments": {
"type": "array",
"items": {
"type": "object",
"properties": {
"_links": {
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"self": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"web": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
}
}
},
"filename": {
"type": "string"
},
"height": {
"type": "integer"
},
"id": {
"type": "integer"
},
"mimeType": {
"type": "string"
},
"size": {
"type": "integer"
},
"state": {
"type": "string"
},
"width": {
"type": "integer"
}
}
}
}
}
},
"_links": {
"type": "object",
"properties": {
"assignedTo": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"createdByCustomer": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"createdByUser": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"customer": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
}
}
},
"action": {
"type": "object",
"properties": {
"associatedEntities": {
"type": "object",
"properties": {
"user": {
"type": "integer"
}
}
},
"text": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"assignedTo": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"first": {
"type": "string"
},
"id": {
"type": "integer"
},
"last": {
"type": "string"
},
"photoUrl": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"body": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"createdBy": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"first": {
"type": "string"
},
"id": {
"type": "integer"
},
"last": {
"type": "string"
},
"photoUrl": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"customer": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"first": {
"type": "string"
},
"id": {
"type": "integer"
},
"last": {
"type": "string"
},
"photoUrl": {
"type": "string"
}
}
},
"id": {
"type": "integer"
},
"openedAt": {
"type": "string"
},
"savedReplyId": {
"type": "integer"
},
"source": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"via": {
"type": "string"
}
}
},
"state": {
"type": "string"
},
"status": {
"type": "string"
},
"to": {
"type": "array",
"items": {
"type": "string"
}
},
"type": {
"type": "string"
}
}
}
}
}
},
"_links": {
"type": "object",
"properties": {
"closedBy": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"createdByCustomer": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"mailbox": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"primaryCustomer": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"self": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"threads": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"web": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
}
}
},
"bcc": {
"type": "array",
"items": {
"type": "string"
}
},
"cc": {
"type": "array",
"items": {
"type": "string"
}
},
"closedBy": {
"type": "integer"
},
"closedByUser": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"first": {
"type": "string"
},
"id": {
"type": "integer"
},
"last": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"createdAt": {
"type": "string"
},
"createdBy": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"first": {
"type": "string"
},
"id": {
"type": "integer"
},
"last": {
"type": "string"
},
"photoUrl": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"customerWaitingSince": {
"type": "object",
"properties": {
"friendly": {
"type": "string"
},
"time": {
"type": "string"
}
}
},
"customFields": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"text": {
"type": "string"
},
"value": {
"type": "string"
}
}
}
},
"folderId": {
"type": "integer"
},
"id": {
"type": "integer"
},
"mailboxId": {
"type": "integer"
},
"number": {
"type": "integer"
},
"preview": {
"type": "string"
},
"primaryCustomer": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"first": {
"type": "string"
},
"id": {
"type": "integer"
},
"last": {
"type": "string"
},
"photoUrl": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"source": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"via": {
"type": "string"
}
}
},
"state": {
"type": "string"
},
"status": {
"type": "string"
},
"subject": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"type": "object",
"properties": {
"color": {
"type": "string"
},
"id": {
"type": "integer"
},
"tag": {
"type": "string"
}
}
}
},
"threads": {
"type": "integer"
},
"type": {
"type": "string"
},
"userUpdatedAt": {
"type": "string"
}
},
"version": 1
}

View File

@@ -0,0 +1,53 @@
{
"type": "object",
"properties": {
"_links": {
"type": "object",
"properties": {
"fields": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"folders": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
},
"self": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
}
}
}
},
"createdAt": {
"type": "string"
},
"email": {
"type": "string"
},
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"slug": {
"type": "string"
},
"updatedAt": {
"type": "string"
}
},
"version": 1
}

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="310" preserveAspectRatio="xMidYMid"><path fill="#304DDB" d="m18.432 180.969 90.484-90.485a63.72 63.72 0 0 0 18.99-45.428A64.25 64.25 0 0 0 109.476 0L18.99 90.484A63.72 63.72 0 0 0 0 135.913c0 17.687 7.075 33.512 18.432 45.056m219.136-52.876-90.484 90.484a63.72 63.72 0 0 0-18.99 45.429 64.25 64.25 0 0 0 18.431 45.056l90.484-90.485A63.72 63.72 0 0 0 256 173.15c0-17.687-7.075-33.513-18.432-45.056zm-.559-37.422A63.72 63.72 0 0 0 256 45.242 64.25 64.25 0 0 0 237.568.186L18.991 218.577C7.26 230.307 0 246.32 0 264.192a64.25 64.25 0 0 0 18.432 45.056z"/></svg>

After

Width:  |  Height:  |  Size: 619 B