NOTE: This app and the associated code is NOT production quality, its pure purpose is to demonstrate the full flow of custom interactions in Journey Builder
- Node.js and npm installed (if you’d like to test locally)
- A Twilio account sign up for a free Twilio account here
- A Marketing Cloud Account with Journey Builder
- A publicly accessible web server (this template was built using a free Heroku account with SSL support)
Also, we’re going to make the assumption that you already have Salesforce Marketing Cloud’s Contact Builder properly setup and configured
This guide covers Heroku, skip this step if you are familiar on how to deploy a Node.js app
- Fork and Clone this repository
- Login into Heroku
- Click on New > Create new app
- Give a name to the app and click on "Create App"
- Choose your preferred Deployment method (Github or Heroku Cli are nice to work with)
- Click on "Deploy branch"
- Once your branch is deployed, click on the "View" button and verify you see the welcome message
- Click on “Open App” and copy the URL for your application. Save for use later.
- Login to the Twilio console and navigate to the home screen and click on settings
- Copy your Account SID and your Auth Token and save it for later
- Then navigate to Programmable SMS and click on SMS
- If you don’t already have a Messaging Service setup, please review this guide
- Click on the Messaging Service you would like to use and copy the Service SID and save it for later
While you can certainly tweak this example to send directly from a short code, you’ll have more flexibility when it comes to how you want to configure additional features around a messaging service; Copilot, advanced opt-out management, sticky sender, area code and country code geomatch.
- Login to Marketing Cloud and to the upper right hand corner and click on setup
- Once in Setup, click into Apps > Installed Packages
- Click on New and enter a name and a description for your package
- Copy the JWT Secret value from the Summary page and save it for later
- Click on Add Component, select Journey Builder Activity and Click next
- Give you activity a name: Twilio SMS. Also select the category where this activity will show up within Journey Builder. Choose Messages. Last, enter [url of your Heroku app] as your Endpoint URL
- Click Save
- Copy the Unique Key value from the Journey Builder Activity panel and save it for later
- Open /public/config.json and:
- Replace applicationExtensionKey for the value you got from step 8 in configuring your package in Marketing Cloud
- Replace [your-app-URL] with the domain for your specific heroku app:
- https://YOUR-APP-URL.herokuapp.com/journeybuilder/execute
- https://YOUR-APP-URL.herokuapp.com/publish
- https://YOUR-APP-URL.herokuapp.com/validate
- https://YOUR-APP-URL.herokuapp.com/stop
- https://YOUR-APP-URL.herokuapp.com/save
- Open public/js/customActivity.js and
- Replace {{Contact.Attribute.TwilioV1.TwilioNumber}} with the correct data extension and column name that will be used to reference the TO phone number.
- {{Contact.Attribute.YOUR-DATA-EXTENSION-NAME.YOUR-PHONE-NUMBER-COLUMN}}
- This is something that is typically customized when setting up Marketing Cloud but is needed in order for Twilio to understand WHO the message needs to be sent to.
The index.html defines how the Marketer will see/interact with the Twilio Messaging Service. By default, the code suggested asks for the following as a starting point:
- Account SID
- Auth Token
- Messaging Service SID
- Message body
If you want, the Account SID, auth token even the Messaging Service SID can be hidden or saved as config variables so that your marketer doesn’t need to include them every time they configure a message through Journey Builder
- Log back into Heroku and navigate to your app
- Click on "Settings"
- Click on "Reveal config vars"
- Add a new var called jwtSecret and paste the App Signature you got from step 3 when configuring your package in Marketing Cloud
- If you want to lock in what Messaging Service SID your marketing team uses, you can also save the Twilio account SID, auth token, as well as the Messaging Service SID as config var.
- Login into Marketing Cloud and navigate to Journey Builder and create a new Journey.
- You should be able to the Twilio SMS custom activity and drag it into the canvas
- Click into the activity and fill out the Account SID, Auth Token, Messaging Service SID and the body for your SMS/MMS message.
- Better yet, test out 5 different variations of your SMS message to optimize campaign performance(optional):
If you'd like to learn more about Twilio and how to integrate its services into Journey Builder Custom Activities, email me at jmaitz@twilio.com
Also, follow Twilio on LinkedIn
Documentation for /public/config.json https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/custom-activity-config.html