Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pipedrive Data Synchronization

This project synchronizes person data from a JSON file with Pipedrive.

The input data and the fields to be mapped are kept in separate JSON files. The application reads the mappings and uses them to create the Pipedrive person payload.

How it works

The application follows this flow:

  1. Read the person data from inputData.json.
  2. Read the field mappings from mappings.json.
  3. Find the field that is mapped to the Pipedrive name field.
  4. Search Pipedrive for a person with that name.
  5. If the person exists, update the existing record.
  6. If the person does not exist, create a new record.

Nested input fields are also supported. For example:

{
  "pipedriveKey": "phone",
  "inputKey": "phoneNumber.home"
}

will get the value from phoneNumber.home in inputData.json.

Project Structure

src/
├── index.ts
├── mappings/
│   ├── inputData.json
│   └── mappings.json
└── types/
    └── pipedrive.ts

Requirements

  • Node.js
  • npm
  • A Pipedrive account
  • Pipedrive API key

Setup

Clone the repository and install the dependencies:

git clone https://github.com/vsarvani2004/pd-sync-assignment.git
cd pd-sync-assignment
npm install

Create a .env file in the project root:

PIPEDRIVE_API_KEY=your_api_key
PIPEDRIVE_COMPANY_DOMAIN=your_company_domain

The .env file is not included in the repository.

Run the project

First build the TypeScript code:

npm run build

Then run the application:

npm start

Example mapping

The current mapping file contains mappings such as:

[
  {
    "pipedriveKey": "name",
    "inputKey": "fullName"
  },
  {
    "pipedriveKey": "email",
    "inputKey": "emailAdress"
  },
  {
    "pipedriveKey": "phone",
    "inputKey": "phoneNumber.home"
  }
]

The mappings are processed dynamically, so the synchronization logic does not depend on the input field names being hardcoded.

Error handling

The application handles cases such as:

  • Missing Pipedrive API key or company domain
  • Missing name mapping
  • Missing or empty input fields
  • Invalid email or phone values
  • Pipedrive API request failures
  • Invalid responses from the Pipedrive API

If an optional mapped field is missing, that mapping is skipped instead of stopping the complete synchronization.

Testing

The synchronization was tested with both cases:

  • An existing Pipedrive person was found and updated.
  • A new person name was used and a new Pipedrive person was created.

Security

The Pipedrive API key is stored in .env.

The following are excluded from Git:

.env
node_modules/
dist/
*.log

The API key should not be committed to the repository.

About

TypeScript assignment implementing Pipedrive person data synchronization with dynamic field mapping, including search, create, update, validation, and error handling.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages