Blueprints

Sync new users from Postgres to HubSpot

Source

yaml
id: hubspot-postgres-sync
namespace: blueprints
tasks:
  - id: each
    type: io.kestra.plugin.core.flow.ForEach
    values: "{{ trigger.rows }}"
    tasks:
      - id: create_contact_in_hubspot
        type: io.kestra.plugin.hubspot.contacts.Create
        apiKey: "{{ secret('HUBSPOT_API_KEY') }}"
        email: "{{ json(taskrun.value).Email }}"
        firstName: "{{ json(taskrun.value).FirstName }}"
        lastName: "{{ json(taskrun.value).LastName }}"
        phone: "{{ json(taskrun.value).Phone }}"
        jobTitle: "{{ json(taskrun.value).JobTitle }}"

triggers:
  - id: postgres_trigger
    type: io.kestra.plugin.jdbc.postgresql.Trigger
    sql: |
      SELECT 
        first_name as "FirstName", 
        last_name as "LastName", 
        email as "Email",
        phone as "Phone",
        job_title as "JobTitle"
      FROM customers
      WHERE updated_at > CURRENT_DATE - INTERVAL '1 day'
      AND (processed_at IS NULL OR processed_at < updated_at)
    interval: PT5M
    fetchType: FETCH

pluginDefaults:
  - type: io.kestra.plugin.jdbc.postgresql
    values:
      url: "{{ secret('POSTGRES_URL') }}"
      username: "{{ secret('POSTGRES_USERNAME') }}"
      password: "{{ secret('POSTGRES_PASSWORD') }}"

About this blueprint

SQL API

This flow syncs user data from Postgres to HubSpot by creating new contacts.

For Each

Create

Trigger

postgresql

More Related Blueprints

New to Kestra?

Use blueprints to kickstart your first workflows.

Get started with Kestra