Salesforce CRM — SalesforceConnector

The crm_sync step type upserts Velaris case data into Salesforce as a Contact and a linked Case record. When the step executes, SalesforceConnector automatically refreshes the OAuth2 access token using the stored refresh token — no manual token management required. The upsert is idempotent: running the step multiple times on the same case will not create duplicate Salesforce records.

Field mapping is defined in a JSON field_map configuration attached to the connector record. This allows different connector instances (e.g., one for loans, one for complaints) to map different Velaris case data fields to different Salesforce fields.

Xero Accounting — XeroConnector

The invoice_generate step type creates a draft invoice in Xero, populated with line items derived from case data fields. XeroConnector handles OAuth2 token refresh automatically using the stored refresh token and tenant ID. Invoices are created in Draft status by default; the connector supports an Auto-Post option that transitions the invoice to Submitted status immediately.

Line item fields are configured via a JSON line_item_fields array in the connector config, allowing arbitrary line item structures to be derived from case data.

Step Types

Step Type Connector Work Center Panel Panel Contents Auto-Advance Trigger
crm_sync SalesforceConnector CRM Sync Panel ☁️ Sync status badge, Salesforce record links (Contact ID, Case ID), last synced timestamp, Sync Now button HTTP 200 or 201 response from Salesforce upsert API
invoice_generate XeroConnector Invoice Panel 🧾 Invoice status badge, Xero invoice number, line item summary, total amount, Generate Invoice button HTTP 200 response from Xero Invoices API

Salesforce Configuration

  1. Create a Salesforce Connected App. In Salesforce Setup, search for App Manager > New Connected App. Enable OAuth Settings, add the callback URL https://your-domain.com/api/crm/oauth/callback, and select scopes: api and refresh_token. Save and copy the Consumer Key (Client ID) and Consumer Secret (Client Secret).

  2. Complete the initial OAuth2 flow to obtain a refresh token. This is a one-time step. Use the Salesforce OAuth2 authorization endpoint to authorize the Connected App and capture the refresh token from the token response. Velaris Studio provides a helper at Studio > HxConnect > CRM > Authorize Salesforce — clicking it opens the OAuth consent screen and stores the refresh token automatically.

  3. Get your Salesforce instance URL. This is the base URL of your Salesforce org (e.g., https://yourorg.my.salesforce.com). Found in Setup > Company Information.

  4. Set environment variables. Add the following and restart the case-service:

    SALESFORCE_CLIENT_ID=3MVG9...your_consumer_key
    SALESFORCE_CLIENT_SECRET=your_consumer_secret
    SALESFORCE_REFRESH_TOKEN=your_refresh_token
    SALESFORCE_INSTANCE_URL=https://yourorg.my.salesforce.com
  5. Add the connector in Studio with field_map configuration. Navigate to Studio > HxConnect > CRM and click Add Connector. Configure the credentials using {{env.*}} placeholders and provide the field_map JSON (see example below). Save.

  6. Add a crm_sync step to your case type. Add the step at the appropriate stage, link the SalesforceConnector, and publish.

Field Map Configuration

The field_map JSON defines how Velaris case data fields map to Salesforce object fields. The top-level keys are Salesforce object types (Contact, Case). Each entry maps a Salesforce field name to a Velaris field path using dot notation.

{
  "Contact": {
    "FirstName": "case.data.customer_first_name",
    "LastName": "case.data.customer_last_name",
    "Email": "case.data.customer_email",
    "Phone": "case.data.customer_phone",
    "AccountId": "case.data.salesforce_account_id"
  },
  "Case": {
    "Subject": "case.title",
    "Status": "case.status",
    "Origin": "\"Velaris\"",
    "Description": "case.data.description",
    "External_Case_Ref__c": "case.ref",
    "Priority": "case.data.priority"
  }
}

Literal string values (like "Velaris" above) can be embedded directly using double-quoted strings. Velaris case fields use the case.* path prefix. Custom Salesforce fields (with __c suffix) are fully supported.

Xero Configuration

  1. Create a Xero App. Log in to the Xero Developer Portal. Click New App, set Integration type to Web app, and enter the redirect URI: https://your-domain.com/api/invoices/oauth/callback. Copy the Client ID and Client Secret.

  2. Complete the initial OAuth2 flow. Use Velaris Studio's helper at Studio > HxConnect > Accounting > Authorize Xero. This opens the Xero consent screen, requests the accounting.transactions scope, and stores the refresh token and tenant ID automatically.

  3. Note your Xero Tenant ID. After authorization, the tenant ID is displayed in Studio. It is a UUID identifying your Xero organisation (e.g., 79af5f79-bdf8-4e37-acde-...).

  4. Set environment variables. Add the following and restart the case-service:

    XERO_CLIENT_ID=your_client_id
    XERO_CLIENT_SECRET=your_client_secret
    XERO_REFRESH_TOKEN=your_refresh_token
    XERO_TENANT_ID=79af5f79-bdf8-4e37-acde-...
  5. Add the connector in Studio. Navigate to Studio > HxConnect > Accounting and click Add Connector. Configure the credentials using {{env.*}} placeholders, set the line_item_fields JSON array, and optionally enable Auto-Post to submit invoices immediately. Save.

  6. Add an invoice_generate step to your case type. Link the XeroConnector and publish.

API Reference

Method Endpoint Description Auth
POST /api/crm/cases/{id}/sync Executes the CRM sync for the case using the linked SalesforceConnector. Returns Salesforce Contact ID and Case ID. JWT
GET /api/crm/sync-records Lists all CRM sync records from crm_sync_records. Supports ?case_id= filter. Returns sync status, SF record IDs, timestamps. JWT (Admin/Manager)
POST /api/invoices/cases/{id}/generate Generates a Xero invoice for the case using the linked XeroConnector. Returns Xero InvoiceID and invoice number. JWT
GET /api/invoices/records Lists all invoice records from invoice_records. Supports ?case_id= and ?status= filters. JWT (Admin/Manager)

OAuth Token Management

Token rotation is automatic. Both SalesforceConnector and XeroConnector maintain a short-lived access token in memory and refresh it automatically when it expires, using the stored refresh token. You never need to store or rotate access tokens. Only the refresh token lives in environment variables — and it is long-lived (until explicitly revoked).
SD-7 Security Policy: rotate refresh tokens every 90 days. Refresh tokens are long-lived OAuth credentials. Per Velaris security policy SD-7, refresh tokens for CRM and accounting integrations must be rotated at least every 90 days. To rotate: use the Studio Re-Authorize button (Studio > HxConnect > CRM or Accounting > Re-Authorize). This generates a new refresh token and updates the SALESFORCE_REFRESH_TOKEN / XERO_REFRESH_TOKEN environment variable via your secrets manager. Log the rotation in your change management system.