Connectors power up your CRM and add functionalities by Integrating with other services through its APIs (OAuth 2.0).
Getting Started with Connectors
Connectors enable the process of establishing integrations between the solutions built over Vertical Solution platform and third-party applications using the OAuth 2.0 protocol.
You can consider connection as a way to log in to any third-party service. If you're already logged in (connected) to a particular service, you can always access your data stored in those services. Once a connector is created and connected, you can invoke it in the custom functions using the invokeConnector Deluge task, and access data from the required service and via the JS SDK Methods.
For example, to access your Twitter account using Twitter's REST APIs from your solution, you can create a Twitter connection, connect to it, and use the connection link name in invokeConnector task. The invokeConnector task will perform the specified API call to your connected Twitter account and allows you to access the data.
OAuth 2.0
OAuth 2.0 is an industry-standard, open-source authorization protocol, which is used to gain partial access to a user's account on an HTTP service. An example of an OAuth 2.0 authorization is the sign-in screen that appears when a third-party application (also known as a client) requests partial access to a social media account, such as Facebook, Google, or Yahoo.
Important terminologies
Client - The application requesting access to data stored in an external system. When creating a connector in Zoho Developer Console, the client is the solution you are developing.
Resource - The application or service that the client is trying to access. In our case, the resource is the third-party service (ex: Dropbox) you are trying to integrate.
Request Token URL - This URL is used to send authorization requests to the resource server. The resource server prompts the resource owner (user) to authorize this request.
Access Token URL - Once the request is authorized by the resource owner, the server sends an access token to the client. This token has to be exchanged every time the clients wants to access the resource data.
Refresh Token URL - Some access tokens are valid only for a limited period of time. When an access token expires, the client has to get another access token from the resource, using the refresh token URL.
Client ID - A unique identifier provided to every client application. This ID is provided by the resource owner.
Client Secret - Every client application has a secret code mapped to it. This is done to prevent unauthorized access to the resource.
Redirect URL - This is the URL to which the end user will be redirected, once data access has been authorized. The client application will generate a redirect URL automatically.
Create a connector
To create a connector:
Log in to Zoho Developer Console and click Vertical Solutions.
Select the application you'd like to modify and click Edit.
Create a Connectors and under Utilities.
Click Create Connector.
Provide a suitable name and description for the connector.
Provide the name of the third-party service.
Provide the signup URL for the third-party service.
Provide the URLs needed to generate the Auth token.
Request Token URL: This allows the connector to request authorization to access data on the resource server.
Access Token URL: Once authorized, the Request Token and Token Key will be exchanged for the Access Token, allowing the connector to draw specific information from the third-party server.
Refresh Token URL: Some applications increase security by limiting the duration of time a particular token is valid. In these cases, you will need to provide the Refresh Token URL to allow the connector to reauthorize access.
Revoke Token URL: Upon calling the Revoke Token URL, the application shall explicitly revoke tokens and revoke the granted access. Upon providing the Revoke Token URL, users are required to choose between Access Token or Refresh Token for the Revoke using field, which should be used when the Revoke token API call is made.
Choice of the token for the Revoke using field differs from service to service. Please ensure you choose the right token.
Set Client Credentials
Once the Connector details are saved, the Client Credentials pop-up will appear. You can register your solution with the respective third party web-service (Google, MailChimp, etc.) by picking the Redirect URL displayed in the pop-up and generating the Client ID & Client Secret generated at the web service.
Add APIs
Once you have created your Connector, define the actions it can perform by adding an API for each action taken by the connector. For example, once you have integrated with Google Drive, you can export the data present in your solution to your Google Drive, or vice-versa. Both these processes will require different APIs. These APIs will be available in the developer documentation of the application.
Authorize a Connector
After you establish a connector, the connector has to be authorized.
To authorize the connector:
In the All Connectors page of your Zoho developer, open the respective connector by clicking on it.
Click Authorize Connector.
Upon clicking Authorize Connector, if you're not already logged into the third-party account, you will be prompted to do so.
Once you are logged in, the authorization window will explain the access permissions for the connector.
Click Allow.
Once the Connector API is created and authorized, you can validate the API by executing and checking the response.
Validate API
You can validate the API by executing and checking the response.
In the All Connectors page, click on the connector containing the APIs.
A new page will appear, displaying all APIs associating with the connector.
Choose the API from the left pane and click
Execute.
The API request's Response Code and Response Body will be displayed in the response area.
Publish a Connector
Publishing a connector technically means publishing the APIs associated with the connector.
To publish a connector:
- In the All Connectors page, click the connector in which the API is to be published and click Publish.
A new popup will appear to provide publish details. - Provide the following details:
- Connector Logo
- Support Email Address
- Release Notes
Associate Connector with Solution
To associate connectors with your solution:
- In your Zoho Developer Console home page, click Vertical Solutions.
- Select the solution to which you'd like to associate the connector.
- Click Connectors in the left pane and click Associated Connectors.
- Click Add Connector and choose the connector that you intend to associate.
- Click Add.
Connectors Actions
Once the Connector is published, you may define the actions it can perform On Authorization and On Revoking, which will define what action to be performed during an authorization of the connector, and on revoking this connector respectively.
To define and edit connectors actions:
- Navigate to the Associated Connectors page. The connectors will be listed.
- Hover over the respective connector and click View Actions.
- Write your function which needs to be performed on authorization of this connector at On Authorization.
- Write your function which needs to be performed on authorization of this connector at On Revoking.
Using Connectors APIs
Once a connector is created and connected, you can invoke the APIs defined in it via the below means:
- Custom functions using the invokeConnector deluge task
- JS SDK Methods.
Invoking Connectors APIs via Custom Functions
Syntax
response_variable =zoho.crm.invokeConnector("connector_unique_identifier");
The connector_unique_identifier is the API name of the Connector and can be obtained from the Associated Connectors section of Connectors at the solution in which the connector is associated.
To find the connector_unique_identifier:
- Navigate to the Associated Connectors page and go to Associated Connectors.
- Hover over the respective connector and click View All API's.
You can view the List of APIs. - Click the respective APIs, to view the Connectors API Details.
Find the API Unique identifier, which follows the format of connector_unique_identifier.connector_api_unique_identifier. For example, if the API Unique identifier is ' gcontacts.pushcontact ', gcontacts is the API name of the connector and pushcontact is the API name of the API .
You may also click the Copy to Clipboard button to copy the sample script and use them in the custom functions.
Sample Code
data=Map();
data.put("First_Name","Alfred");
data.put("Last_Name","Little");
data.put("Email_ID","example@zohomail.com");
data.put("Phone_Number","");
zoho.crm.invokeconnector("gcontacts.pushcontact",data);
Invoking Connectors and its APIs via JS SDK Methods
Connectors and the APIs within them can be invoked via our JS SDK methods, thereby facilitating users to perform their business functionalities from a custom build widgets.
There are 4 methods that are associated with Connector in our JS SDK, which will we explain in detail below:
- Authorize a Connector
- Connector Status
- Revoke Connector
- Invoke Connector API
You can find the JS SDK and some sample widgets on our Github page.
Authorize a Connector
The ZOHO.CRM.CONNECTOR.authorize method can be used to authorize a connector, which will prompt the connector authorize window.
Syntax
ZOHO.CRM.CONNECTOR.authorize(connector_unique_identifier)
The connector_unique_identifier here refers to the API name of the Connector.
Sample code
var connectorAPIName = "zoho.authorize";
ZOHO.CRM.CONNECTOR.authorize(connectorAPIName);
Connector Status
The ZOHO.CRM.CONNECTOR.isConnectorAuthorized method can be used to check and verify the status of a connector. The response will be in boolean, where 'true' means the connector's authorization is active and 'false' means the connector's authorization is inactive and needs re-authorization.
Syntax
ZOHO.CRM.CONNECTOR.isConnectorAuthorized(connector_unique_identifier)
The connector_unique_identifier here refers to the NameSpace of Connector to authorize.
Sample code
var connectorAPIName = "zoho.authorize";
ZOHO.CRM.CONNECTOR.isConnectorAuthorized(connectorAPIName)
.then(function(result){
console.log(result)
});
Revoke Connector
The ZOHO.CRM.CONNECTOR.revokeConnector method can be used to revoke the connector authorisation.
Syntax
ZOHO.CRM.CONNECTOR.revokeConnector(connector_unique_identifier)
The connector_api_unique_identifier here refers to the API name of the of the connector.
Sample Code
ZOHO.CRM.CONNECTOR.revokeConnector("zoho.accounts")
.then(function(data){
console.log(data)
})
Invoke Connector API
The ZOHO.CRM.CONNECTOR.invokeAPI method can be used to Invoke the APIs defined within the connector.
Syntax
ZOHO.CRM.CONNECTOR.invokeAPI(connector_api_unique_identifier, data)
The connector_api_unique_identifier here refers to the API name of Connector API. The data here refers to the data object that has passed to the connector API.
The data object contains the following parameters:
NAME | TYPE | DESCRIPTION
|
VARIABLES | Object | Dynamic Data represented by placeholders in connectorAPI |
CONTENT_TYPE | Object | ContentType - multipart for multipart request |
PARTS | Array | For multipart request provide parts config here |
FILE | Object | To include a file in your multipart request |
Sample Code
var data = {
"apikey":"**********",
"name":"peter",
"email":"example@zohomail.com"
}
ZOHO.CRM.CONNECTOR.invokeAPI("gcontacts.pushcontact",data)
.then(function(data){
console.log(data)
})
Authorizing Connectors in Subscriber Orgs
Once connectors are packaged and upgraded in a subscriber org, subscribers must authorize them in their orgs to make them active.
Subscriber org admins must authorize each connector. If not authorized, the functionalities that use the connector will not work as intended.
To authorize connectors, subscribers should:
- Log in to the subscriber account.
- Go to Setup > Developer Space > Connectors.
- Click the Authorize button next to the connector you want to authorize.
- On the authorization page, enter your credentials for the third-party service and allow the access permissions for the application.
Upon clicking Authorize, you will be redirected to the respective third-party service's authorization page associated with the connector, defined in the developer console. Here, you will need to enter your credentials for the respective service and accept the access permissions for the application.