'Create a new contact or update an existing one if email or phone matches (upsert)',
name:'contactCreateNotice',
type:'notice',
displayOptions:{
show:{
resource:['contact'],
operation:['create'],
},
},
default:'',
},
];
constcustomFields: INodeProperties={
displayName:'Custom Fields',
name:'customFields',
placeholder:'Add Field',
type:'fixedCollection',
default:{},
typeOptions:{
multipleValues: true,
},
options:[
{
name:'values',
displayName:'Value',
values:[
{
displayName:'Field Name or ID',
name:'fieldId',
type:'options',
required: true,
default:'',
description:
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/nodes/expressions.html#expressions">expression</a>',
typeOptions:{
loadOptions:{
routing:{
request:{
url:'/custom-fields',
method:'GET',
},
output:{
postReceive:[
{
type:'rootProperty',
properties:{
property:'customFields',
},
},
{
type:'setKeyValue',
properties:{
name:'={{$responseItem.name}}',
value:'={{$responseItem.id}}',
},
},
{
type:'sort',
properties:{
key:'name',
},
},
],
},
},
},
},
},
{
displayName:'Field Value',
name:'fieldValue',
type:'string',
default:'',
routing:{
send:{
value:'={{$value}}',
property:'=customField.{{$parent.fieldId}}',
type:'body',
},
},
},
],
},
],
};
constcreateProperties: INodeProperties[]=[
{
displayName:'Email',
name:'email',
type:'string',
placeholder:'name@email.com',
description:'Email or Phone are required to create contact',
displayOptions:{
show:{
resource:['contact'],
operation:['create'],
},
},
default:'',
routing:{
send:{
type:'body',
property:'email',
},
},
},
{
displayName:'Phone',
name:'phone',
type:'string',
description:
'Phone or Email are required to create contact. Phone number has to start with a valid <a href="https://en.wikipedia.org/wiki/List_of_country_calling_codes">country code</a> leading with + sign.',
placeholder:'+491234567890',
displayOptions:{
show:{
resource:['contact'],
operation:['create'],
},
},
default:'',
routing:{
send:{
type:'body',
property:'phone',
},
},
},
{
displayName:'Additional Fields',
name:'additionalFields',
type:'collection',
placeholder:'Add Field',
default:{},
displayOptions:{
show:{
resource:['contact'],
operation:['create'],
},
},
options:[
{
displayName:'Address',
name:'address1',
type:'string',
default:'',
routing:{
send:{
type:'body',
property:'address1',
},
},
},
{
displayName:'City',
name:'city',
type:'string',
default:'',
routing:{
send:{
type:'body',
property:'city',
},
},
},
customFields,
{
displayName:'Do Not Disturb',
name:'dnd',
description:
'Whether automated/manual outbound messages are permitted to go out or not. True means NO outbound messages are permitted.',
type:'boolean',
default:false,
routing:{
send:{
type:'body',
property:'dnd',
},
},
},
{
displayName:'First Name',
name:'firstName',
type:'string',
default:'',
routing:{
send:{
type:'body',
property:'firstName',
},
},
},
{
displayName:'Last Name',
name:'lastName',
type:'string',
default:'',
routing:{
send:{
type:'body',
property:'lastName',
},
},
},
{
displayName:'Name',
name:'name',
type:'string',
default:'e.g. John Deo',
description:
"The full name of the contact, will be overwritten by 'First Name' and 'Last Name' if set",
routing:{
send:{
type:'body',
property:'name',
},
},
},
{
displayName:'Postal Code',
name:'postalCode',
type:'string',
default:'',
routing:{
send:{
type:'body',
property:'postalCode',
},
},
},
{
displayName:'Source',
name:'source',
type:'string',
default:'',
placeholder:'e.g. Public API',
routing:{
send:{
type:'body',
property:'source',
},
},
},
{
displayName:'State',
name:'state',
type:'string',
default:'',
routing:{
send:{
type:'body',
property:'state',
},
},
},
{
displayName:'Tags',
name:'tags',
type:'string',
hint:'Comma separated list of tags, array of strings can be set in expression',