Invoke URL task
An Invoke URL task is used to access third party services from Zoho SalesIQ via Connections. The Invoke URL task supports four HTTP methods, GET, POST, PUT, DELETE via connections.
The list of parameters passed when the invoke URL task is executed is explained in this table.
|url||The resource URL from the third party service used to perform various operations.||Mandatory|
|type||HTTP Methods: GET | PUT | POST | DELETE||Mandatory|
|parameters||To send additional params of the form data type in the request URL.||Optional|
|headers||Headers are used to specify the request header parameters.||Optional|
|connection||The name of the connection to be used.||Optional|
|files||The file object.||Optional|
Let us consider Twitter as the third party service integrated with Zoho SalesIQ. First create a connection with Twitter that lets you perform operations like searching, posting and reading tweets right from your chat window using the Invoke URL function.
- Create the connection by choosing twitter from the pre-registered service and enter the Connection Name and declare the Use Credentials of Login User option.
- Now, create a /tweet command in Zoho SalesIQ. The invoke URL deluge script should be used in the command execution code to let you post tweets from Zoho SalesIQ.
Take a look at the sample invoke URL deluge script modified to suit twitter connection. The twitter resource URL that lets you post/update tweets is as follows
https://api.twitter.com/1.1/statuses/update.json (Refer Twitter API References)
The following deluge script, when executed will tweet your message directly from Zoho SalesIQ.
response=invokeUrl [ url: "https://api.twitter.com/1.1/statuses/update.json?status=" + tweetMessage type: POST connection: twitter ];
The params and their description are:
- URL: Give the Twitter API to post/updates tweets along with the variable.
- type: Specify the HTTP method - POST
- connection: Give the connection name. This connection has the use credentials of login user value (user access value) set as true. When this code is executed, the user will be prompted to give access and perform integration with their own credentials. The first time the /tweet command is triggered, the invoke URL task is executed and the user is prompted to provide access to post on their behalf and on giving access, the message is directly posted to the user's twitter handle.
To use the headers parameter in the invoke URL task :
Take, for example, the /campaigns command that can get you the list of campaigns in with a particular status in your MailChimp account. The MailChimp resource URL to get the list of statuses is given below.
https://usX.api.mailchimp.com/3.0/campaigns (Refer MailChimp API references for the query string parameters that are allowed)
A sample invoke URL deluge script for the MailChimp connection is shown below. The params and their description are:
- URL: Give the mail chimp API to get campaigns list with a particular status.
- type: Specify the HTTP method - GET
- connection: Give the connection name. This connection has the use credentials of login user (user access value) set as true. When this code is executed, the user will be prompted to give access and perform integration with their own credentials.
- headers: Specify the request headers to be passed.
The following deluge script, when executed will get the list of campaigns from Zoho SalesIQ.
headersMc = Map();headersMc.put("Content-Type","application/json"); response=invokeUrl [ url: "https://usX.api.mailchimp.com/3.0/campaigns?query=" + campstatus type: GET connection: mailchimp headers: headersMc ];
As an example let us consider a message action - Upload to GDrive that uploads files shared in a conversation directly to your Google Drive account. The Google Drive API to upload files is shown below:
- URL: Give the Google Drive API to send attachments/ upload files.
- type: Specify the HTTP method - POST
- connection: Give the connection name. This connection has the use credentials of login user (user access value) set as true. When this code is executed, the user will be prompted to give access and perform integration with their own credentials. headers: Specify the request headers to be passed.
- files: The files object of the data type LIST is used to store the list of files.
This deluge script when executed will upload a file shared in any conversation in Zoho SalesIQ to your Google Drive.
driveheaders = Map(); driveheaders.put("Content-Type","application/json"); att = attachments.get(0);fileList = List();fileList.add(comments);fileList.add(att); response=invokeUrl [ url:"https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable" type: POST headers: driveheaders connection: googledrive files: fileList ];
response=invokeUrl [ url: <url> type: <GET/PUT/POST/DELETE> parameters: <parameters> headers: <headers> connection: <connection name> files: <file object> ];