Example,
Action Name: Send WA Message
API URL: https://whatsapp.integrations.kylas.io/send-wa-message
Now, we have enabled the action for specific workflow as per your requirement.
Suppose, You Enabled workflow for Lead and Deal. Then action will be shown in Lead and Deal workflow when you/user install the application.
When a user installs the application, action will be shown in workflow, when user selects action type as Marketplace Actions, all actions should be displayed which is supported for that specific entity.
Now, when user selects required marketplace action, button will be shown with action name.
Eg. Send WA Message.
tenantId=1xxx (logged in user tenantId)
userId=3xxx (logged in user Id)
entityType=LEAD (Workflow Entity Type)
identifier=2.089744815252126 (Unique identifier)
In our case, we are showing form when iframe gets opened in the workflow, you can show/perform anything as per your requirement/case.
Suppose you are showing the form where certain things will be there in the iframe and then there is cancel and save(submit) button in form.
In simple term you want to cancel the activities when click on cancel button and in save(submit) you are saving activities in your side. But this things workflow doesn’t know about anything, as this all things are happening in iframe with respect to marketplace app side.
So, need to send certain things to update same in workflow. For this cross-origin communication, we are using below method, kindly refer this documentation to get more details.
https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
So, If I cancel the activities, below things need to be sent.
window.parent.postMessage( { payload: { closeMarketplaceIframe: true }, location: 'workflow', identifier: '2.089744815252126' }, 'https://app.kylas.io' )
In postMessage, function need to send parameters in above format.
window.parent.postMessage(arg1, arg2)
arg1: Object
payload: Object
location: 'workflow’
identifier: identifier (should be sent while request to your domain API/Request URL).
arg2: String
Kylas Domain.
In, arg1:
Identifier will be used for differentiating action. In one workflow, you can enter multiple marketplace actions for one marketplace app.
So, if marketplace app will be same and same action that tou are adding for perform different activities in same workflow, Identifier will be used for closing the specific pop-up (modal Iframe) in workflow page.
Payload should be sent same as it is mentioned above for closing action.
And for save(submit) action,
all saving logic is done in your marketplace application side, workflow doesn’t know about anything.
In this, case need to call postMessage function with same arguments and same format.
But the different activities are getting saved at your side and need to send different payload in arg1 in postMessage instead of just closing the pop-up (modal Iframe).
You are setting up marketplace action in workflow, means when certain conditions are matched successfully and workflow action is called, you need to take step/perform certain action in either in marketplace side or either in Kylas or anywhere.
So, this marketplace app needs to know about this.
For that, you need to send parameters like below.
As payload in object format.
{
"name": "any name",
"description": "any description",
"requestUrl": "your-marketplace-url-where-workflow-will-hit-send-values-you-set",
"method": "request-type-of-your-action",
"resourceId": "record-id",
"parameters": [
{
"name": "myUniqueIdentifier-any-name",
"entity": "CUSTOM",
"attribute": 193,
"isStandard": false
},
{
"name": "any-name",
"entity": "WORKFLOW_ENTITY_TYPE_MUST_BE_IN_CAPITAL",
"attribute": "internal_name_of_field",
"isStandard": false/true
},
{
"name": "any-name",
" entity ": "WORKFLOW_ENTITY_TYPE_MUST_BE_IN_CAPITAL",
"attribute": "internal_name_of_field",
"isStandard": false/true
}
]
}
** name/method/resourceId/requestUrl - required parameters - marketplace action is set in workflow.
Let’s understand about above payload.
name/description/requestUrl - All these things are based on your marketplace application. You can specify anything.
method: Request Type - In which format request (GET/POST) will be sent to you when workflow is called while certain conditions is matched, and action is called.
resourceId: Suppose you set workflow and marketplace action. Now you are coming back to same workflow and want to edit same action, then how your marketplace application knows, which activities you are editing. workflow will send this resourceId in parameters along with default four parameters which I mentioned earlier (tenantId, userId, entityType, identifier). And you can use this parameter value to identify record in your marketplace app.
parameters: when workflow is called on any specific entity. You need perform certain activities. If you need to workflow will send some values of that entity, then you need to set parameters for the same.
This should be in array of objects, which consists of four key-value.
attribute - when workflow is called/execute on entity, workflow will fetch this attribute value.
isStandard – true for standard (system field) and false for custom field/custom attribute
entity: must be same as workflow entity.
(If you think, how you know entity, then remember, we are sending parameter entityType with your Target/API URL, so you can persist/pass and configure that parameter value here. May be, you need to convert entityType value in Singular form and in Capital Letter.)
name: workflow will send this as key and processed value of attribute you set.
Example.
Suppose I sent parameters like,
[
{
"name": "myUniqueIdentifier",
"entity": "CUSTOM",
"attribute": 193,
"isStandard": false
},
{
"name": "variable_firstName",
"entity": "LEAD",
"attribute": "firstName",
"isStandard": true
}
]
When workflow will execute and will send values based on configurable URL and Method.
Like,
{ "myUniqueIdentifier": 193, "variable_firstName": "CRM Customer" }
myUniqueIdentifier is set as custom and attribute value is custom set, so we send back as it is. You will use as identifier If your marketplace has multiple records in same table and can be going to multiple actions for your application.
variable_firstName - I specified this name and workflow will send back as key and value is My Lead’s first name on which workflow is executed.
Please refer below screenshot/snippet for sample payload and more understanding.
{
"name": "Send automated whatsapp message",
"description": "This is used for sending automated whatsapp message via workflow",
"method": "POST",
"resourceId": 123,
"requestUrl": "https://whatsapp.integrations.kylas.io/deliver-via-workflow.json",
"parameters": [
{
"name": "myUniqueIdentifier", "entity": "CUSTOM",
"attribute": 123, "isStandard": false
},
{
"name": "entityId", "entity": "LEAD",
"attribute": "id", "isStandard": true
},
{
"name": "variable_firstName", "entity": "LEAD",
"attribute": "firstName", "isStandard": true
},
{
"name": "variable_cfCustomCity", "entity": "LEAD",
"attribute": "cfCustomCity", "isStandard": false
}
]
}
In your application, you can perform the desired action whenever the above payload is received on your request URL.