Welcome to the Salesforce Webhook Integration Template! This template is designed to help you easily set up a Python server that listens for incoming webhook notifications from Salesforce. When a specified event occurs in Salesforce, such as a record being created or updated, Salesforce will send a notification to your Python server, which will then print the data for verification purposes. This is an excellent way to integrate Salesforce events with your applications or workflows.
To begin using this template, simply click on "Start with this Template" on the Lazy platform. This will pre-populate the code in the Lazy Builder interface, so you won't need to copy, paste, or delete any code manually.
Once you have started with the template, the next step is to deploy the app. Press the "Test" button on the Lazy platform. This will initiate the deployment process and launch the Lazy CLI. The Lazy platform handles all deployment aspects, so you don't need to worry about setting up your environment or installing libraries.
After pressing the "Test" button and deploying your app, Lazy will provide you with a dedicated server link. This link is where your Python server will listen for incoming webhook notifications from Salesforce. You can use this link to set up the webhook in Salesforce and to interact with the app.
To integrate the Python server with Salesforce, follow these detailed steps:
Here is a sample Apex class that you can use as a starting point:
public class WebhookNotifier {
@future(callout=true)
public static void sendNotification(String jsonBody) {
HttpRequest req = new HttpRequest();
req.setEndpoint('http://your-python-server-url/webhook');
req.setMethod('POST');
req.setHeader('Content-Type', 'application/json');
req.setBody(jsonBody);
Http http = new Http();
HTTPResponse res = http.send(req);
// Handle the response as needed.
}
}
Replace 'http://your-python-server-url/webhook' with the server link provided by Lazy after deployment.
Remember to follow Salesforce's documentation for creating triggers and writing Apex classes. You can find more information on these topics in the Salesforce Developer Documentation.
By following these steps, you will have successfully integrated the Salesforce Webhook Integration Template with your Salesforce instance, allowing you to receive and handle events in real-time on your Python server.