---
schema_version: "1"
id: 9f857a406520aacd984d7bb4b8f063756c37071c51fb906749eaf2cc54522198
title: Dynamically Control Messaging Actions
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/service-cloud/messaging-byoc-ccaas/guides/control-messaging-actions.md
canonical_url: https://developer.salesforce.com/docs/service/messaging-byoc-ccaas/guide/control-messaging-actions.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: d51b5a813b1961fb772d003f13eb893f632c6409edc7d60a607ffd99a4179d67
products:
  - Bring Your Own Channel for CCaaS
  - Service Cloud Developer Content
---
# Dynamically Control Messaging Actions

Control what reps can or can’t do per Messaging session agentWork, according to your business needs. Enable or disable Messaging actions for a specific Bring Your Own Channel for CCaaS Messaging session. For example, turn on transfers for certain queues and turn off transfers for others.

**note:** Lighting App Builder settings for the Enhanced Conversation Component that hide controls take precedence over dynamically controlled Messaging actions. For example, if the transfer action in a Messaging session layout is hidden but transfers are enabled through Interaction Service API for that Messaging session agentWork, the transfer action isn’t visible to the rep.

1.  To create an AgentWork record when the system finds a rep to handle a work assignment, call the Interaction Service AgentWork API (`POST /api/v1/agentWork`).
2.  As part of the payload for the AgentWork API, include the optional `agentActionVisibilities` JSON object. This object specifies whether a particular action is enabled or disabled for the Messaging session agentWork using these parameters.

    - `agentAction`: Required. An enum that specifies which Messaging action is dynamically controlled. Options are `Transfer` and `Conference`.
    - `visible`: Required. A Boolean that indicates whether an action is enabled (`true`) or disabled (`false`). Although Messaging action buttons are visible if visible is `false`, they aren’t functional.

    Here are two example payloads. They differ based on whether a Pending Service Routing (PSR) record already exists when you call the AgentWork API.

    ```json
{
      "userId": "USER_ID",
      "workItemId": "WORK_ITEM_ID",
      "capacityWeight": CAPACITY_WEIGHT,
      "routingContext": {
        "conversationIdentifier": "CONVERSATION_ID",
         "routingType": "ROUTING_TYPE",
         "routingCorrelationId": "EVENT_ID"
    },
      "agentActionVisibilities": [{
        "agentAction": "Transfer",
        "visible": true
      }]
    }
```

    ```json
{
      "userId": "USER_ID",
      "workItemId": "WORK_ITEM_ID",
      "agentActionVisibilities": [{
        "agentAction": "Conference",
       "visible": false
      }]
    }
```

**See Also**

- [Interaction Service API](https://developer.salesforce.com/docs/service/interaction-service-api/guide/get-started.html)
- _GitHub_: [Interaction Service APIs](https://github.com/salesforce-misc/interaction-service-apis)
