How sidarth164/custom-activity-deskapi-node works
Project type and purpose
• This is a Node.js + Express “app extension” for Salesforce Marketing Cloud’s Journey Builder.
• It provides two custom activities (“Create Case” and “Update Case”) that appear in the JB canvas, let users configure them via a small SPA (HTML/CSS/JS under public/ixn/activities), and execute HTTP callbacks to external services (Desk.com API).
File structure
• Top level
• app.js – Express server, mounts routes and static asset middleware
• Procfile – Heroku web process
• lib/jwtDecoder.js – helper to decode and validate SFMC JWT tokens
• routes/
activityCreate.js – POST handler for Create Case execution
activityUpdate.js – POST handler for Update Case execution
activityUtils.js – Desk.com API helper (auth, request building)
index.js – authentication, CSRF-token and static route setup
• public/ixn/activities/{create-case,update-case}/
index.html, JS, CSS, config.json – the configuration UIs loaded in JB
• No internal database; all state is passed as inArguments/outArguments.
README for additional insights
• The README describes the Journey Builder lifecycle:
• Edit time: JB loads config.json and static assets from your app to let the user define inputs.
• Activation time: Marketing Cloud fires REST calls to your /execute endpoints with a JWT.
• Your server: decodes token, extracts arguments, calls Desk.com API, returns status and outArguments.
• Dependencies: Express, node-jwt, request or similar HTTP library.
Components & interactions
1. Journey Builder UI (Browser)
2. Marketing Cloud Interaction Service (Event trigger & REST invoker)
3. Your Node.js App on Heroku (Express server)
• Static-asset server (serves public/ixn/*)
• Route handlers
– Activity Create (/ixn/activities/create-case)
– Activity Update (/ixn/activities/update-case)
• JWT Decoder (lib/jwtDecoder.js)
• Desk.com API client (routes/activityUtils.js)
• SFMC Auth client (in app.js for token requests to auth.exacttargetapis.com)
4. Desk.com REST API
1. JB UI → GET config.json + index.html (to render the config dialog)
2. User fills form → POST saved config back to JB UI (no server call)
3. User activates Journey → Marketing Cloud issues POST /execute to your Node app with JWT + inArguments
4. Node app → decode JWT → validate session → extract inArguments
5. Node app → (optional) request new SFMC bearer token if needed
6. Node app → HTTP call to Desk.com REST API (create or update case)
7. Desk.com API → HTTP response → Node app formats outArguments → returns to MC service
8. Marketing Cloud logs result, passes outArguments to downstream activities
c. Architectural patterns
• RESTful API back end + static front end (SPA)
• Middleware for authentication (JWT)
• Modular route structure for each activity
• External service integration (Desk.com, SFMC Auth)
d. Key technologies
• Node.js, Express
• JWT (lib/jwtDecoder.js)
• HTML5/RequireJS/CSS for the config UI
• Desk.com REST API
Detail & coverage
• JWT Decoder and activityUtils as separate functional blocks.