Cloud Elements supports events via polling or webhooks depending on the API provider. For more information about our Events framework, see Events Overview.
Supported Events and Resources
Cloud Elements supports both webhooks and polling events for Salesforce.
You can set up events for the following resources:
- Account
- Lead
- Contact
- Opportunity
- Other objects that include
created
,updated
, anddeleted
data.
Polling
You can configure polling through the UI or in the JSON body of the /instances
API call.
Configure Polling Through the UI
For more information about each field described here, see Parameters.
- To enable hash verification in the headers of event callbacks, click Show Optional Fields, and then add a key to Callback Notification Signature Key.
- Switch on Events Enabled.
- Select polling from Event Type.
- Add an Event Notification Callback URL.
- Use the Event poller refresh interval (mins) slider or enter a number in minutes to specify how often Cloud Elements should poll for changes.
Configure Polling Through API
To add polling when authenticating through the /instances
API call, add the following to the configuration
object in the JSON body. For more information about each parameter described here, see Parameters.
{
"event.notification.enabled": true,
"event.vendor.type": "polling",
"event.notification.callback.url": "<INSERT_YOUR_APPS_CALLBACK_URL>",
"event.notification.signature.key": "<INSERT_KEY>",
"event.poller.configuration": "<CONFIGURATION_OF_OBJECTS_TO_POLL>",
"event.poller.refresh_interval": "<TIME_IN_MINUTES>"
}
event.notification.signature.key
is optional.Example JSON with Polling
instance JSON with polling events enabled:
{
"element": {
"key": "sfdc"
},
"providerData": {
"code": "<Code_On_The_Return_URL>"
},
"configuration": {
"oauth.callback.url": "https://www.mycoolapp.com/auth",
"oauth.api.key": "<Insert_Client_ID>",
"oauth.api.secret": "<Insert_Client_Secret>",
"event.notification.enabled": true,
"event.vendor.type": "polling",
"event.notification.callback.url": "https://staging.cloud-elements.com/elements/api-v2/instances/events",
"event.notification.signature.key": "12345",
"event.poller.configuration": "{\n \"accounts\": {\n \"url\":\"/hubs/crm/accounts?where=LastModifiedDate>'${gmtDate:yyyy-MM-dd'T'HH:mm:ss.SSS'Z'}'\",\n \"idField\": \"Id\",\n \"datesConfiguration\": {\n \"updatedDateField\": \"LastModifiedDate\",\n \"updatedDateFormat\": \"yyyy-MM-dd'T'HH:mm:ss.SSSSZ\", \n \"createdDateField\": \"CreatedDate\",\n \"createdDateFormat\": \"yyyy-MM-dd-'T'HH:mm:ss.SSSSZ\",\n \"updatedDateTimezone\": \"GMT\",\n \"createdDateTimezone\": \"GMT\"\n }\n }\n}",
"event.poller.refresh_interval": "5"
},
"tags": [
"forDocs"
],
"name": "mySFDCInstance"
}
Webhooks
When implementing webhooks for Salesforce, Cloud Elements creates APEX classes and triggers in order to send webhooks. This can only be done in a Salesforce sandbox account. If you want to support webhooks in a production Salesforce account, you'll have to make some modifications and migrate those classes to production according to the Salesforce specification. View more information regarding the Salesforce specification.
You can configure webhooks through the UI or through API in the JSON body of the /instances
API call. First, you must set up webhooks in Salesforce.
Set Up Webhooks
Follow these steps to set up your Salesforce application with the endpoint.
- Via a web browser, log in to your Salesforce account.
- In the Quick Find box, type
Remote Site Settings
. - Click New Remote Site.
- Create a remote site for the URL
https://staging.cloud-elements.com
.
Configure Webhooks Through the UI
For more information about each field described here, see Parameters.
- Switch on Events Enabled.
- Select webhooks from Event Type.
- Add an Event Notification Callback URL.
- Optionally include a Callback Notification Signature Key.
- Enter each object that you want to poll for changes separated by commas.
Configure Webhooks Through API
To add webhooks when authenticating through the /instances
API call, add the following to the configuration
object in the JSON body. For more information about each parameter described here, see Parameters.
{
"event.notification.enabled": true,
"event.vendor.type": "webhooks",
"event.notification.callback.url": "<INSERT_YOUR_APPS_CALLBACK_URL>",
"event.notification.signature.key": "<INSERT_KEY>",
"event.objects": "<COMMA_SEPARATED_LIST>"
}
event.notification.signature.key
is optional.Example JSON with Webhooks
Instance JSON with webhooks events enabled:
{
"element": {
"key": "sfdc"
},
"providerData": {
"code": "<Code_On_The_Return_URL>"
},
"configuration": {
"oauth.callback.url": "https://www.mycoolapp.com/auth",
"oauth.api.key": "<Insert_Client_ID>",
"oauth.api.secret": "<Insert_Client_Secret>",
"event.notification.enabled": true,
"event.vendor.type": "webhooks",
"event.notification.callback.url": "https://mycoolapp.com",
"event.notification.signature.key": "12345",
"event.objects": "Contact,Account"
},
"tags": [
"forDocs"
],
"name": "mySFDCInstance"
}
Parameters
API parameters are in code formatting
.
Parameter | Description | Data Type |
---|---|---|
'key' | The element key. sfdc | string |
Namename | The name for the element instance created during authentication. | Body |
oauth.api.key | The Consumer Key from Salesforce. | string |
oauth.api.secret | The Consumer Secret from Salesforce. | string |
Filter null values from the responsefilter.response.nulls | Optional. Determines if null values in the response JSON should be filtered from the response. Yes or true indicates that Cloud Elements will filter null values.Default: true . | boolean |
Events Enabledevent.notification.enabled | Optional. Identifies that events are enabled for the element instance. Default: false | boolean |
Event Typeevent.vendor.type | Optional. Identifies the type of events enabled for the instance, either webhook or polling . | string |
Event Notification Callback URLevent.notification.callback.url | For webhooks and polling. The URL where your app can receive events. | string |
Callback Notification Signature Keyevent.notification.signature.key | For webhooks and polling. Optional A user-defined key for added security to show that events have not been tampered with. This can be any custom value that you want passed to the callback handler listening at the provided Event Notification Callback URL. | string |
Objects to Monitor for Changesevent.objects | For webhooks and polling. Optional Comma separated list of objects to monitor for changes. | string |
Event poller refresh interval (mins)event.poller.refresh_interval | For polling only. A number in minutes to identify how often the poller should check for changes. | number |
tags | Optional. User-defined tags to further identify the instance. | string |