How to add workflow actions in a Kylas marketplace app to perform automated actions?

How to add workflow actions in a Kylas marketplace app to perform automated actions?

This article covers the steps to enable Workflow actions in a marketplace app actions at the time of app creation so that the users of your marketplace application can use the actions to perform some marketplace actions automatically via Kylas workflows.

Prerequisites: 

Product Plan: Kylas elevate 
Permissions: Tenant user (the user who signed up on Kylas for the first time) 
Activities to be performed: A marketplace app should have been created as explained in the following article https://support.kylas.io/portal/en/kb/articles/how-to-create-a-marketplace-application 

Steps: 

Add workflow actions in the marketplace app: follow below steps to add/configure workflow actions in the marketplace app. 
  1. Navigate to the Step 4 of the marketplace app creation step as explained in the above article
  2. Click on + Add New App Action for add action. 
  3. Select the actions as Embedded Actions. Embedded action will be open in Kylas Itself. You can specific width and height as per your requirement. 
  4. Enter the Action Name and provide you application API/Target/Request URL in API URL where request will be sent with Query parameters. 
  5. Choose the toggles under Workflow category for the specific entity type that you want to create action for

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.  




Support the action in your marketplace app: When user clicks on Send WA Message, it will request to target URL which y ou have specified in API URL while configuring Marketplace Action with below parameters. 

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. 

  1. 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. 

  1. {
      "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,

  1. [
      {
        "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.

  1. {
      "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. 

    • Related Articles

    • How to add marketplace app trigger as a trigger event for Kylas workflow?

      This article covers the steps to perform in order to add a marketplace app trigger as the workflow trigger event. This will enable you to let a workflow get triggered by an external event taking place in a marketplace app and you can use this for ...
    • What are triggers in marketplace app and how to add triggers?

      This article covers the steps to take for adding triggers in marketplace application. What are triggers? Triggers in marketplace apps enables the app developers to trigger Kylas workflows based on an event that takes place in their application. And ...
    • How to setup Teams notifier app to send messages to MS teams channels via Kylas workflow?

      This article covers the steps to follow to setup MS Teams notifier application from Kylas marketplace to send MS Teams messages via Kylas workflows. Users can setup workflows to achieve use cases like below: Whenever a Lead or Deal is closed, ...
    • How to Send automated SMS via Kylas Workflows?

      This article covers the steps to be performed to send automated SMS to Leads or Contacts.  Prerequisites: Product Plans: Elevate  Activities to be completed: Kylas SMS app installed and configured to send manual SMS. Please refer the following ...
    • How to Create a Marketplace Application?

      Step 1: Go to Kylas Marketplace apps >> Manage Apps >>Create App · After Clicking on Create app, you will be asked to enter the required information o App Type :- you can either publish this app for private use or make it public o App Category: - ...