These demos were shown in the session Getting Started with Marketing Cloud API Integrations at Dreamforce 2018.
This web app consists of 2 demos:
- A standalone web app that uses REST APIs to load data into Marketing Cloud
- The same web app running as a Marketing Cloud app within the Marketing Cloud UI
Login to your Marketing Cloud account and follow instructions at Create Data Extension to create a new Standard Data Extension.
Property | Value |
---|---|
Name | DF18Demo |
External Key | DF18Demo |
Is Sendable | No |
Next, add the 4 fields below to the DF18Demo
Data Extension:
Field Name | Data Type | Length | Primary Key | Nullable? | Default Value |
---|---|---|---|---|---|
id | Text | 15 | Yes (Checked) | No (Unchecked) | (Empty) |
name | Text | 50 | No (Unchecked) | No (Unchecked) | (Empty) |
EmailAddress | 254 | No (Unchecked) | No (Unchecked) | (Empty) | |
created_dts | Date | N/A | No (Unchecked) | No (Unchecked) | Current Date |
Follow instructions at Create a Marketing Cloud App to create a new Marketing Cloud App and use the values below:
Property | Value |
---|---|
Name | Enter a name you wish. The name you enter here shows up in the Marketing Cloud menu |
Description | Enter the description you wish. |
Login | https://localhost:5000/login |
Redirect | https://localhost:5000/appdemo |
Logout | https://localhost:5000/logout |
Add an API Integration
component to the Marketing Cloud App you just created.
- Click
Add Component
in the Marketing Cloud App and chooseAPI Integration
- Make sure Perform server-to-server requests is checked.
- Make sure Perform requests on behalf of the user is checked.
- When selecting the Marketing Cloud scope for your API calls, make sure the following permissions are checked:
- DATA -> Data Extensions -> Read
- DATA -> Data Extensions -> Write
See API Integration for more details.
-
Get the
ClientID
andClientSecret
from API Integration component and put in the following environment variables on your local computer:DF18DEMO_CLIENTID=YOUR_CLIENTID
DF18DEMO_CLIENTSECRET=YOUR_CLIENTSECRET
-
Get the
JWT SIGNING SECRET
from the Marketing Cloud App put in the following environment variable on your local computer:DF18DEMO_JWTSECRET=YOUR_JWT_SIGNING_SECRET
See Get an API Key for more details.
The steps below are for MacOS. Modify as needed for your operating system.
Download and install Node.js for your operating system: https://nodejs.org/en/download/
TIP: If you have
Git
installed then you can dogit clone https://github.com/sanagama/sfmc-df18demo.git
instead.
- Browse to https://github.com/sanagama/sfmc-df18demo
- Click
Clone or Download
then clickDownload ZIP
- Save the ZIP file to your
HOME
directory as~/sfmc-df18demo.zip
- Extract the zip file to your
HOME
directory~/sfmc-df18demo.zip
Type the following commands in the Terminal
window to run the web app:
cd ~/sfmc-df18demo
npm install
npm run
In this demo, the web app running locally on https://localhost:5000
calls the appropriate Marketing Cloud REST APIs to load sample data into the DF18Demo
Data Extension.
- Launch your browser and navigate to https://localhost:5000
- You've already completed Step #1 and Step #2.
- In Step #3, click
Execute Request
to get an OAuth token. - In Step #4, click
Execute Request
to load the sample data. - Go back to Marketing Cloud and navigate to the
DF18Demo
Data Extension. - Click
Records
to see 2 new records added by the web app.
In this demo, the web app running locally on https://localhost:5000
is displayed within Marketing Cloud web UI (in an IFRAME) and is launched via the Marketing Cloud app menu to load sample data into the DF18Demo
Data Extension.
- Login into Marketing Cloud
- Click on your Marketing Cloud App under
AppExchange
in the top navigation bar. - Note that the same web app is now running within the Marketing Cloud UI (in an IFRAME).
- You've already completed Step #1 and Step #2
- In Step #3, click
Execute Request
to get a Refresh token. - In Step #4, click
Execute Request
to get an OAuth token from the Refresh token. - In Step #5, click
Execute Request
to load the sample data. - Navigate to the
DF18Demo
Data Extension. - Click
Records
to see 2 new records added by the web app.
If you wish, you can also run this web app in Heroku, AWS, Azure, GCP, etc.
Here are detailed instructions on running Node.js web apps in Heroku: https://devcenter.heroku.com/articles/deploying-nodejs
TIP: Remember to set the following environment variables for the Herkou app:
RUNNING_IN_HEROKU=true
DF18DEMO_CLIENTID=YOUR_CLIENTID
DF18DEMO_CLIENTSECRET=YOUR_CLIENTSECRET
DF18DEMO_JWTSECRET=YOUR_JWT_SIGNING_SECRET
Check out these resources to help you get going:
- Marketing Cloud Developer Center: https://developer.salesforce.com/devcenter/marketing-cloud
- Create an Installed Package: https://sforce.co/InstalledPackage
- Marketing Cloud APIs: https://sforce.co/CloudAPI
- Marketing Cloud SDKs: https://sforce.co/SDK
- Content Block SDK: https://github.com/salesforce-marketingcloud/blocksdk
- Content Builder SDK: https://sforce.co/ContentBuilder
- MobilePush and Journey Builder SDKs: https://sforce.co/MobilePushSDK