Hubspot - Jira "Company sync"

Hi Community,

I am new to using Pipedream and need to use it to connect between Hubspot and Jira cloud.

Requirement:
Sync all companies dynamically from Hubspot to Jira so that they appear in a new Jira custom field (on all tickets) as a custom single-select dropdown field.

I know their are ready-made Jira add-ons that can perform this, however my company has sugggested that we build this using Pipedream as the integrator between the two applications.

I’m pretty sure there are two parts (at least) to this request:

  1. Build a custom single-select list in Jira using code
  2. Populated this custom list dynamically using Pipedream - as companies are added/removed from Hubspot

Any assistance would be much appreciated to start me off in the right direction.
Thank you in advance,

Kevin

Hi @kdickson,

To achieve your goal of syncing companies from HubSpot to Jira using Pipedream, you’ll need to set up a workflow with the following steps:

  1. Trigger: Use a HubSpot trigger to detect when a new company is added or an existing company is updated. You can use the “New Company” or “Company Updated” triggers available in Pipedream.

  2. Action: Use a custom action to update the Jira custom field with the company data from HubSpot. This involves making API calls to both HubSpot and Jira.

Here’s a step-by-step guide to get you started:

Step 1: Set Up the HubSpot Trigger

  1. Search for the HubSpot app in the Pipedream trigger menu.
  2. Select the “New Company” or “Company Updated” trigger.
  3. Connect your HubSpot account.
  4. Follow the instructions on the trigger configuration screen. You may need to generate a test event from HubSpot to get real data to test your workflow.

Step 2: Create a Custom Action to Update Jira

You’ll need to write a custom Pipedream component to update the Jira custom field. Here’s an example of how you might structure this component:

import { axios } from "@pipedream/platform";

export default defineComponent({
  props: {
    jira: {
      type: "app",
      app: "jira",
    },
    hubspot: {
      type: "app",
      app: "hubspot",
    },
  },
  async run({ steps, $ }) {
    // Fetch companies from HubSpot
    const companies = await axios($, {
      url: `https://api.hubapi.com/companies/v2/companies/paged`,
      headers: {
        Authorization: `Bearer ${this.hubspot.$auth.oauth_access_token}`,
      },
    });

    // Update Jira custom field with company data
    const jiraResponse = await axios($, {
      url: `https://api.atlassian.com/ex/jira/{cloudid}/rest/api/3/field/{fieldId}/option`,
      method: "POST",
      headers: {
        Authorization: `Bearer ${this.jira.$auth.oauth_access_token}`,
        "Content-Type": "application/json",
      },
      data: {
        options: companies.results.map(company => ({
          value: company.properties.name.value,
        })),
      },
    });

    return jiraResponse;
  },
});

Notes:

  • Replace {cloudid} and {fieldId} with your actual Jira Cloud ID and the ID of the custom field you want to update.
  • Handle Pagination: The HubSpot API may return paginated results. Ensure you handle pagination to fetch all companies.
  • Error Handling: Implement error handling to manage API rate limits and other potential issues.

Step 3: Test and Deploy

  1. Test your workflow with sample data to ensure it behaves as expected.
  2. Deploy the workflow to automate the process of syncing companies from HubSpot to Jira.

If you have further questions or need additional help, feel free to ask!

I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double-check my answers and code! Learn how to build your own.