Salesforce/Box V1 Webhooks

Box is a cloud-based file management service that offers collaboration for businesses and individuals.
(Looking for Box V2 Webhooks? Here is the V2 recipe ยป)

This recipe shows how to send real-time Box folder notifications into Salesforce using Streamscript webhooks.

RECIPE
Step 1 - Create a webhook receiver in Salesforce
Step 2 - Configure Box to send file events with V1 Webhooks
Step 3 - Test the integration with a file upload

Start 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.

Step 1 - Create a webhook receiver in Salesforce

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.

Save the Flow:

Note that the Flow API Name follows this three-part naming convention: Webhook_SiteName_PathSuffix

Step 2 - Configure Box to send file events with V1 Webhooks

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:

Add one final 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.

Step 3 - Test the integration with a file upload

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.

Appendix - Example Data

HTTP Headers for Box V1 Webhooks:

Callback Parameters for Box V1 Webhooks:

$Webhook request and response properties:

$Webhook.request # null
$Webhook.requestMethod # GET
$Webhook.requestIp # 74.112.186.52
$Webhook.requestUri # /Streamscript/BoxV1
$Webhook.requestPath # /services/apexrest/Streamscript/*
$Webhook.requestParams # {item_name: "Screenshot.png"...}
$Webhook.requestHeaders {X-Salesforce-SIP: "74.112.186.52"...}
$Webhook.responseStatus # 200
$Webhook.responseHeaders # {...}
$Webhook.response # blank