feat(automations): support custom contact fields in Update Contact Field action#240
Merged
Merged
Conversation
…eld action
The "Update Contact Field" automation action could only write the built-in
name/email/company columns. This wires up the existing custom_fields /
contact_custom_values tables so automations can read and update arbitrary
custom fields, and adds the missing UI to define them.
- Add a "Custom fields" manager dialog on the Contacts page (admin+ gated)
to create / rename / delete field definitions. Inserts carry account_id.
- Load account custom fields into the automation builder's ResourcesContext
and offer them in the Field dropdown, encoded as `custom:<id>`. A saved
field that's since been deleted is preserved as an "(unknown field)"
option so editing doesn't silently drop it.
- Engine: interpolate the value ({{ vars.* }} / {{ message.text }}) for all
fields, and for `custom:<id>` verify the field belongs to the automation's
account (defense in depth) before upserting into contact_custom_values.
- Tests: cover the custom-value upsert, variable interpolation, and
cross-account rejection.
Closes #235
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #235
Problem
The Update Contact Field automation action could only write the three built-in contact columns (Name, Email, Company), and its value wasn't interpolated — so workflows couldn't store richer customer data or use workflow variables.
What this does
The
custom_fields/contact_custom_valuestables and account-scoped RLS already existed (migrations 001 + 017); the contact detail view already reads/writes per-contact values. This PR wires the rest together — no migration needed.useCan('edit-settings')) to create / rename / delete field definitions. Inserts carryaccount_id+user_id.ResourcesContext(same pattern as tags/templates) and offers them in the Field dropdown, encoded ascustom:<id>. A saved field that's since been deleted is preserved as an "(unknown field)" option so editing doesn't silently drop it.{{ vars.* }}/{{ message.text }}) for all fields. Forcustom:<id>it verifies the field belongs to the automation's account (defense in depth — the service-role client bypasses RLS) before upserting intocontact_custom_valueson itsUNIQUE(contact_id, custom_field_id)key.Tests / checks
npm run typecheck— cleannpm run lint— no new errorsnpm run test— 394 pass, incl. 3 new engine tests (custom-value upsert, variable interpolation, cross-account rejection)Notes
Text-only fields for now (
field_type: 'text'); field-definition management stays admin+ to match existingcustom_fieldsRLS. As a side benefit, this unblocks the broadcast personalization screens that already readcustom_fieldsbut had no creation path.🤖 Generated with Claude Code