diff --git a/packages/backend/src/apps/hubspot/actions/index.js b/packages/backend/src/apps/hubspot/actions/index.js index 9dbfbd06..3f735c73 100644 --- a/packages/backend/src/apps/hubspot/actions/index.js +++ b/packages/backend/src/apps/hubspot/actions/index.js @@ -1,3 +1,4 @@ import createContact from './create-contact/index.js'; +import updateContact from './update-contact/index.js'; -export default [createContact]; +export default [createContact, updateContact]; diff --git a/packages/backend/src/apps/hubspot/actions/update-contact/index.js b/packages/backend/src/apps/hubspot/actions/update-contact/index.js new file mode 100644 index 00000000..25a4a6e7 --- /dev/null +++ b/packages/backend/src/apps/hubspot/actions/update-contact/index.js @@ -0,0 +1,96 @@ +import defineAction from '../../../../helpers/define-action.js'; + +export default defineAction({ + name: 'Update contact', + key: 'updateContact', + description: `Updates an existing contact on user's account.`, + arguments: [ + { + label: 'Contact ID', + key: 'contactId', + type: 'string', + required: true, + variables: true, + }, + { + label: 'Company name', + key: 'company', + type: 'string', + required: false, + variables: true, + }, + { + label: 'Email', + key: 'email', + type: 'string', + required: false, + variables: true, + }, + { + label: 'First name', + key: 'firstName', + type: 'string', + required: false, + variables: true, + }, + { + label: 'Last name', + key: 'lastName', + type: 'string', + required: false, + description: 'Last name', + variables: true, + }, + { + label: 'Phone', + key: 'phone', + type: 'string', + required: false, + variables: true, + }, + { + label: 'Website URL', + key: 'website', + type: 'string', + required: false, + variables: true, + }, + { + label: 'Owner ID', + key: 'hubspotOwnerId', + type: 'string', + required: false, + variables: true, + }, + ], + + async run($) { + const { + contactId, + company, + email, + firstName, + lastName, + phone, + website, + hubspotOwnerId, + } = $.step.parameters; + + const response = await $.http.patch( + `crm/v3/objects/contacts/${contactId}`, + { + properties: { + company, + email, + firstname: firstName, + lastname: lastName, + phone, + website, + hubspot_owner_id: hubspotOwnerId, + }, + } + ); + + $.setActionItem({ raw: response.data }); + }, +}); diff --git a/packages/docs/pages/apps/hubspot/actions.md b/packages/docs/pages/apps/hubspot/actions.md index f2ae7746..def938e3 100644 --- a/packages/docs/pages/apps/hubspot/actions.md +++ b/packages/docs/pages/apps/hubspot/actions.md @@ -3,6 +3,8 @@ favicon: /favicons/hubspot.svg items: - name: Create a contact desc: Create a contact on user's account. + - name: Update contact + desc: Update an existing contact on user's account. ---