1. Tasks
  2. Find or Create Contact

Tasks

Find or Create Contact

The Find or Create Contact task adds a contact to an existing contact list on a stub. If the contact already exists in the org, it will add the existing contact to the contact list. Otherwise it will create a new contact with the contact point in the task definition in the org, and add it the contact list.

It finds existing contacts using the contact point in the task definition.

Basic usage

Add a contact to the Field Technicians contact list.

loading...

Parameters

list_name

required
string

The name of an existing contact list on the stub to add the contact to. If the contact list does not already exist, this task will fail.


contactpoint

required
string

The value of the contact point. This depends on the type of the contact point.

Examples in the form {{example_type}}:{{example_contactpoint}}:

  • email:technician1@bobstechnicians.com
  • mobile:+27711234321

type

required
string

The type of contactpoint associated with the contactpoint to be added to the contact list.

Examples:

  • email
  • stubberhandle
  • mobile

Refer to the Contacts documentation for more information on the type of contactpoints.


descname

optional
string

A descriptive name for the contact.

Examples

  • John Doe
  • Advanced Support.
  • ~~#jsonata#$substringBefore(stubpost.data._email_in.from_address, "@")

Result

editor
        {
"find_or_create_contact": {
  "success": true,
  "payload": {
    "found": true,
    "contact": // an entire contact document, example below
}
}

      

Properties

found

boolean

Whether or not the contact was found.

contact

object

This will be an entire contact object as it exists in your org's database.

Example contact object:

editor
        {
  "orguuid": "someuuid",
  "type": "individual",
  "basic": {
    "descname": "Auto Created - newemployee@stubber.com"
  },
  "details": {},
  "contactpoints": [
    {
      "contact": "newemployee@stubber.com",
      "type": "email",
      "uuid": "someuuid"
    }
  ],
  "is_representative_contact": false,
  "contactuuid": "someuuid",
  "data": {},
  "createdAt": "2024-02-16T15:07:45.375Z",
  "updatedAt": "2024-02-16T15:07:45.375Z",
}

      

Examples

These are some more examples

Add Contact using mobile contact point from Whatsapp with a descriptive name

editor
        {
    "tasktype": "find_or_create_contact",
    "params": {
        "list_name": "customer",
        "type":"mobile",
        "contactpoint":"~~stubpost.data.mobile_number"
        "descname": "~~stubpost.data.customer_name"
    }
}


      

Result

editor
        {
    "success": true,
    "payload": {
        "found": false,
        "contact": // the newly created contact document.
    }
}