diff --git a/packages/nodes-base/nodes/Intercom/Intercom.node.ts b/packages/nodes-base/nodes/Intercom/Intercom.node.ts index ea635e22b7..58fe5ebe94 100644 --- a/packages/nodes-base/nodes/Intercom/Intercom.node.ts +++ b/packages/nodes-base/nodes/Intercom/Intercom.node.ts @@ -97,9 +97,9 @@ export class Intercom implements INodeType { let responseData; for (let i = 0; i < length; i++) { const resource = this.getNodeParameter('resource', 0) as string; - const opeation = this.getNodeParameter('operation', 0) as string; + const operation = this.getNodeParameter('operation', 0) as string; if (resource === 'lead') { - if (opeation === 'create') { + if (operation === 'create' || operation === 'update') { const email = this.getNodeParameter('email', i) as string; const options = this.getNodeParameter('options', i) as IDataObject; const jsonActive = this.getNodeParameter('jsonParameters', i) as boolean; @@ -144,6 +144,16 @@ export class Intercom implements INodeType { body.custom_attributes = customAttributesJson; } } + if (operation === 'update') { + const updateBy = this.getNodeParameter('updateBy', 0) as string; + const value = this.getNodeParameter('value', i) as string; + if (updateBy === 'userId') { + body.user_id = value; + } + if (updateBy === 'id') { + body.id = value; + } + } try { responseData = await intercomApiRequest.call(this, '/contacts', 'POST', body); } catch (err) { diff --git a/packages/nodes-base/nodes/Intercom/LeadDescription.ts b/packages/nodes-base/nodes/Intercom/LeadDescription.ts index 44dc94b594..5e5f53bd01 100644 --- a/packages/nodes-base/nodes/Intercom/LeadDescription.ts +++ b/packages/nodes-base/nodes/Intercom/LeadDescription.ts @@ -18,6 +18,11 @@ export const leadOpeations = [ value: 'create', description: 'Create a new lead', }, + { + name: 'Update', + value: 'update', + description: 'Update a new lead', + }, ], default: '', description: 'The operation to perform.', @@ -25,6 +30,55 @@ export const leadOpeations = [ ] as INodeProperties[]; export const leadFields = [ + { + displayName: 'Update By', + name: 'updateBy', + type: 'options', + displayOptions: { + show: { + resource: [ + 'lead', + ], + operation: [ + 'update', + ], + }, + }, + options: [ + { + name: 'User Id', + value: 'userId', + default: '', + description: 'Automatically generated identifier for the Lead', + }, + { + name: 'Id', + value: 'id', + default: '', + description: 'The Intercom defined id representing the Lead', + }, + ], + default: '', + description: 'Update by', + }, + { + displayName: 'Value', + name: 'value', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + resource: [ + 'lead', + ], + operation: [ + 'update', + ], + }, + }, + description: 'Update by value', + }, { displayName: 'Email', name: 'email', @@ -43,6 +97,24 @@ export const leadFields = [ }, description: 'The email of the user.', }, + { + displayName: 'Email', + name: 'email', + type: 'string', + default: '', + required: false, + displayOptions: { + show: { + resource: [ + 'lead', + ], + operation: [ + 'update', + ], + }, + }, + description: 'The email of the user.', + }, { displayName: 'JSON Parameters', name: 'jsonParameters', @@ -53,6 +125,7 @@ export const leadFields = [ show: { operation: [ 'create', + 'update', ], resource: [ 'lead' @@ -70,6 +143,7 @@ export const leadFields = [ show: { operation: [ 'create', + 'update', ], resource: [ 'lead' @@ -82,7 +156,6 @@ export const leadFields = [ name: 'phone', type: 'string', default: '', - required: false, description: 'The phone number of the user', }, { @@ -107,7 +180,6 @@ export const leadFields = [ type: 'boolean', default: false, options: [], - required: false, description: `A boolean value, which if true, instructs Intercom to update the users' last_request_at value to the current API service time in UTC. default value if not sent is false.`, }, { @@ -118,7 +190,6 @@ export const leadFields = [ loadOptionsMethod: 'getCompanies', }, default: [], - required: false, description: 'Identifies the companies this user belongs to.', }, ] @@ -138,6 +209,7 @@ export const leadFields = [ ], operation: [ 'create', + 'update', ], jsonParameters: [ true, @@ -164,6 +236,7 @@ export const leadFields = [ ], operation: [ 'create', + 'update', ], jsonParameters: [ false, diff --git a/packages/nodes-base/nodes/Intercom/LeadInterface.ts b/packages/nodes-base/nodes/Intercom/LeadInterface.ts index 480407bafb..b7e4f9a000 100644 --- a/packages/nodes-base/nodes/Intercom/LeadInterface.ts +++ b/packages/nodes-base/nodes/Intercom/LeadInterface.ts @@ -5,6 +5,8 @@ export interface ILeadCompany { } export interface ILead { + user_id?: string; + id?: string; email: string; phone?: string; name?: string;