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.
The application follows this flow:
- Read the person data from
inputData.json. - Read the field mappings from
mappings.json. - Find the field that is mapped to the Pipedrive
namefield. - Search Pipedrive for a person with that name.
- If the person exists, update the existing record.
- 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.
src/
├── index.ts
├── mappings/
│ ├── inputData.json
│ └── mappings.json
└── types/
└── pipedrive.ts
- Node.js
- npm
- A Pipedrive account
- Pipedrive API key
Clone the repository and install the dependencies:
git clone https://github.com/vsarvani2004/pd-sync-assignment.git
cd pd-sync-assignment
npm installCreate a .env file in the project root:
PIPEDRIVE_API_KEY=your_api_key
PIPEDRIVE_COMPANY_DOMAIN=your_company_domainThe .env file is not included in the repository.
First build the TypeScript code:
npm run buildThen run the application:
npm startThe 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.
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.
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.
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.