Integrating Zephr within Salesforce
Learn how to integrate Zephr within Salesforce, including setting up webhooks and triggers to manage user updates and product grants.
Certain aspects of the Zephr and Salesforce integration will require you to set up webhooks and triggers within Salesforce – for example, if you wish to update a User in Zephr when their corresponding Contact is updated in Salesforce.
Below is the URL and format that needs to be called when setting these up, along with a list of event names that can be called in order to trigger different events within Zephr. For information on how to add webhooks within Salesforce, consult the Salesforce Help Section.
URL and Format to Call:
/plugins/salesforce/webhooks?event={eventName}&code={secretCode}
createUser
This is used to create a user within Zephr when a Contact is registered within Salesforce. This will:
- Check Zephr for a Salesforce Contact’s Email
- If found this will:
- Update the Zephr User
- Save the Salesforce ID to the Zephr User’s Extended Profile
- If found this will:
- If not found this will:
- Create a Zephr User
- Save the Salesforce ID to the Zephr User's Extended Profile
Example:
{"Id":"<id>","Email":"<email>","<mapped_attribute_1>": "<mapped_attribute_1_value>",
"<mapped_attribute_2>": "<mapped_attribute_2_value>",
"<mapped_attribute_3>": "<mapped_attribute_3_value>"
...
}
So, for example, where
FirstName
and
LastName
are values in the mapping config (please see the example in ‘Salesforce Contacts to Zephr Users’ above), the body would look like so:
{
"Id": "<id>",
"Email": "<email>",
"FirstName": "<first_name>",
"LastName": "<last_name>"
}
updateUser
This is used to update a User within Zephr when the corresponding Contact is updated within Salesforce. This will:
- Map the Salesforce Product ID to a Zephr Product ID
- Check Zephr for the Salesforce Contact’s email
- If found this will:
- Purchase the Zephr Product
- Update the Zephr User’s Extended Profile with Product Grants
- If not found this will:
- Create a Zephr User
- Purchase the Zephr Product
- Update the Zephr User’s Extended Profile with Product Grants
- If found this will:
Example:
{"Email": "frank@zephr.com","contactId": "384975982743985234"}
Or
{"Id": "384975982743985234","Email": "frank@zephr.com","FirstName": "Frank","LastName": "Blaize","MailingStreet": "1 Frank Street","MailingCity": "London","MailingState": "","MailingPostalCode": "EC4A 2DQ","MailingCountry": "United Kingdom","Phone": "+441234567891","JobTitle": "Blaize","contactId": "384975982743985234"}
buyProduct
This is used to add a product grant to a Zephr User when a product or subscription is added to the corresponding Salesforce Contact – for example if an in-house sales teams makes a sale over the phone, and adds the customer’s subscription manually. This will:
- Map the Salesforce Product ID to a Zephr Product ID
- Check Zephr for the Salesforce Contact’s Email
- If found this will:
- Grant the user access to the Zephr Product
- If not found this will:
- Create a Zephr User
- Grant the user access to the Zephr Product
- If found this will:
Products to be purchased for a user can be submitted in 3 different ways:
- As a string representing a single Salesforce product ID using the `productId` field. Any successful product purchases will have a starting time matching the time that Zephr received the webhook and no ending time (the user’s access will continue until cancelled).
- Multiple strings representing Salesforce product IDs may be supplied in a JSON array with the `productIds` field. Any successful product purchases will have a starting time matching the time that Zephr received the webhook and no ending time (the user’s access will continue until cancelled).
- As an array of objects to the `products` field. This option allows the caller to optionally specify start and end times for a product grant. Dates should be supplied as strings and will be parsed as a Javascript Date(). It is recommended to supply date strings in ISO 8601 to avoid ambiguity and for maximum precision.
Example:
{"productId":"7011o0000011UsOAAU","email":"emaill@email.com","contactId":"0031q00000EC3YNAA1"}
Example with start and end times for products:
{
"contactId": "7011o0000011UsOAAU",
"email": "email@email.com",
"products": [
{
"id": "abc123",
"start_time": "2020-10-15T23:06:59.000Z",
"end_time": "2021-10-15T23:06:59.000Z"
},
{
"id": "56789DEF",
"start_time": "2020-10-15T20:06:59.000Z",
"end_time": "2020-11-15T20:06:59.000Z"
}
]
}
cancelProduct
This is used to remove a product grant from a Zephr User when a product or subscription is removed from the corresponding Salesforce Contact – for example if a user has phoned the customer service team asking to put a hold on their subscription. This will:
- Check Zephr for the Salesforce Contact’s Email
- If found this will:
- Check for Product Grants in Zephr User’s Extended Profile
- Revoke the matching Product ID
- Update the Zephr User’s Extended Profile with remaining Product Grants
- If found this will:
Example:
{"productId":"701240000009JyLAAU","email":"email@world.com","contactId":"0031q00000925cVAAQ"}