Set up HeyLoyalty webhook

To ensure that the changes made to members directly in HeyLoyalty are synchronized back to Business Central (BC), you need to set up a webhook in your HeyLoyalty environment.

Prerequisites

Make sure you’ve set up member synchronization and created AAD application for HeyLoyalty in Business Central before moving on to procedural steps.

Procedure in Business Central

  1. Click the Lightbulb button, search for the Web Services page, and open it.
  2. Find the webservice address that was created in Business Central for HeyLoyalty.
    It should have Service Name = heyloyalty_services. 3.Copy the web service link from the field OData V4 URL.
  3. Adjust the link address, so HeyLoyalty can understand it correctly:
    Generally a Business Central webservice URL for HeyLoyalty has the following structure:
https://api.businesscentral.dynamics.com/v2.0/<Your BC tenant ID>/<Your BC environment name>/ODataV4/Company('<Your BC company name>')/heyloyalty_services

As you can see, there are character pairs (' and ') around your BC company name. HeyLoyalty doesn’t support this. So you’ll need to replace the (' with its URL encoded representation %28%27, and the ') with %27%29. For example:

  • Original URL:
https://api.businesscentral.dynamics.com/v2.0/1f807cd6-d8bf-4bb0-b2e4-922d41e37d37/Production/ODataV4/Company('CRONUS%20Danmark%20A%2FS')/heyloyalty_services
  • Adjusted URL:
https://api.businesscentral.dynamics.com/v2.0/1f807cd6-d8bf-4bb0-b2e4-922d41e37d37/Production/ODataV4/Company%28%27CRONUS%20Danmark%20A%2FS%27%29/heyloyalty_services

Procedure in your HeyLoyalty environment

  1. Select Lists from the top menu ribbon, then select Edit List on the list you want to set the webhook for.

  2. Select the Webhooks subsection.

    &ldquo;Webhooks&rdquo; subsection of a HeyLoyalty list

  3. Click Create a webhook. Fill in the following fields for the new webhook:

Field nameRecommended value
URLThe adjusted web service URL from Business Central you have prepared earlier.
Contact emailAn email address to which webhook errors should be sent.
Send as raw json objectYes
Simplified formatYes
Authentication typeOAuth 2.0
UsernameThe Application (Client) ID from the Azure AD application details page that was shown to you at the end of the “Create Azure Active Directory application for HeyLoyalty” process
PasswordThe Client Secret value from the Azure AD application details page
base URLhttps://login.microsoftonline.com/<Your BC tenant ID>/oauth2/v2.0
scopes (optional)https://api.businesscentral.dynamics.com/.default
New subscriber (email, phone)Yes
New subscriber (heypush)Yes
Update subscriberYes
Unsubscribe subscriberYes
Spam complaintYes
Hard bouncesYes