Salesforce Messaging agent availability

Overview

Set up a Salesforce Flow to retrieve agent availability and wait time attributes. Use these values to display information to end users or apply conditional logic before a Handoff to Salesforce.

Quick start

Complete these steps to set up agent availability checking. See Implementation & usage for detailed instructions.

1

Create an External Client App

Set up an External Client App in Salesforce with the Client Credentials Flow enabled.

2

Create a custom Flow

Build an Autolaunched Flow that checks queue availability and returns agent status.

3

Configure HTTP Request blocks in Ada

Add blocks to call the token endpoint and custom flow endpoint before the Handoff.

Implementation & usage

Configure Salesforce and Ada to check agent availability before Handoffs.

Set up the External Client App in Salesforce

Create an External Client App so Ada can authenticate and call the availability endpoint using client credentials.

To set up the External Client App:

  1. Go to Setup > App Manager, then click New External Client App.

  2. Under the basic details, complete the following fields:

    FieldNotes
    NameDisplayed in the App Manager. The API Name auto-fills from the name.
    Contact EmailThe contact email for Salesforce to use in the event of an error.
    Distribution StateSet to Local unless you are packaging the app.
  3. Expand the Enable OAuth section and select the Enable OAuth check box.

  4. In the Callback URL field, enter a value. The Client Credentials Flow does not redirect, so a placeholder such as https://localhost is sufficient.

  5. Under OAuth Scopes, add the scopes required for server-to-server API access. The Manage user data via APIs (api) scope is typically sufficient. The Perform requests at any time (refresh_token, offline_access) scope is not required, because the Client Credentials Flow does not issue refresh tokens.

  6. Select the Enable Client Credentials Flow check box.

  7. Save the app, then find it in the External Client App Manager. Select the dropdown, then select Edit Policies.

    The Client Credentials Flow requires an explicit Run As user assigned at the policy level.

  8. Under Client Credentials Flow, set the Run As user to your integration or service user, then click Save.

    Set the Run As user under Client Credentials Flow
  9. To retrieve your credentials, return to the External Client App Manager, select the dropdown, then select Edit Settings. Verify via email to reveal the Consumer Key (client ID) and Consumer Secret (client secret).

    Reveal the Consumer Key and Consumer Secret

Set up the Flow in Salesforce

Create a custom Flow to return queue availability and wait time attributes.

To set up the Flow:

  1. Go to Process Automation > Flows in Setup, and select New Flow

  2. Select Autolaunched Automations > Autolaunched Flow (No Trigger)

    New Process Automation
  3. Between the Start and End elements, select the + symbol and add an Action element, selecting the Check Availability for Routing action. Select the following options:

    Check Availability for Routing
    1. Service Channel: Messaging

    2. Check Availability for: Queue

    3. Queue > Use variable: {!queueId}

      You can also set a fixed queue with Select Queue.
    4. Select Output: Return all

    5. Check Manually assign variables

      • Add variables to the respective fields.

        Assign Variables
    6. On the upper left, select Toolbox and go to Manager > Resources > Variables.

      1. Ensure that queueId has Available for input selected.

      2. Ensure that the other variables (from Store Output Values) has Available for output selected.

        Store Output Variables

Set up the Handoff in Ada

Configure HTTP Request blocks in your Handoff to call the Salesforce endpoints.

To set up the Handoff:

  1. The token endpoint: Add an HTTP Request block to generate an access token for calling the flow endpoint. Store the Client ID and Client Secret in the token vault, and save the access_token as a sensitive variable.

    For example: https://**{{subdomain}}**.sandbox.my.salesforce.com/services/oauth2/token?grant_type=client_credentials&client_id=**{{salesforce_client_id}}**&client_secret=**{{salesforce_client_secret}}**

    Call Custom Endpoints
  2. The custom flow endpoint, called by adding the flow name to the URL and passing the access token as a bearer token in the request header.

    If you’re using a variable to select the queue, pass the id in the body using this key: inputs[0].queueId.

    For example: https://**{{subdomain}}**.sandbox.my.salesforce.com/services/data/v64.0/actions/custom/flow/**{{flow_name}}**.

    HTTP Request Block Setup

From there, you can store the relevant outputs using the key 0.outputValues.{{variableName}}. These values can then be used in conditional logic or surfaced to end users via a Text block before reaching the Salesforce Messaging Utils block.