Dynamic CRM Embed actions

Use cases for dynamically changing the list of available actions

To enable actions in the CRM, you need to include the slugs of the actions in the appropriate webhook response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "app_objects": [
    {
      "id": "...",
      ...,
      "actions": [
        "open-document",
        "edit-document",
        "archive-document"
      ]
    }
  ],
  "actions": [
    "archive-all",
    "new-document"
  ]
}

Even though the actions must be defined ahead of time in the Dev Portal, you can dynamically change the list of available actions in each response.

Use case: Allowing only one object in the CRM

The CRM users will often want to create new objects associated with their contacts or deals from within the CRM. If you have business-specific constraints about the number of associated objects, you can disable actions based on the number of existing objects:

documents = load_documents_for_deal(request["record"]["id"])
actions =
  if is_empty(documents):
    ["new-document"]
  else:
    []

response = {
  "app_objects": build_app_objects(documents),
  "actions": actions
}

In the example above, we enable the "New Document" action in the CRM if the opportunity doesn't have an associated document already.

Use case: Disabling actions based on permissions

You can easily control which actions are available to certain CRM users based on their permissions:

user = fetch_user_by_email(request["crm_user"]["email"])
actions = filter_actions(ALL_ACTIONS, user.permissions)

response = {
  "app_objects": build_app_objects(documents),
  "actions": actions
}

Use case: Changing actions based on user settings

Certain actions can be implemented in multiple ways. For example, a "Show Details" action can be either a link or a modal action. You can define both variants in the Dev Portal and pick one based on user's settings:

user = fetch_user_by_context(request["platform_context"]["id"])
actions =
  if user.show_document_in_crm:
    ["open-in-crm"]
  else:
    ["open-in-app"]

response = {
  "app_objects": build_app_objects(documents),
  "actions": actions
}

Ready to build your CRM app?

Integrate every CRM with one build, request access to get started.