Executing Functions using API URLs | Online Help | Sigma

Executing Functions using API URLs

Executing a function via a REST API URL is now supported in Sigma. All you have to do is configure the Function Execution API URL with your function parameters. This helps to listen to third-party application events through webhooks and perform relevant actions. 
This functionality is currently supported only for Zoho Desk and Zoho Projects' extensions.

Business Case

To sync two Project Management Software like Zoho Projects and Jira via Sigma, the Function Execution API can be used. To do this, a webhook with the function URL is configured in Jira's end, which in turn invokes the DRE function in Sigma every time the configured action occurs. Thus, you can allow Jira to create a task or a bug every time an issue is filed in Zoho Projects and vice versa.
 
Note that only the functions associated with installed extensions can be executed using this API. To execute a Sigma function, use *.sigmaexecution domain.
 

Function Execution API

  1.  POST    https://<APP UUID>.sigmaexecution.com/workspace/invokefunction

Parameters

* refers to mandatory fields

Name
Type
Description
auth_type *
String
Authentication type.
encapiKey *
String
Encrypted API key. Note that this must be encoded if tried on Postman API.
sigma_function_uuid *
String
ID of the sigma function to be executed.
sigma_function_version *
Double
Version of the sigma function to be executed.
integ_scope_id *
Long
Portal ID of the Zoho Service.
app_install_id*
Long
Installation ID of the extension.
custom_response
Boolean
Customize the response format.

Extra Parameters

Function Execution API allows 10 more dynamic request parameters to be configured along with above mandatory parameters. The parameters can be in the following format:
 
Name
Type
Format
Dynamic Parameters
String
[a-zA-Z0-9_-]+

Request Body

Only JSON and XML content types are allowed in request body.

Headers

Function Execution API allows a maximum of 30 headers, including HTTP default headers. These extra headers will be passed to the DRE function via input data with property as 'headers'.
 

Input Data Format for DRE Function

Input data will be passed to the function in JSON format, along with the Request Body, Headers and Extra Parameters, if any.
  1. {
  2.    "app_install_id" : "12345678901234",
  3.    "zapp_uuid" : "4998cbb4-2b14-4c46-b8fa-1ba2084c2f13",
  4.    "version" : 1.0,
  5.    "app_scope_id" : "676543",
  6.    "integ_scope_id" : "123456", // service team installed org id
  7.    "service_app_id" : "22334455667777", // service team's app installed id
  8.    "request_method" : "POST",
  9.    "sigma_execution_domain" : "4998cbb4-2b14-4c46-b8fa-1ba2084c2f13.sigmaexecution.com",
  10.    "service_domain" : "orchetly.zoho.com",
  11.    "payload" : <request body>,
  12.    "parameters" : { "param1" : "value1", .... etc },
  13.    "headers" : { "header1" : "value1", .... etc },
  14.    "encapiKey" : "<IAM Org API Key>", // this is unique for each installation
  15. }

Success Response

Once the API executes successfully, the response can be obtained in 4 different types of response formats. These formats are based on the function's return type and custom_response parameter.
 
Case 1: DRE function with VOID return type
  1. custom_response parameter is FALSE
  2. custom_response parameter is TRUE

Case 2: DRE function with STRING return type
  1. custom_response parameter is FALSE
  2. custom_response parameter is TRUE
 
Case 1a: When return type is VOID and custom_response is FALSE
Status Code: 200
Content Type: application/json
  1. {
  2.  "result": {
  3.    "Tasks": [ ],
  4.    "message": {
  5.       "userMessage": [
  6.            "userMessage1",
  7.            "userMessage2".....          
  8.        ]
  9.    }
  10.  },
  11.  "unique_id": "6770d980-b77f-11ea-8566-e1b196a63afa",
  12.  "code": 3009,
  13.  "function_id": 247153000000022001,
  14.  "message": "Function Executed Successfully",
  15.  "status": "Success"
  16. }
 
Case 1b: When return type is VOID and custom_response is TRUE
Status Code: 200
Content Type: application/json
No response body

Case 2a: When return type is STRING and  custom_response is FALSE
Status Code: 200
Content Type: application/json
  1. {
  2.  "result": {
  3.    "output": "return value",
  4.    "Tasks": [ ],
  5.    "outputType": "STRING",
  6.    "message": {
  7.        "userMessage": [
  8.            "userMessage1",
  9.            "userMessage2".....          
  10.        ]
  11.    }
  12.  },
  13.  "unique_id": "d71ec590-2ef7-11eb-9be9-05d86f610bcc",
  14.  "code": 3009,
  15.  "function_id": "177112000000016001",
  16.  "action": "saveAndExecute",
  17.  "message": "Function Executed Successfully",
  18.  "status": "Success"
  19. }
 
Case 2b: When return type is STRING and  custom_response is TRUE
Let's assume that the variable 'returnObject' is fetched from actual DRE response.
returnObject = actualResponse.result.output 
 
Status Code: <returnObject.statusCode if present, otherwise 200>
Content Type: <returnObject.contentType if present, otherwise application/json>
Response Headers: <returnObject.responseHeaders will be appended if present>
Response Body: <returnObject.message if present>

Validations

  1. returnObject should be a Map type.
  2. returnObject.statusCode should be one of the HTTP Status Code.
  3. returnObject.contentType should be a HTTP supported value.
  4. returnObject.responseHeaders should be a key-value pair.
Note: If the validation fails, we will not throw errors. Instead, we will set default values.

Sample script to return custom response

  1. entity = Map();
  2. entity.put("id", 001);
  3. entity.put("name", "Helen");

  4. responseHeaders = Map();
  5. // add response headers if any

  6. customResponse = Map();
  7. customResponse.put("statusCode", 201);
  8. customResponse.put("contentType", "application/json");
  9. customResponse.put("responseHeaders", responseHeaders);
  10. customResponse.put("message", entity);

  11. return customResponse;

Response for the above script
Status Code: 201
Content Type: application/json
  1. {
  2.  "id": 001,
  3.  "name": "Helen"
  4. }

Failure Response

If the API execution fails, the response will be as follows:

Case 1:
Status Code: 412
Content Type: application/json
  1. {
  2.    "message": "Installation not found for given input."
  3. OR
  4.     "message": "Installation is in inactive state for given input."
  5. OR
  6.     "message": "App Version status is not allow function execution."
  7. etc
  8. }
 
Case 2:
Status Code: 500
Content Type: application/json
  1. {
  2.    "message": "Function execution failed"
  3. }

How to construct Invoke Function URL inside DRE function?

The input data object will be passed to DRE function. This object will have a property called sigma_execution_domain which holds sigma execution domain value. We can use this property to construct the Invoke Function URL.
  1. functionUUID = "46b39021-1234-1234-1234-b4a1683f9d0d";
  2. functionVersion = 3;

  3. invokeFunctionURL = "https://" + data.get("sigma_execution_domain") + "/workspace/invokefunction?sigma_function_uuid="+functionUUID+"&sigma_function_version="+functionVersion+"&integ_scope_id="+data.get("integ_scope_id")+"&app_install_id="+data.get("app_install_id")+"&auth_type=apikey&encapiKey="+data.get("encapiKey");

  4. ' use the invokeFunctionURL to register webhook on third-party tool, execute function, etc '

    Zoho CRM Training Programs

    Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

    Zoho CRM Training
      Redefine the way you work
      with Zoho Workplace

        Zoho DataPrep Personalized Demo

        If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

        Zoho CRM Training

          Create, share, and deliver

          beautiful slides from anywhere.

          Get Started Now


            Zoho Sign now offers specialized one-on-one training for both administrators and developers.

            BOOK A SESSION








                                    You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                        Manage your brands on social media

                                          Zoho Desk Resources

                                          • Desk Community Learning Series


                                          • Digest


                                          • Functions


                                          • Meetups


                                          • Kbase


                                          • Resources


                                          • Glossary


                                          • Desk Marketplace


                                          • MVP Corner


                                          • Word of the Day


                                            Zoho Marketing Automation

                                              Zoho Sheet Resources

                                               

                                                  Zoho Forms Resources


                                                    Secure your business
                                                    communication with Zoho Mail


                                                    Mail on the move with
                                                    Zoho Mail mobile application

                                                      Stay on top of your schedule
                                                      at all times


                                                      Carry your calendar with you
                                                      Anytime, anywhere




                                                            Zoho Sign Resources

                                                              Sign, Paperless!

                                                              Sign and send business documents on the go!

                                                              Get Started Now




                                                                      Zoho TeamInbox Resources



                                                                              Zoho DataPrep Resources



                                                                                Zoho DataPrep Demo

                                                                                Get a personalized demo or POC

                                                                                REGISTER NOW


                                                                                  Design. Discuss. Deliver.

                                                                                  Create visually engaging stories with Zoho Show.

                                                                                  Get Started Now









                                                                                                      • Related Articles

                                                                                                      • Triggers & Events

                                                                                                        Triggers are configured to invoke function blocks when specific events occur in the application or Zoho service. For example, you can trigger a welcome email to a user when your extension is installed. The mail notification function is configured in ...
                                                                                                      • Functions

                                                                                                        Functions are the building blocks for developing an extension. They come handy for all server side customization. Sigma executes functions without additional infrastructure cost. External function calls can be done using rest APIs. You have to ...
                                                                                                      • Create extensions using Zoho Sigma cloud editor

                                                                                                        Sigma has introduced a cloud editor where users can build extensions for Zoho services . Upon selecting a Zoho service, the corresponding service’s plug-in manifest file will be pre-populated into Sigma’s editor as a new project, eliminating the need ...
                                                                                                      • About Sigma

                                                                                                        As your company expands, you might add new business processes to your organization and recruit more employees. Having several tools to monitor the development will make managing the organization laborious. Also, if you have to juggle between many ...
                                                                                                      • Executions

                                                                                                        Executions tab displays the list of triggers executed in your extensions. Along with the trigger name and its version, you can also view the function to which the trigger is associated, start time of the execution, duration of the execution, and its ...
                                                                                                        Wherever you are is as good as
                                                                                                        your workplace

                                                                                                          Resources

                                                                                                          Videos

                                                                                                          Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                          eBooks

                                                                                                          Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                          Webinars

                                                                                                          Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                          CRM Tips

                                                                                                          Make the most of Zoho CRM with these useful tips.



                                                                                                            Zoho Show Resources