Configuring Salesforce to Automatically Send a Thnks
This guide walks you through automatically triggering the sending of a Thnks using Salesforce Process Builder or Apex triggers.Prerequisites
- Access to the Thnks API.
- Thnks API Key (Authorization Token).
- URL for Thnks API endpoint.
- Administrative access to Salesforce for creating custom fields and Apex classes.
Setup
Prepare Webhook Data
Before setting up the integration, ensure you have the following details:
Data (JSON format)
Here’s an example of the JSON payload you will need to include in the request. You’ll need to replace the placeholders with the appropriate Salesforce tokens or field variables:
- Replace
<GIFT_ID>with the Thnks ID of the gift you want to send. - Use Salesforce merge fields or dynamic data variables (e.g.,
{!Contact.Email}) to populate lead or contact information.
Create an Apex Class for the API Callout
Trigger the Apex Class
Use Process Builder or Flow
- Create a Process in Process Builder or a Flow in Salesforce to trigger the Apex class.
- Define the criteria for when the gift should be sent (e.g., Opportunity Stage Closed Won or Lead Status Changed).
- Use the Apex Action to call the
ThnksGiftSender.sendGiftmethod, passing the required parameters (e.g., Gift ID, Contact Email, First Name, Last Name, and Message).
Test and Verify
Run a Test with Sample Data
Test the Process Builder workflow, Flow, or Trigger using sample data to ensure the API callout works as expected.
Check Logs
Verify the API callout response in the Apex Logs to ensure the gift was sent successfully.
Best Practices