API call to initiate a workflow

API end-point to send request

https://staging-workflow-api.leena.ai/v2/bot/:botId/app/:appId/external/init

  1. Under the API, the base URL can change basis the region of deployment. Following are the region and the corresponding URL for the end-point.
  2. Under the URL you would have to pass the Bot ID of your instance, and the particular app ID or Identifier, which needs to be initiated. These details can be found under the URL of the particular workflow app, and Identifier for a particular app is the one that is created by you.

Authentication

Internal Leena AI authentication mechanisms are supported under this, which is:

  1. X-app-secret
  2. Bot user token

To initiate a workflow via an REST API, we can use Leena AI connector (web-hook/REST API) with auth type = 'Leena AI x-app-secret'.

Request body

Certain pointers are to be kept in mind, while drafting the request body:

Request body Key

Description

userId

The user Id/Employee Id of the user who would be the initiator of the request. The user added here would become the Initiator of the request.

formData

The form fields added under the form which is mapped under 'Initiator Input' node are to be passed under 'formData' root key.

Under the sample JSON, you can view that if the form has fields with IDs 'name', 'email', 'leaves', then correspondingly the values for these keys have been passed.

formDataLabel

This root key handles all the dropdown fields (which have been configured under the form)

formDataLabel > Dropdown field ID

Pass the Field ID for which we need to pass the value

formDataLabel > Dropdown field ID > Label, Value

Pass the options' label, value for the particular dropdown field. For example, 'Leave Type' under the below example is the field ID of the dropdown field. We have passed 'label' and 'value' for the option which needs to be passed in the request.

Sample

{

 "userId": "cand-001028",

 "formData": {

 "name": "Test Name",

 "email": "[email protected]",

 "leaves": 20

},

 "formDataLabel": {

 "LeaveType": [

{

 "label": "SickLeave", "value": "SL"

},

{

 "label": "CasualLevae", "value": "CL"

}

],

 "leave type":

{

 "label": "Casual leave", "value": "SL"

} 

}

}