Salesforce Marketing Cloud is a powerful marketing automation platform. One of its key features is Journey Builder which enables businesses to build, automate, and optimise customer journeys.
Custom Journey Builder activities provide an opportunity to extend the functionality of Journey Builder by integrating your product's features or custom actions into the marketing automation process.
This repository is designed to kickstart the development of custom activities for Salesforce Marketing Cloud Journey Builder, useful for product development and software-as-a-service (SaaS).
Install project dependencies:
npm install
Run the Express server locally:
npm run serve
Debug the Vue app front-end:
npm run dev
Start the Express server:
npm start
Variable | Description | Required | Sample Value |
---|---|---|---|
NODE_ENV | Environment identifier used for conditional logic. | ❌ | staging |
NODE_VERSION | Required depending on hosting. | 🤔 | 18.15.0 |
PORT | Express server port. | ❌ | |
VITE_APP_URL | Express server URL. | ✅ | https://xyz.onrender.com/ |
VITE_APP_TITLE | Journey Builder activity name. | ✅ | Example Activity |
SFMC_MID | Business Unit MID(s) where the Installed Packaged is enabled. | ✅ | 500042165 |
SFMC_TENANT | Business Unit Tenant Subdomain(s). | ✅ | mcvnkblwyrzgidx3m-u2qpk-tsfh |
SFMC_CLIENT | Installed Package Client ID(s). | ✅ | zp9hxgqo84e2nyz26rpkp3m9 |
SFMC_SECRET | Installed Package Secret Key(s). | ✅ | xqYZXcBhJ39sLmPxRvVkdGqR |
SFMC_LOG_DE | Data Extension External Key(s). Shared Data Extensions can be used across MID's in the same enterprise. | ✅ | A2E9F753-6D1C-4B8F-A1CD-9C408BF2E7A0 |
JB_TIMEOUT | Milliseconds before each rest activity in the journey times out. Must be from 1000 to 100000 milliseconds. | ❌ | 20000 |
JB_RETRY_COUNT | Times to retry each rest activity in the journey after the rest activity times out. Must be from 0 to 5. | ❌ | 0 |
JB_RETRY_DELAY | Milliseconds before each rest activity in the journey is retried. Must be from 0 to 10000 milliseconds. | ❌ | 1000 |
JB_CONCURRENT_REQUESTS | How many rest activities to run in parallel. Must be from 1 to 10. | ❌ | 5 |
TREBLLE_PROJECT | Treblle Project ID. | ❌ | pQr3XsT4uV5wYz6 |
TREBLLE_KEY | Treblle API Key. | ❌ | gA3wMzxRQpLsYb1eXsNhFd2VoTkQUZkf |
In Marketing Cloud, go to Setup | Apps | Installed Packages:
- Click New.
- Give the package a name and description.
- Click Save.
Adding a server-to-server component allows our server to interact with Marketing Cloud i.e. validate a journey activity and upsert records to a data extension.
- Under Components, click Add Component.
- Select API Integration.
- Click Next.
- Select Server-to-Server.
- Click Next.
- Set the properties for the integration, including scopes.
- Automation > Journeys: Read
- Data > Data Extensions: Write
- Click Save.
Note the
SFMC_MID
andSFMC_TENANT
as these are consistently used across integrations, as well as the CLIENT KEY and CLIENT SECRET generated as part of this integration for use as theSFMC_CLIENT
andSFMC_SECRET
environment variables.
Adding a journey builder activity component enables the node to be used in the canvas. It's possible to create multiple custom activities within the same Installed Package.
- Under Components, click Add Component.
- Select Journey Builder Activity.
- Give the activity a name - for simplicity, use the same value as the
VITE_APP_TITLE
environment variable. - Select a category to determine which section the activity appears under in the canvas.
- Enter the Endpoint URL, which is the same as the
VITE_APP_URL
envrionment variable. - Click Save.
In Marketing Cloud, go to Contact Builder | Data Extensions:
- Click Create.
- Choose Create from New.
- Enter a name for the data extension.
- Click Next.
- Apply data retention if necessary.
- Click Next.
- Create attributes as per the schema below:
Name Type Length Required activityId Text 50 False activityInstanceId Text 50 False activityObjectID Text 50 False definitionInstanceId Text 50 False eid Text 50 False journeyId Text 50 False keyValue Text 500 False mid Text 50 False mode Text 50 False stackKey Text 50 False uid Text 50 False inArguments Text 4000 False timestamp Date False - Click Complete.
Note the EXTERNAL KEY provided, either generated or specified, to be used as the
SFMC_LOG_DE
environment variable.
Treblle makes it super easy (and free!) to understand what's going on with your API's and the apps that use them.
This is OPTIONAL but useful to see the requests made by Marketing Cloud to validate, publish and execute activity requests.
From the Treblle dashboard, click on create a new project:
- Give the project a name.
- Enter the Base URL, which is the same as the
VITE_APP_URL
envrionment variable. - Select Node as the platform.
- Select the relevant environment, based on the
NODE_ENV
environment variable. - Click Create Project.
Note the PROJECT ID and API KEY generated for the project, to be used as the
TREBLLE_PROJECT
andTREBLLE_KEY
environment variables.