Showing posts with label rest api. Show all posts
Showing posts with label rest api. Show all posts

Thursday, 13 May 2021

Integration of Salesforce Chatter with SharePoint Online

INTRODUCTION 

When working on one of the requirements for a manufacturing sector project for a client based in Atlanta, Georgia, USA, we came across a requirement where we had to develop a solution by integrating Salesforce with SharePoint. The basic need was to save feedback/comments from SharePoint to custom object in Salesforce. 

Comment should contain user name same as in Salesforce Chatter. Responses received from either of the platform, Salesforce or SharePoint; should be in sync. 

CHALLENGE

The main challenge was that SharePoint users are not licensed users within Salesforce. And API provided by chatter saves comment or post to chatter for only Salesforce licensed user. These users were not in sync with both Salesforce and SharePoint. 
 
The other challenge was to display comments from Salesforce into SharePoint. Connect API provides very complex response from Salesforce and it was not easy to map the field values in SharePoint. 

APPROACH

To address these issues, we took an approach of configuring a custom object in Salesforce to save comments. With a Master-detail relationship, we linked this custom object (which was created to save comments) to its parent object. 

To get more insight about the technical approach, have a look at the below explanation and screenshots. 

Let’s assume that we have an object (e.g., Account) which we consider as a parent object. We want to add comments related to the each record of that object. 

Now, users from SharePoint are going to add their comments to the records of this object to keep track of approval status. Let’s not forget that these users are not licensed Salesforce users. 

SharePoint users add their comments from SharePoint UI and with use of REST API, it will be stored in custom object in Salesforce, which is related to our parent object - Account. 

To store these comments from SharePoint, Salesforce connected app credentials were used for authentication and authorization.

Configuration of custom object for Chatter is shown in below screenshot:

Data fetched through REST API from SharePoint, would be displayed as shown in below screenshot.

SUMMARY 

By configuring custom object in Salesforce & using REST API, we can easily integrate data from 3rd party applications used by non-Salesforce users by its username or email id.

If you have any questions you can reach out our Salesforce Consulting team here.

Thursday, 6 May 2021

Integration of Salesforce Marketing Cloud with Open Source CRM System using Rest API

INTRODUCTION

While working on one of the requirements for a transportation sector project for a client based out of Melbourne, Australia there was a requirement to import existing records\leads into the Salesforce Marketing Cloud from third party open source CRM system.

We also needed to provide specifications to add lead into SFMC on the fly from an external CRM system by doing necessary configuration. Given specifications are to be used by other CRM team to insert record from CRM to SFMC on the fly. Below are the detailed steps we need to follow:

APPROACH

1) For importing existing data into Salesforce Marketing Cloud, we have created Data Extension and fields into SFMC and used CSV Import.

2) For integration with third party system, Marketing Cloud provides two APIs that uses OAuth 2 authentication mechanism:
  • The REST API gives you more access to Marketing Cloud features.
  • The SOAP API gives you complete access to most email features.

In this scenario, we have used REST API to integrate with external system. 

Marketing Cloud administrator user is required to perform the actions needed for configuration. Following steps are executed in SFMC.

  • Log in as Marketing Cloud Administrator user in SFMC.
  • Go to Setup -> Apps ->Installed Packages.
  • Click New to create a new package.
  • In the New Package Details window, enter the Name and Description of the package.
  • Click on the Save button.
  • Click on Add Component and will open one pop-up window for setup.
  • In pop-up, select API Integration and click Next. 

  • Select Server-to-Serveras Integration type then click Next.
  • Select required permission for API and click the Save button. Permission can be updated in future, if required.
  • Copy Client Id, Client secret, Authentication URL, and REST URL which will be used for API integration in future steps.

  • Getting Access Token
    • Example Request:
      • Authentication endpoint can be retrieved from the above step.
      • Endpointhttps://YOUR_SUBDOMAIN.auth.marketingcloudapis.com/v2/token
      • Method: POST
      • Content-Type: application/json
    • Request Body:
  • {
    "grant_type": "client_credentials",
    "client_id": "7a9j47upktedde30uedl822p",
    "client_secret": "195527892567524157"
    • Example Response : HTTP/1.1 200 OK
    • Response Body:
  • {
    "access_token":"eyJhbLciOiJIPzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjIifQ.eyJhY2Nlc3NfdG9rZW4iOiJhYmJUQTlpSHZqRjkyd3Jkb0xWZEFCaloiLCJjbGllbnRfaWQiOiI3ZTRmYW1xaWUzcWtzdzlhNDRrcmxvZDgiLCJlaWQiOjEwNzU3Njc2LCJzdGFja19rZXkiOiJRQTFTMSJ9.wSFfEdeNrkoiU_tnmJ2ihm8iUqnJKlZoI3GlavTGBhs.hU4EsiC1e9txh_TCt90YlI2l7xZZ5E6_oa0xku3Jj9CCk1B72M4bhO3kUIyhwfVuB0MFbL0y9KD_RRFzg-nuqPgjPyONnby-iWopdZPBHd-3woupxCMST5-vfJO9qAED9qiUfYLS4WmHRuJTCX4NPScyu8BdROTVEe-D3iAoAeFoJX_rLZ9d5eEhIn1AvkYgoj9siuxAprHEvmySTgNIXkQA6uT_IQ-H1dbfOyJmlFKpYzvhvHb0KH7NJ24zy5bd2MQ5",
    "expires_in":1080,
    "token_type":"Bearer",
    "rest_instance_url":"mc563885gzs27c5t9-3k636tzgm.rest.marketingcloudapis.com",
    "soap_instance_url":"mc563885gzs27c5t9-63k636tzgm.soap.marketingcloudapis.com",
    "scope": "email_read email_write email_send"
    
    }

  • Upsert records in Data Extension: 
    • In a single synchronous call, the API upserts multiple data extension rows. The maximum size of a payload is 5 megabytes. We can post a maximum of 50 fields and 50 records at a time as a best practice.
    • Example Request: 
      • Host:https://YOUR_SUBDOMAIN.rest.marketingcloudapis.com/hub/v1/dataeventsasync/key:YOUR_KEY/rowset
      • Method: POST
      • Content-Type: application/json
      • Authorization: Bearer YOUR_ACCESS_TOKEN
    • Request Body 

  • [ { "keys":{ "Email": "someone@example.com"}, "values":{ "LastLogin": "2013-05-23T14:32:00Z", "IsActive": true, "FirstName": "John", "FollowerCount": 2, "LastName": "Smith" } }, { "keys": {"Email": "someone2@example.com"}, "values":{ "LastLogin": "2013-05-23T14:32:00Z", "IsActive": true, "FirstName": "Jane", "FollowerCount": 2, "LastName": "Smith" } } ]
    • Example Response : HTTP/1.1 200 OK
    • Response Body:
  • [
         {
             "keys": {
                     "Email": "someone@example.com"
                     },
             "values": {
                     "LastLogin": "2013-05-23T14:32:00Z",
                     "IsActive": true,
                     "FirstName": "John",
                     "FollowerCount": 2,
                     "LastName": "Smith"
                     }
         },
         {
             "keys": {
                     "Email": "someone2@example.com"
                     },
             "values": {
                     "LastLogin": "2013-05-23T14:32:00Z",
                     "IsActive": true,
                     "FirstName": "Jane",
                     "FollowerCount": 2,
                     "LastName": "Smith"
                     }
         }
     
  • API returns a 400 response for an an invalid request with details on the error.

SUMMARY
Using Salesforce Marketing cloud APIs, third party open source CRM can be integrated with SFMC. APIs and its sample responses are used to add records on the fly into SFMC. For further details you can refer to this Link!

If you have any questions you can reach out our Salesforce Consulting team here.