How to Integrate Salesforce and Postgrid with Zapier?

Salesforce and Postgrid with Zapier

Zapier is an automation tool that helps you to connect different web-application and automate the tasks and data between them. It supports over 5000+ apps including Gmail, Salesforce, Slack, etc. It works by creating “Zaps” which are automated workflows that connect two or more apps. For example, You can integrate Salesforce and Postgrid with Zaper. For example, Zapier makes it easy to connect your Salesforce data with Postgrid, so you can send postcards, create contacts, and other communications with just a few clicks.

Integrating Salesforce and Postgrid with Zapier

In this case, there are six stages in the process of creating Postgrid contacts using details of Salesforce campaign members of the “Account” type:

Creating a Zap to integrate Salesforce and Postgrid.

1. First, log in to your Zapier Account.

2. Then, click the “Create Zap” button from the left sidebar of the page.

Salesforce and Postgrid

Creating a trigger for the app.

1. Afterward in the Trigger section, select “Salesforce” as the trigger app. In brief, a trigger is an event that starts the Zap.

2. Then, select the trigger event and click the “Continue” button. We are selecting “New Record” to trigger when a record is created.

3. Moreover, allow Zapier to access your Salesforce Account and click the “Continue” button.

Salesforce and Postgrid

4. Further, choose the Salesforce Object for the trigger and click the “Continue” button. We are choosing “Campaign Member” as the trigger object.

5. Then, test your trigger to confirm that the right account is connected and your trigger is set up correctly. For this, Trigger Object must contain at least one record.

Filtering Account from Campaign member.

1. In the Action section, select “Filter by Zapier” which will filter the “Account” from CampaignMember, and click the “Continue” button.

2. Then, set the filter condition so that “Type (Text)Exactly Matches Account” and click the “Continue” button. This will immediately open another Action section.

Salesforce and Postgrid

Using code to split AccountName into first-name and last-name.

1. In this Action section, Select “Code by Zapier“. It is being used to split the Account name and return them as first name and last name. It will also return two-letter country codes for the respective country.

2. Then, select “Run Javascript” as a code event and click the “Continue” button.

3. Then, name the variables “fullName” & “countryName” and populate the corresponding fields with Name & Country fields respectively.

Salesforce and Postgrid

4. Thereafter, replace the code in the code editor with the following codes:

//FOR SPLITTING THE NAMES OF ACCOUNTS INTO TWO PARTS
const splitName = (fullName) => {
  let words = fullName.split(" ");
  let firstName = words[0];
  let lastName = words.slice(1).join(" ");
  return { firstName, lastName };
};
// Example usage
const fullName = inputData.fullName;
const { firstName, lastName } = splitName(fullName);

//FOR GETTING THE COUNTRY CODE OF THE COUNTRY
const getCountryCode = async (country) => {
  const url = `https://restcountries.com/v2/name/${encodeURIComponent(country)}?fullText=true&fields=alpha2Code`;
  const response = await fetch(url);
  const data = await response.json();
  if (data.length > 0) {
    return data[0].alpha2Code;
  } else {
    return " "; // return a space character if no matches are found
  }
};
// Example usage
const countryName = inputData.countryName;
const countryCode = await getCountryCode(countryName);

output = { firstName, lastName, countryCode };

5. Now, click the “Continue” button and also test the action by clicking the “Test Action” button.

Creating an action for the Zap.

1. Afterward, click the “+” at the bottom of the Coding section. This will open the final Action section.

2. In this section, select “PostGrid Print & Mail” as the final action and then select “Create Contact” as the action event.

3. Then, click the “Continue” button.

4. Thereafter, allow Zapier to access your PostGrid Print & Mail Account by providing “API Keys” of your postgrid account and then click the “Continue” button. You can find your API keys at https://dashboard.postgrid.com/dashboard/settings. Then, click the “Continue” button.

Salesforce and Postgrid

Mapping fields for contact creation.

1. Further, populate the contact fields with their corresponding fields by searching in the insert data field. But select the “First Name“, “Last Name” and “Country Code” from the “Run Javascript in Code by Zapier” dropdown.

Salesforce and Postgrid

2. Furthermore, click the “Continue” button. Following this, click the “Test Action” button to test the Zap if it is correctly working or not.

3. Finally, click the “Publish Zap” button to publish the Zap.

Now, your automation is ready for working. If you create a campaign member in Salesforce then, the Zap triggers. Then, the filter checks if the campaign member is an account or not. If the campaign member is an account then, the Zap continues else the Zap breaks. Afterward, the Zap splits the AccountName into first name and last name and generates country-code. Finally, the details are mapped in the contact fields and the contact is created.

Please contact us at manish@bay20.com or call us at +91-8800519180 for any support related to Salesforce. You can also visit the salesforce development page to check the services we offer.