A8Flow
a8flow lists the pre-built functions available to you in A8Studio.
Functions
Here, let's take a look at these Functions.
dedupe
Checks for duplicate values within active instances for the provided input variables.
- Method
- Usage
- Response
dedupe(request: DuplicateInstanceRequest): Promise<DuplicateInstanceResponse>
/* Checks for an instance associated with the Mobile Number "9876543210" and Name "John".
If found, it will return an array containing the corresponding "Details" and the OutVariable "aadhaarNo".
If not found, it will return an "Empty" array.*/
await a8flow.dedupe({
"variables": [
{
"name": "mobileNumber",
"value": "9876543210"
},
{
"name": "applicantName",
"value": "John"
}
],
"outVariables": ["aadhaarNo"]
});
{
"duplicateInstance": true,
"processInstances": [
{
"id": "7812a293-2801-11ef-b709-022be0dae595",
"processDefinitionKey": "deepika_testingAssisted",
"status": "ACTIVE",
"startTime": "2024-06-11T14:47:04.635Z",
"duplicateVariables": [
{
"variableName": "startedBy",
"createdAt": "2024-06-11T14:47:04.635Z"
},
{
"variableName": "mobileNumber",
"createdAt": "2024-06-11T14:48:30.525Z"
}
],
"outVariables": [
{
"variableName": "aadhaarNo",
"value": "459329057159",
"createdAt": "2024-06-11T14:48:30.525Z"
}
]
}
]
}
deeplink
Generates a shortened URL that allows direct access to a specific task within the application.
- Method
- Usage
- Response
deeplink(taskDefKey?: string): Promise<string>
/* taskDefKey (String): The unique identifier for the task definition.
This key specifies the task that the generated link will point to. */
await a8flow.deeplink("Activity_0mzgt28")
{
"shortenUrl": "https://a8s.app/OE2VW0"
}
evaluateDMN
Evaluates the business rule for the provided variables in the specified DMN.
- Method
- Usage
- Response
evaluateDMN(key: string, data: any): Promise<any>
/* Executes a DMN named 'tradin' with the specific variable 'typeofBusiness';
a "String" with the value taken from 'params.app_Emp_Trader'.*/
await a8flow.evaluateDMN('tradin',{
"variables": {
"typeofBusiness": {
"type": "String",
"value": params.app_Emp_Trader
}
}
});
eventLogger
A custom logger for generating logs of specific events.
- Method
- Usage
- Response
eventLogger(request: EventLoggerRequest): Promise<boolean>
/* Creates a log entry for the "Loan Application Status" - for,
a user with the corresponding UserID "0000000000" and Mobile No "9876543210".*/
await a8flow.eventLogger({
userId: "0000000000",
eventName: "loanApplicationStatus",
properties: { "mobile": 9876543210 }
})
true
generateSequenceId
Generates "Sequential Values" for the App.
Note: On giving a "tag", it generates the SequenceID with respect to this tag. However, the "tag" is an optional parameter.
- Method
- Usage
- Response
generateSequenceId(request: GenerateSeqIdRequest): Promise<GenerateSeqIdResponse>
// Generates a "Sequence ID" with respect to the "approval" tag.
await a8flow.generateSequenceId({
tag: "approval"
})
{
"sequenceId": 1
}
getGroupById
Returns details of the given GroupID.
- Method
- Usage
- Response
getGroupById(groupId: string): Promise<groupResponse[]>
// Returns details of the "admin" GroupID.
await a8flow.getGroupById("web");
{
"id": "web",
"name": "Web Users",
"type": "SYSTEM",
"metadata": {
"smsNotification": false,
"location": true,
"dashboards": null
}
}
getGroups
Returns a list of all the available Groups.
- Method
- Usage
- Response
getGroups(): Promise<groupResponse[]>
// Returns a list of all the available groups.
await a8flow.getGroups();
[
{
"id": "web",
"name": "Web Users",
"type": "SYSTEM",
"metadata": {
"smsNotification": false,
"location": true,
"dashboards": null
}
},
{
"id": "mobile",
"name": "Mobile Users",
"type": "SYSTEM",
"metadata": {
"smsNotification": false,
"location": true,
"dashboards": null
}
},
{
"id": "general",
"name": "General",
"type": "Solo Assistance",
"metadata": {
"smsNotification": false,
"location": false,
"dashboards": []
}
},
]
getGroupsByUserID
Retrieves a list of groups the user belongs to, identified by their user ID.
- Method
- Usage
- Response
getGroupsByUserId(userId: string): Promise<groupResponse[]>
// Returns the list of groups the user 'Kenny' (userID: KHJKL5678) is a part of.
request - await a8flow.getGroupsByUserId('KHJKL5678')
[
{
"id": "web",
"name": "Web Users",
"type": "SYSTEM",
"metadata": {
"smsNotification": false,
"location": true,
"dashboards": null
}
},
{
"id": "mobile",
"name": "Mobile Users",
"type": "SYSTEM",
"metadata": {
"smsNotification": false,
"location": true,
"dashboards": null
}
},
]
getLoggedInUser
Returns the ID of the currently "Logged In" User.
- Method
- Usage
- Response
getLoggedInUser(): Promise<getLoggedInUserResponse>
// Returns the name of the currently logged-in user.
await a8flow.getLoggedInUser()
"john_johnson"
getNextAvailableAgent
Lists the next available "agent" (user) in the group with access to the process based on the provided algorithm (roundRobin or mostIdleAgent).
Note:
roundRobin
- schedules the process in a circular order without prioritizing individual users in the group.mostIdleAgent
- schedules the process to the user with the least number of tasks within the group.
Optionally, you also have a "tag" parameter.
- Method
- Usage
- Response
getNextAvailableAgent(req: IntelligentRouteRequest): Promise<IntelligentRouteResponse>
/* Lists the next available user in the group "admin" with access to the process with the "processMigration"
definitioKey.
And the roundRobin algorithm schedules the process in a circular order to the users with the "approver" tag.*/
await a8flow.getNextAvailableAgent({
groupId: "admin",
processDefinitionKey: "processMigration",
algorithm: "roundRobin",
tag: "approver",
});
{
"agentId": "ranjith_kumar"
}
getProcessDefinitions
Returns a list of the latest process definitions.
- Method
- Usage
- Response
getProcessDefinitions(): Promise<processDefinitionResponse[]>
// Returns a list of the latest process definitions.
await a8flow.getProcessDefinitions();
[
{
"id": "44f30edf-af78-11ee-8058-ea7a2b972880",
"key": "ranjithkumar_new-component_Live",
"category": "http://bpmn.io/schema/bpmn",
"name": "new-component (live)",
"version": 2,
"resource": "new-jour.bpmn",
"deploymentId": "44cd375c-af78-11ee-b768-06e9bafa0f52",
"diagram": null,
"suspended": 1,
"tenantId": null,
"versionTag": null,
"historyTimeToLive": 150,
"displayName": "new-component (live)",
"startableInTasklist": true
},
{
"id": "47fb0715-3a67-11ee-bf5d-06e9bafa0f52",
"key": "saravanan_soft_deletions_check_Live",
"category": "http://bpmn.io/schema/bpmn",
"name": "soft_deletions_check (live)",
"version": 1,
"resource": "soft_deleteion_flow.bpmn",
"deploymentId": "47f89612-3a67-11ee-bf5d-ea7a2b972880",
"diagram": null,
"suspended": 1,
"tenantId": null,
"versionTag": null,
"historyTimeToLive": 150,
"displayName": "soft_deletions_check (live)",
"startableInTasklist": true
}
]
getSignedURL
It generates signed URLs for a provided list of URLs. These signed URLs allow access to the original resources for a predefined time period.
- Method
- Usage
- Response
getSignedURL(request: SignedURLRequest): Promise<{[key: string]: string;}>
await a8flow.getSignedURL({
// expTimeInMinutes (Number): Required. The number of minutes the signed URLs should remain valid.
// urlList (Object): Required. A object where the keys are identifiers for the URLs and the values are the actual URLs that need to be signed.
expTimeInMinutes:10,
urlList:{
"aadhar":"https://.../03c243a6-7b56-42bf-b78a-1181d9df575a",
"pan":"https://.../03c144b6-7b46-42af-b09c-1181d99kju55a",
}
})
{
"aadhar": "https://.../03c243a6-7b56-42bf-b78a-1181d9df575a?...X-Goog-SignedHeaders=host&X-Goog-Signature=ad7a8f509be7dd0fb9dce9f07ac6916611ef7aac070ac00d61cc02ec1acfd1d90998c2c991f03b0ccdaebf1dd93f408848a9afd0877d179c4521d1e0a2cb7044ffeda5b5f055288c70e88ea12aa8616bd0c2b73062ac9ecf0f5e2228e9ac9e6577ef6178c39fadcf8b03aab88c2a71bbb8de5a88d09b856a7326a5e9eea2e6a3bdff99c000a3a58655580639a66ae3709a893e9c4b092efa75613a2e19fe8665a14c4c21766d48",
"pan": "https://.../03c144b6-7b46-42af-b09c-1181d99kju55a?...X-Goog-SignedHeaders=host&X-Goog-Signature=35b3f7251dbcc219112ab9f70551eb2a9c587e91a26803cb2dc44e5ca1da5349508022fb4b8d8a0af4809a4db485386cd08825cd561d220a19d51d4305bdd8fbc02e83f38968b8b4a43841f31d7269fba9bc0874c8878904eb7d51da7b3224dae117a84a1ccb5eabf54d8ae62c7f10609292a1be8aef11f2a5d84aa05be0eb52414a59a0db3a07f38e0765ebbad11531e18d891842c012b4174ab551647c125635f2e34b9737ca",
}
getUserById
Returns details of the given user ID.
- Method
- Usage
- Response
getUserById(userId: string): Promise<userResponse[]>
// Returns the user details of "john_johnson".
await a8flow.getUserById("john_johnson");
[
{
"id": "john_johnson",
"firstName": "John",
"lastName": "Johnson",
"email": "john.johnson@autonom8.org",
"mobileNumber": "9876543210",
"passwordUpdatedAt": null,
"metadata": {
"userLanguage": "en-IN"
},
"is2fa": false,
"lastLogin": "2024-06-02T16:16:00.952406Z",
"forcePasswordChange": false
}
]
getUsers
Returns a list of all the available users.
- Method
- Usage
- Response
getUsers(): Promise<userResponse[]>
// Returns a list of all the available users.
await a8flow.getUsers();
[
{
"id": "john_johnson",
"firstName": "John",
"lastName": "Johnson",
"email": "john.johnson@autonom8.org",
"mobileNumber": "9876543210",
"passwordUpdatedAt": null,
"metadata": null,
"is2fa": false,
"lastLogin": null,
"forcePasswordChange": false
},
{
"id": "user_one",
"firstName": "User",
"lastName": "One",
"email": "user.one@mail.com",
"mobileNumber": "9999999999",
"passwordUpdatedAt": null,
"metadata": null,
"is2fa": false,
"lastLogin": null,
"forcePasswordChange": false
},
]
getUsersByGroupId
Returns the "User-List" for the given GroupID.
- Method
- Usage
- Response
getUsersByGroupId(groupId: string): Promise<userResponse[]>
// Returns the list of users for the "admin" GroupID.
await a8flow.getUsersByGroupId("admin");
[
{
"id": "super_admin",
"firstName": "Super",
"lastName": "Admin",
"email": "superadmin@autonom8.com",
"mobileNumber": null,
"passwordUpdatedAt": null,
"metadata": {},
"is2fa": false,
"lastLogin": null,
"forcePasswordChange": false
},
{
"id": "john_johnson",
"firstName": "John",
"lastName": "Johnson",
"email": "john.johnson@autonom8.org",
"mobileNumber": "9876543210",
"passwordUpdatedAt": null,
"metadata": null,
"is2fa": false,
"lastLogin": null,
"forcePasswordChange": false
},
]
sendMail
This Method allows for sending emails with the specified content to designated recipients. It offers customization of the email's subject, body, and SMTP details for sending. The SMTP details are optional and, if provided, are given priority.
- Method
- Usage
- Response
sendMail(request: SendMailRequest): Promise<any>
a8flow.sendMail({
// to (Array of Strings): Required. A list of recipient email addresses.
// cc (Array of Strings): Optional. A list of carbon copy (cc) recipient email addresses.
to: ["deepika@example.com"],
// subject (String): Required. The subject of the email.
subject: "Loan Approval",
// body (String): Required. The HTML content of the email body.
body: `<p>Hello!</p>
<p> Deepika, your loan application is waiting for your approval.</p>
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<td>
<table cellspacing="0" cellpadding="0">
<tr>
<td style="border-radius: 2px;" bgcolor="#ED2939">
<a href="https://a8s.app/PxVN9E" target="_blank" style="padding: 8px 12px; border: 1px solid #ED2939;border-radius: 2px;font-family: Helvetica, Arial, sans-serif;font-size: 14px; color: #ffffff;text-decoration: none;font-weight:bold;display: inline-block;">
Approve / Reject
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>`,
// smtpDetails (Object): Optional. Details of the SMTP server to use for sending the email. If provided, these details take priority.
// host (String): The SMTP server host.
// port (Number): The port number to use for the SMTP server.
// ssl (Boolean): Whether to use SSL for the SMTP server.
// senderEmail (String): The sender's email address.
// senderEmailPassword (String): The password for the sender's email account.
smtpDetails: {
"host": "smtp.gmail.com",
"port": 465,
"ssl": true,
"senderEmail": "noreply@example.com",
"senderEmailPassword": "********",
}
})
{
"message": "email sent"
}
sendMessage
Sends a message to the process engine. It either triggers a new message start event or creates an intermediate message catching event in an ongoing process.
All message events are named and may carry additional data (payload).
Note: Unlike a signal, a message event is always directed at a single recipient.
- Method
- Usage
- Response
sendMessage(request: SendMessageRequest): Promise<boolean>
/* Helps trigger a message event named "New_Applicant_Verification" along with the processVariables
(john_johnson) needed for the event.*/
await a8flow.sendMessage({
messageName: "New_Applicant_Verification",
processVariables: {name:"john_johnson"}
});
true / false
setDueDateAndFollowUpDate
Sets the delivery and follow-up dates for a particular task.
- Method
- Usage
- Response
setDueDateAndFollowUpDate(request: setDueDateAndFollowUpDateRequest): Promise<any>
// Sets the Delivery Date as "2022-01-01" and Follow-Up Date as "2024-01-31".
await a8flow.setDueDateAndFollowUpDate( {
due: "2024-01-01T00:00:00.000+0000",
followUp: "2024-01-31T00:00:00.000+0000"
});
204 - No Content
startNewProcessInstance
Starts a new process instance for the given "process definition key".
Note: Variables field is optional. If supplied, the instance will start with the provided variables; else, without it.
- Method
- Usage
- Response
startNewProcessInstance(request: startNewProcessInstanceRequest): Promise<startNewProcessInstanceResponse>
/* Starts a new process instance for the given "process definition key" (Loan_Approval) with the provided
variable values ("FirstName: deepika", & "Age: 23").*/
await a8flow.startNewProcessInstance({
procDefKey: "Loan_Approval",
variables: {
FirstName: { "value": "deepika" },
age: { "value": 23 },
}
});
{
"message": "Successfully started new instance"
}