Tailwind Logo

Implementing a webhook in Sitecore Connect that works with Sitecore Forms.

XM CloudConnect

Published: 2024-07-29

I will create a sample that uses a webhook to connect to Sitecore Connect and save the data entered into Sitecore Forms. The data will be saved to an Excel file in OneDrive. In practice, it would be better to save the data in a CRM or similar.

Create a Project

First, create a project in Sitecore Connect. In this case, we will name the project XM Cloud Demo. c

connectexcel02.png

The first step is to create a Folder, since the Project you have just created contains nothing. Name the folder XM Cloud to Excel.

connectexcel03.png

Once the folder is created, recipes can be created.

connectexcel04.png

Create a Recipe

This time, we will create a Recipe from scratch, which will be linked to Sitecore Forms using a webhook, so the configuration will be as follows

connectexcel05.png

Click the "Start Building" button, and after a few moments you will be taken to a screen where you can set the Webhook Trigger and Next Action as shown below.

connectexcel06.png

+ to select what to do when a request is made in the webhook.

Trigger settings

Before creating an action, configure the Trigger settings. Clicking on the newly created trigger will take you to the setup screen.

connectexcel07.png

Click the "Start guided setup" button to go to the Setup webhook screen. Set the Event name here.

connectexcel08.png

After setting, switch to the Listen for an event screen.

connectexcel08a.png

In this state, go to the Sitecore Forms administration page and navigate to the Webhooks page.

connectexcel09.png

Click the Create webhook button to open the webhook configuration screen, and set the webhook URL shown on the Sitecore Connect screen.

connectexcel10.png

Next, open the form for which you want to configure settings, click on the settings icon (to the right of the icons lined up in the center), and specify the webhook you created in Choose webhook.

connectexcel11.png

After specifying, click Test webhook to display the test screen.

connectexcel12.png

Enter a value and click the Submit button to preview the data to be sent.

connectexcel13.png

After pressing the Submit button and navigating to the Sitecore Connect screen, we were able to confirm that the data had been received successfully.

connectexcel14.png

Trigger is now complete.

connectexcel15.png

Create Action

The data received by the trigger will be processed in Actions. In this case, we will record the contents of the form in Excel.

First, click + to select the next type of action.

connectexcel16.png

This time, we will select Action in app, search in Excel, and create the settings for integration with Excel.

connectexcel17.png

This time, select Add rows in batch to add rows to an Excel sheet. Clicking on the button switches to the configuration screen for connecting to an Excel file.

connectexcel18.png

When you use the service for the first time, a screen for setting authorization to connect will be displayed as shown below.

connectexcel19.png

After accepting, the procedure changes to selecting an Excel file placed in storage. For this demonstration, we will specify an Excel file placed in OneDrive.

connectexcel20.png

Add table definitions to the specified Excel file.

connectexcel21.png

Once this name is added to the Sitecore Connect configuration, the table entry will appear in the configuration screen.

connectexcel22.png

Then, for each item, specify which Excel table data will be set for the item when the Trigger is created.

connectexcel23.png

The Action is now complete.

Test Job

On the screen you are creating, there is a button to switch to Test Jobs. When you switch to Test Jobs, you will see a screen like the one below.

connectexcel24.png

Click the button to enter the test mode.

connectexcel25.png

When in this mode, go to Sitecore Forms and run the test on the target form. If the data is received and written to Excel, the Sitecore Connect test screen will appear as Successful as shown below.

connectexcel26.png

Referring to the Excel file, we were able to verify that it contained the entered data.

connectexcel27.png

The recipe is now complete.

connectexcel28.png

Summary

This time, we created a recipe in Sitecore Connect, connected to the Sitcore Forms Webhook, and set up an Excel file to save the data to. In actual operation, the data of the form could be saved to Excel in less than an hour. In actual operation, I think Sitecore Connect can be used to implement various processes, such as specifying the save destination in the CRM connection.

Tags