Integrate Salesforce with Magento 2 use Webhook

Salesforce is the leading customer relationship management (CRM) cloud-based software in the world. By providing CRM applications for sales and customers management, Salesforce offers optimal sales customer management solutions for businesses. It has high security and reliability, so it is extremely appropriate for small and medium enterprises. In an effort to help the business grow successfully, Mageplaza develops Webhook extension which allows Salesforce integrates with Magento 2 easily.

What Is Webhook?

Webhook is a helpful tool which allows online stores to configure to send an API request to a configurable destination (URL) such as other servers or applications in cases trigger events including new order, customer login, abandoned carts, etc occur. As a result, store owners can instantly update important notifications and have suitable activities shortly.

Table Of Content

Webhook supports these below entities of Magento:

  • Customer
  • Order
  • Invoice
  • Shipment
  • Credit Memo
  • Product
  • Category
  • Abandoned Cart

These entities of Salesforce:

  • Accounts
  • Contacts
  • Events
  • Asset
  • Campaign

How To Integrate Salesforce With Magento 2 With Webhook

Instructions For Registering And Using Salesforce

Access to here, click the Sign up for free button to register a new Salesforce account > Fill out the registration form completely:

Instructions For Registering And Using Salesforce 1

After sign up successfully, access to https://workbench.developerforce.com:

Instructions For Registering And Using Salesforce 2

  • Environment: Production
  • API Version: choose API Version you want, click the below checkbox
  • Click Login with Salesforce button to log in Workbench by using your registered Salesforce account.
    After Login in Workbench successfylly, please click utilities > Apex Execute > Enter the command: System.debug(UserInfo.getOrganizationId()+’‘+UserInfo.getSessionId().SubString(15)); > Click the Execute button to get Session ID.

Instructions For Registering And Using Salesforce 3

These Fields Of Salesforce

To view the latest fields of Salesforce, you can click here

Instructions For Creating Hook

How to create a new account in Salesforce via Magento 2

Required fields:

  • Name

Optional fields:

  • Fax
  • Type
  • Phone
  • Jigsaw
  • OwnerId
  • SicDesc
  • Website
  • Industry
  • ParentId
  • BillingCity
  • Description
  • BillingState
  • ShippingCity
  • AccountSource
  • AnnualRevenue
  • BillingStreet
  • ShippingState
  • BillingCountry
  • ShippingStreet
  • BillingLatitude
  • ShippingCountry
  • BillingLongitude
  • ShippingLatitude
  • BillingPostalCode
  • NumberOfEmployees
  • ShippingLongitude
  • ShippingPostalCode
  • BillingGeocodeAccuracy
  • ShippingGeocodeAccuracy

In this part, I will give detail instructions on how to configure Webhook which helps Magento 2 integrate with HubSpot.

From the Admin Panel, go to System > Webhook > Manage Hooks, select Add New on the right corner, then you will see many options including New Order, New Customer, Update Customer, Delete Customer, etc.

Step 1: Fill all information in the General Information tab

How to create a new account in Salesforce via Magento 2 image 1

Step 2: Enter the data on the Action tab

How to create a new account in Salesforce via Magento 2 image 2 How to create a new account in Salesforce via Magento 2 image 3

Notes:

Payload URL:

  • End point: /services/data/vx.y/sobjects/Account, with vx.y is your API Version which is installed Workbench.

Headers: Click the Add button to add the value of headers such as Name and Value according to requests of servers, in order to call this API.

  • Name: Authorization, Value: Bearer Session ID, with Session ID is Session ID which you already found.
  • For example:

How to create a new account in Salesforce via Magento 2 image 4

Body: With POST or PUT method, you need to add content on the Content section to send the request. Click the Insert Variable button to choose variable.

  • With the customer of Magento and POST method, you need to insert the below content into Body section:
{

  "Name" : "Alata",

  "ShippingCity" : "New York",

}

Note: If you want to get any data field, you need to change the value of this data field with variable coming from Insert Variable.

The results of creating a hook:

How to create a new account in Salesforce via Magento 2 image 5

Once some events in Store such as adding new customer, new order, etc occurs, the data will be saved on Hook Logs:

How to create a new account in Salesforce via Magento 2 image 6

Click Select > View to redirect to View log page, in order to view the data information:

How to create a new account in Salesforce via Magento 2 image 7

The Result Shown In Salesforce:

The Result Shown In Salesforce

These Available Body Templates

New Contact:

Endpoints URL

  • POST: /services/data/vx.y/sobjects/Contact

Required fields:

  • LastName

Optional fields:

  • Fax
  • Email
  • Phone
  • Title
  • Jigsaw
  • OwnerId
  • AccountId
  • Birthdate
  • FirstName
  • HomePhone
  • OtherCity
  • Department
  • LeadSource
  • OtherPhone
  • OtherState
  • Salutation
  • Description
  • MailingCity
  • MobilePhone
  • OtherStreet
  • ReportsToId
  • MailingState
  • OtherCountry
  • AssistantName
  • MailingStreet
  • OtherLatitude
  • AssistantPhone
  • MailingCountry
  • OtherLongitude
  • MailingLatitude
  • OtherPostalCode
  • EmailBouncedDate
  • MailingLongitude
  • MailingPostalCode
  • EmailBouncedReason
  • OtherGeocodeAccuracy
  • MailingGeocodeAccuracy

Body Template:

{

        “LastName” : “Sam”,

        “FirstName” : “Mageplaza”,

        “Email” : “mageplaza@gmail.com”

}

Note: If you want to get any data field, you need to change the value of this data field with variable coming from Insert Variable.

Conclusion

In this tutorial, we introduce how to register Salesforce, create Hook with Mageplaza Webhook Extension to integrate Salesforce with Magento 2. In addition, you can refer to other useful extensions for your store here.

Explore Mageplaza Webhook for Mageplaza 2 now!






Back Ask Mageplaza

magento-2-tutorial
webhook