Journey Builder custom activities
What a custom activity is, which endpoints Journey Builder calls and when, and what a team has to stand up before putting one in production.
The journey has to ask the bank’s core system something before the next step, and the team cannot find an activity Salesforce ships that makes that call. What has to be built to add it, and what happens when that system does not answer?
What a custom activity is
Salesforce Help defines the custom activity by who configures it: the marketer or the marketer’s organization, fully, and its activity-type reference gives it a category of its own, Custom. For development it points to the Journey Builder API (application programming interface), whose guides carry the warning worth reading first: “Salesforce Customer Support doesn’t provide support for your custom Journey Builder events and activities”.
This page does not cover the journey itself — canvas, versions, the activities Salesforce ships and activation — which belongs to Journey Builder; nor who enters and how they leave, which belongs to journey entry and exit; nor Automation Studio and its activities.
What it is made of
Three components, all three on a web server of the team’s own.
| Piece | What it is, per the guide |
|---|---|
| Custom activity UI | The activity’s code and assets, on a public web server. The root of the endpoint must hold an index.html |
config.json |
The application extension that defines the activity |
customActivity.js |
Holds the Postmonger events — Postmonger being the mediator the guide requires in every custom component — and sits between the configuration app in the iframe, the frame where Journey Builder embeds that interface, and Journey Builder |
It also asks for postmonger.js and, of hosting, “a web server that communicates via SSL (port 443)” — SSL for Secure Sockets Layer — with Heroku recommended.
config.json declares the type — the configuration guide names two standard ones, Rest and RestDecision (REST for representational state transfer), describing neither — and the canvas panel category, which overrides the one chosen in the package.
How it reaches an account
The activity is registered as a component of an installed package, the container Marketing Cloud Engagement administers in Setup, under Apps > Installed Packages. The Installed Package | Administer permission is required, and one package takes several Journey Builder Activity components.
The component asks for a name, a description, a category and the Endpoint URL (uniform resource locator): the base URL against which “Journey Builder loads all assets relative to this endpoint”.
Two sentences matter here. The first: “Configuration changes to endpoints in your installed package don’t apply to existing custom activities already configured in your account”; to apply them, the activity has to be reconfigured in a new journey version. The second is about scope, and the modal matters: the package can be installed in all accounts in the enterprise, and it is installed by whoever has the permission and access to all of them; the guide documents that registration and that installation as separate procedures. Deleting it does remove it — “it’s removed from all accounts in the enterprise”. The guide speaks of packages installed “in business units where you have permission to install and manage packages”; what a business unit is, the Business Units page explains.
Its diagnostic list adds two checks: that the key property of the config.json matches the component’s — “if the key is missing or incorrect, Journey Builder overrides the config.json file” — and that the Endpoint URL points at the directory of that config.json.
What the platform calls, and when
The sources document two families: the configuration calls answer what a person does with the journey, and the execution call answers what a contact does.
The configurationArguments object declares one URL per action, and says the same of each: it is “the HTTPS endpoint that receives an HTTP POST request when a user performs the action”: HTTPS is HTTP, hypertext transfer protocol, over an encrypted layer.
| User action on the journey | Key in config.json |
|---|---|
| Save it | save |
| Validate it | validate |
| Publish it | publish |
| Unpublish it | unpublish |
| Stop it | stop |
No source says in which order those five URLs are called, or whether all of them are called on every action. The publish-validation guide does list three cases for a journey with a custom activity: that the save, validate or publish methods do not return a 200 HTTP response. It does not write the consequence in words — its own list markup is broken there — so reading them as failures of the validation pass is this page’s own reading.
The other family is a single call. The execute object holds “information that is sent to and returned by the activity each time a contact enters it”: the inArguments are the data Journey Builder passes to the endpoint when a contact enters, and the outArguments the fields the application returns, which cannot be null. The sample body also carries seven context keys, among them journeyId and keyValue, which no source defines.
What travels inside the inArguments is resolved by data binding: Mustache-syntax expressions that the Journey Builder engine evaluates at runtime, not when saving, validating or publishing. They are case-sensitive and must match the exact data extension name and field name. Of Contact.Key it says the engine “requires this contact key value”; what that key is, the Contact Builder page explains.
And one hard consequence: on publish, and every hour after that, the system compiles them, and “when the system can’t compile an expression, publish fails and the system disables the journey”; the guide says renaming or deleting a field can cause it.
When the endpoint is slow or fails
execute property |
Minimum | Maximum | Default |
|---|---|---|---|
timeout, in milliseconds |
1000 | 100000 | 20000 |
retryCount, retries |
0 | 5 | 0 |
retryDelay, in milliseconds |
0 | 10000 | 1000 |
concurrentRequests, parallel calls |
1 | 10 | 6 |
Of the retries the guide is precise about when they happen: “if it times out”. Of parallelism it asks to test that the target application can take multiple loads, and advises increasing the retry and timeout values if gateway errors or timeouts are observed.
Against that table, the troubleshooting page of the same guide says something else: “The maximum timeout for the custom activity is 60 seconds, and there is no retry logic”. Sixty seconds is not a hundred thousand milliseconds, nor is “no retry logic” a retryCount of five. Neither prints a publication date and neither is more specific, so the page publishes both figures, does not choose, and asks for a measurement in the account.
They are also silent on three things this page does not fill in: what Journey Builder does if the call returns a code other than 200, whether the ordering of contacts is guaranteed, and what happens to a contact that was inside when the endpoint stopped responding.
On the journey’s contacts page Help documents a REST type, “an activity that was built via REST API”, with the name whoever created it gave it; that a custom activity shows there is this page’s inference.
Endpoint security
Marketing Cloud Engagement uses the JWT (JSON Web Token; JSON for JavaScript Object Notation) “to validate the identity of API calls to your custom activities”, and the guide recommends it “for activities that retrieve sensitive data or perform sensitive actions”. With a warning: JWTs are encoded, not encrypted, and the encryption comes from the transport layer with SSL. The useJwt of each configuration action turns it on: “If true, requests to the endpoint are encoded as a JWT”.
The alternative is an OAuth 2.0 (open authorization, in the industry’s current phrase; the sources do not expand it) bearer token. It is configured in Setup, Data Management, Key Management, with a Security Context key pointing at the organization’s own token exchange endpoint; once that is done, the platform “automatically uses them in the request headers”. In the activity it is carried by securityOptions, “information about OAuth 2.0 bearer tokens”.
When to build one, and when not to
The row split is this page’s reasoning; no source publishes such a table.
| Situation | What the sources indicate |
|---|---|
| The journey has to read from or write to a system of your own at the moment the contact passes through | This is the case the guide describes: an activity that kicks off a REST call to a third-party application |
| The branch split depends on a decision that system makes | Help says a custom activity can segment into two or more paths; that the type is RestDecision is this page’s own inference from the name, because the configuration guide describes neither of the two |
| What is needed is to update a data extension in the account itself | There are activities Salesforce ships for that, described in Help’s activity-type reference |
| The team cannot sustain a server with SSL, its availability and its monitoring | The guide requires a public server with SSL on port 443, and Salesforce gives the activity no support |
| The endpoint does not answer comfortably inside the timeout | The two published figures contradict each other; without measuring it in the account, sizing is guesswork |
Example: querying a private bank’s core system
A private bank wants its welcome journey to ask the core system whether the client already holds a product. The case is invented; the ordering of the six steps is this page’s proposal, not any source’s.
- Stand up the endpoint: a public server with SSL on port 443, with
index.html,config.jsonandcustomActivity.js, and an execute URL that answers 200. - Fix what goes in and what comes out. In
inArguments, the client identifier resolved by data binding from the contact key, which is the same value as the subscriber key, and not the email address — that is the choice of the pages already published, not a prohibition in Help. InoutArguments, the answer field, which cannot arrive null. - Declare the five configuration URLs, counting on
save,validateandpublishreturning 200, the requirement this page reads out of the validation guide. - Choose the security mechanism before publishing. The query returns client data, the case for which the guide recommends a JWT; with a token exchange in place, the alternative is OAuth 2.0.
- Register the Journey Builder Activity component in an installed package, with the base URL as the Endpoint URL;
metaData.isConfiguredis set to true by thecustomActivity.jsin the Postmonger payload, without which the journey cannot be activated. - Measure the real response time and set
timeout,retryCount,retryDelayandconcurrentRequestswith that figure in hand.
The example promises nothing more: it does not split the journey into branches — that calls for the other standard type, which the guide does not describe — nor does it say what the platform does with a 500, because no source says it.
Before production
- Endpoint reachable from outside, with SSL enabled and an
index.htmlin the root (see “What it is made of”). config.jsoncomplete and itskeyproperty equal to the component’s (see “How it reaches an account”).- The component’s Endpoint URL pointing at the directory holding the
config.json(see “How it reaches an account”). save,validateandpublishreturning 200 before activating, on the reading declared in “What the platform calls, and when”.- Data binding expressions checked against the exact table and field names (see “What the platform calls, and when”).
- The four
executevalues set from a measurement of your own (see “When the endpoint is slow or fails”). - Security mechanism declared and
metaData.isConfiguredset to true (see “Endpoint security” and step 5).
Official sources
- Journey Builder Activities — Salesforce Help (opens in a new tab)
- Activity Types — Salesforce Help (opens in a new tab)
- Activity Type Reference — Salesforce Help (opens in a new tab)
- Reuse a Journey Builder Activity — Salesforce Help (opens in a new tab)
- Journey Builder API — Marketing Cloud Engagement APIs and Programmatic Languages (opens in a new tab)
- Build Custom Activities and Events — Marketing Cloud Engagement APIs and Programmatic Languages (opens in a new tab)
- Custom Activity UI — Marketing Cloud Engagement APIs and Programmatic Languages (opens in a new tab)
- Custom Activity Configuration — Marketing Cloud Engagement APIs and Programmatic Languages (opens in a new tab)
- Register an Endpoint for Custom Journey Builder Component — Marketing Cloud Engagement APIs and Programmatic Languages (opens in a new tab)
- Example REST Activity — Marketing Cloud Engagement APIs and Programmatic Languages (opens in a new tab)
- Postmonger Events Reference — Marketing Cloud Engagement APIs and Programmatic Languages (opens in a new tab)
- Troubleshoot Custom Activities — Marketing Cloud Engagement APIs and Programmatic Languages (opens in a new tab)
- How Data Binding Works — Marketing Cloud Engagement APIs and Programmatic Languages (opens in a new tab)
- Validation Checks to Publish a Journey — Marketing Cloud Engagement APIs and Programmatic Languages (opens in a new tab)
- Packages — Marketing Cloud Engagement APIs and Programmatic Languages (opens in a new tab)
- Create and Install Packages — Marketing Cloud Engagement APIs and Programmatic Languages (opens in a new tab)
- Encode Custom Activities Using a JWT — Marketing Cloud Engagement APIs and Programmatic Languages (opens in a new tab)
- Secure a Custom Activity Using an OAuth 2.0 Bearer Token — Marketing Cloud Engagement APIs and Programmatic Languages (opens in a new tab)