Skip to content

feat: remove Revert.dev dependency from Pipedrive integration #22492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

anikdhabal
Copy link
Contributor

@anikdhabal anikdhabal commented Jul 14, 2025

Remove Revert.dev dependency from Pipedrive integration

Fixes #16797

Summary

This PR removes the dependency on Revert.dev from the Pipedrive CRM integration and implements direct OAuth2 authentication with Pipedrive's native API. The changes follow the same patterns used by other CRM integrations in the codebase (particularly HubSpot).

Key Changes:

  • OAuth Flow: Replaced Revert redirect with direct Pipedrive OAuth2 authorization
  • API Integration: Converted all API calls from Revert's unified format to Pipedrive's native REST API
  • Token Management: Implemented OAuth token storage and basic refresh logic
  • Environment Variables: Removed REVERT_* variables, now requires PIPEDRIVE_CLIENT_ID and PIPEDRIVE_CLIENT_SECRET
  • Data Mapping: Mapped contact and activity data between Revert's unified format and Pipedrive's native structure

Breaking Change: Existing Pipedrive integrations will need to be reconfigured with new OAuth credentials.

Review & Testing Checklist for Human

  • Test OAuth flow end-to-end - Create a Pipedrive OAuth app and verify the complete authorization flow works
  • Test contact creation and search - Verify contacts can be created and searched properly with real data
  • Test activity/meeting management - Verify activities can be created, updated, and deleted correctly
  • Verify token refresh logic - The current implementation is incomplete and may need proper refresh token handling
  • Test error handling - Verify proper error responses for failed API calls and invalid tokens

Recommended Test Plan:

  1. Set up a Pipedrive developer account and create an OAuth app
  2. Configure PIPEDRIVE_CLIENT_ID and PIPEDRIVE_CLIENT_SECRET in environment
  3. Test the integration setup flow in Cal.com
  4. Create a test booking and verify it creates contacts and activities in Pipedrive
  5. Test updating and canceling bookings

Diagram

%%{ init : { "theme" : "default" }}%%
graph TB
    subgraph "OAuth Flow"
        A["api/add.ts<br/>OAuth Authorization"]:::major-edit
        B["api/callback.ts<br/>Token Exchange"]:::major-edit
    end
    
    subgraph "CRM Integration"
        C["lib/CrmService.ts<br/>Pipedrive API Client"]:::major-edit
        D["config.json<br/>App Configuration"]:::minor-edit
    end
    
    subgraph "Configuration"
        E["turbo.json<br/>Environment Variables"]:::minor-edit
        F[".env.appStore.example<br/>Environment Template"]:::minor-edit
    end
    
    subgraph "External APIs"
        G["Pipedrive OAuth API<br/>oauth.pipedrive.com"]:::context
        H["Pipedrive REST API<br/>api.pipedrive.com"]:::context
    end
    
    A --> B
    B --> C
    C --> H
    A --> G
    B --> G
    C --> D
    
    subgraph Legend
        L1[Major Edit]:::major-edit
        L2[Minor Edit]:::minor-edit
        L3[Context/No Edit]:::context
    end
    
    classDef major-edit fill:#90EE90
    classDef minor-edit fill:#ADD8E6
    classDef context fill:#FFFFFF
Loading

Notes

  • Token Refresh: The current getValidAccessToken() implementation is incomplete - it doesn't actually refresh expired tokens, just returns the existing one. This should be addressed before production use.
  • OAuth Scopes: Using comprehensive scopes: deals:read,deals:write,persons:read,persons:write,activities:read,activities:write
  • API Mapping: Activities are used for meetings/events instead of a separate events API, following Pipedrive's data model
  • Error Handling: Basic error handling is implemented but may need enhancement for production edge cases

Session Info:

- Replace Revert API calls with direct Pipedrive OAuth2 and REST API
- Update OAuth flow to use Pipedrive's authorization endpoint
- Implement token exchange in callback handler
- Map Revert's unified API format to Pipedrive's native API structure
- Remove REVERT_* environment variables from configuration
- Update app config to reflect direct Pipedrive integration
- Follow patterns from other CRM integrations like HubSpot

Breaking change: Requires PIPEDRIVE_CLIENT_ID and PIPEDRIVE_CLIENT_SECRET
environment variables instead of REVERT_* variables

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Contributor

coderabbitai bot commented Jul 14, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch devin/remove-revert-pipedrive-1752520608

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the ❗️ .env changes contains changes to env variables label Jul 14, 2025
Copy link

vercel bot commented Jul 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Aug 11, 2025 9:44am
cal-eu ⬜️ Ignored (Inspect) Visit Preview Aug 11, 2025 9:44am

@keithwillcode keithwillcode added the core area: core, team members only label Jul 14, 2025
Copy link

delve-auditor bot commented Jul 14, 2025

No security or compliance issues detected. Reviewed everything up to 9b9d86b.

Security Overview
  • 🔎 Scanned files: 6 changed file(s)
Detected Code Changes
Change Type Relevant files
Configuration changes ► .env.appStore.example
    Remove REVERT-related environment variables
► turbo.json
    Remove REVERT environment variables
Enhancement ► add.ts
    Implement direct Pipedrive OAuth flow
► callback.ts
    Add Pipedrive token exchange handling
► config.json
    Update app configuration for direct Pipedrive integration
► CrmService.ts
    Replace Revert API with direct Pipedrive API implementation

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

- Add token refresh implementation following Pipedrive OAuth2 specification
- Use proper Basic Auth for token refresh requests
- Handle token refresh errors with appropriate logging
- Update access token and expiry date after successful refresh
- Add note about database credential update requirement

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>
@vercel vercel bot temporarily deployed to Preview – api July 14, 2025 19:50 Inactive
@vercel vercel bot temporarily deployed to Preview – cal July 14, 2025 19:50 Inactive
- Import updateTokenObjectInDb utility for proper credential management
- Store credentialId in constructor for database updates
- Update token refresh logic to persist refreshed tokens to database
- Follow Cal.com patterns for OAuth credential management
- Ensure tokens are properly updated after successful refresh

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>
dakshgup added a commit to dakshgup/cal.com that referenced this pull request Jul 14, 2025
…drive integration

Originally by: anikdhabal

# Remove Revert.dev dependency from Pipedrive integration

## Summary

This PR removes the dependency on Revert.dev from the Pipedrive CRM integration and implements direct OAuth2 authentication with Pipedrive's native API. The changes follow the same patterns used by other CRM integrations in the codebase (particularly HubSpot).

**Key Changes:**
- **OAuth Flow**: Replaced Revert redirect with direct Pipedrive OAuth2 authorization
- **API Integration**: Converted all API calls from Revert's unified format to Pipedrive's native REST API
- **Token Management**: Implemented OAuth token storage and basic refresh logic
- **Environment Variables**: Removed `REVERT_*` variables, now requires `PIPEDRIVE_CLIENT_ID` and `PIPEDRIVE_CLIENT_SECRET`
- **Data Mapping**: Mapped contact and activity data between Revert's unified format and Pipedrive's native structure

**Breaking Change**: Existing Pipedrive integrations will need to be reconfigured with new OAuth credentials.

## Review & Testing Checklist for Human

- [ ] **Test OAuth flow end-to-end** - Create a Pipedrive OAuth app and verify the complete authorization flow works
- [ ] **Test contact creation and search** - Verify contacts can be created and searched properly with real data
- [ ] **Test activity/meeting management** - Verify activities can be created, updated, and deleted correctly
- [ ] **Verify token refresh logic** - The current implementation is incomplete and may need proper refresh token handling
- [ ] **Test error handling** - Verify proper error responses for failed API calls and invalid tokens

**Recommended Test Plan:**
1. Set up a Pipedrive developer account and create an OAuth app
2. Configure `PIPEDRIVE_CLIENT_ID` and `PIPEDRIVE_CLIENT_SECRET` in environment
3. Test the integration setup flow in Cal.com
4. Create a test booking and verify it creates contacts and activities in Pipedrive
5. Test updating and canceling bookings

---

### Diagram

```mermaid
%%{ init : { "theme" : "default" }}%%
graph TB
    subgraph "OAuth Flow"
        A["api/add.ts<br/>OAuth Authorization"]:::major-edit
        B["api/callback.ts<br/>Token Exchange"]:::major-edit
    end

    subgraph "CRM Integration"
        C["lib/CrmService.ts<br/>Pipedrive API Client"]:::major-edit
        D["config.json<br/>App Configuration"]:::minor-edit
    end

    subgraph "Configuration"
        E["turbo.json<br/>Environment Variables"]:::minor-edit
        F[".env.appStore.example<br/>Environment Template"]:::minor-edit
    end

    subgraph "External APIs"
        G["Pipedrive OAuth API<br/>oauth.pipedrive.com"]:::context
        H["Pipedrive REST API<br/>api.pipedrive.com"]:::context
    end

    A --> B
    B --> C
    C --> H
    A --> G
    B --> G
    C --> D

    subgraph Legend
        L1[Major Edit]:::major-edit
        L2[Minor Edit]:::minor-edit
        L3[Context/No Edit]:::context
    end

    classDef major-edit fill:#90EE90
    classDef minor-edit fill:#ADD8E6
    classDef context fill:#FFFFFF
```

### Notes

- **Token Refresh**: The current `getValidAccessToken()` implementation is incomplete - it doesn't actually refresh expired tokens, just returns the existing one. This should be addressed before production use.
- **OAuth Scopes**: Using comprehensive scopes: `deals:read,deals:write,persons:read,persons:write,activities:read,activities:write`
- **API Mapping**: Activities are used for meetings/events instead of a separate events API, following Pipedrive's data model
- **Error Handling**: Basic error handling is implemented but may need enhancement for production edge cases

**Session Info**:
- Link to Devin run: https://app.devin.ai/sessions/ca8c7c0a8b9b4b87ae92d5db2d23039a
- Requested by: @anikdhabal
Copy link
Contributor

This PR is being marked as stale due to inactivity.

@github-actions github-actions bot added the Stale label Jul 29, 2025
@github-actions github-actions bot added $50 community Created by Linear-GitHub Sync crm-apps area: crm apps, salesforce, hubspot, close.com, sendgrid Medium priority Created by Linear-GitHub Sync Stale ✨ feature New feature or request 💎 Bounty A bounty on Algora.io labels Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💎 Bounty A bounty on Algora.io community Created by Linear-GitHub Sync core area: core, team members only crm-apps area: crm apps, salesforce, hubspot, close.com, sendgrid ❗️ .env changes contains changes to env variables ✨ feature New feature or request Medium priority Created by Linear-GitHub Sync Stale $50
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Native Pipedrive integration
2 participants