Box is a cloud-based file management service that offers collaboration for businesses and individuals. This recipe shows how to send real-time Box folder notifications into Salesforce using Streamscript and Box V1 Webhooks. (Looking for Box V2 Webhooks? V2 recipe »)
This integration uses three steps:
Follow this recipe by creating a 'Proposals' folder in the Box app, then open the Dev Console to access apps and webhooks. Webhooks are included in all Box Enterprise plans.
Log into Salesforce and prepare a Flow to handle the webhooks.
# Streamscript to read the Box callback parameters $file = $Webhook.requestParams.item_name $type = $Webhook.requestParams.event_type $name = $Webhook.requestParams.from_user_name # Secure the endpoint with a token of your choosing if ($Webhook.requestParams.token != 'ABC123') {throw 'Bad Token'} # Prepare Task $Task = New-Task $Task.Subject = `Box activity: $type` $Task.Description = `User $name interacted with: $file` return $Task
Add a flow element to save the Task.
Streamscript > record
output
Save the Flow:
Notice how the API Name of the Webhook Flow consists of three parts. This is a
convention and it always has the format: Webhook
_ Site Name
_ URL Suffix
Log into Box > Dev Console > My Apps:
Carefully choose the app settings:
Now configure the Box webhook.
General Information
Endpoint Configuration
Callback Parameters are keys and values contained in the webhook payload. Include all of them so that Salesforce receives the full event detail. For each row, click Add callback parameter:
#
symbols, and avoid accidental spaces)Add one last parameter - a hard coded value containing a secure token of your own choosing. This is used by the webhook endpoint to verify each request came from you.
Finally, install your app in your Box account using the preview process.
This option keeps the app private and does not require approval from Box.
It navigates you directly to the app awaiting install in your Box environment. Click Add.
Log into your Box workspace. From the blue navigation menu, click Files then the Proposals folder. Drag and drop a test file into the folder to upload it.
Log into Salesforce. Go to the Tasks tab and open the list view. Here is the upload notification!
This simple Box/Salesforce integration needs no OAuth implementation nor token refresh logic. All file and folder events are sent from Box into Salesforce via the webhook.
HTTP Headers for Box V1 Webhooks
Box-Skills-Client/0.1
2023-12-05T10:56:53-08:00
prod-c1-a-web-proxy-3x0m="Surrogate/1.0 ESI/1.0"
Callback Parameters for Box V1 Webhooks
uploaded
1380432606482
file
png
Proposal
Screenshot.png
0
30353080461
Box Admin
1115752461
["30353080461"]
["Neil Reid"]
["1115752461"]
1380452238155
(present in 'copied' events)237583118146
(present in 'copied' events)$Webhook request and response properties
$Webhook.request # null $Webhook.requestMethod # GET $Webhook.requestIp # 74.112.186.52 $Webhook.requestUri # /Streams/BoxV1 $Webhook.requestPath # /services/apexrest/Streams/* $Webhook.requestParams # {item_name: "Screenshot.png"...} $Webhook.requestHeaders {X-Salesforce-SIP: "74.112.186.52"...} $Webhook.responseStatus # 200 $Webhook.responseHeaders # {...} $Webhook.response # blank
Getting started with Streamscript
Install from the Salesforce AppExchange
Package install link: /packaging/installPackage.apexp?p0=04tGA000005NDq5
How to call Apex from scripts |
Script Tips |
Integrate Box with V2 Webhooks |