Get Appointment Candidates

A service resource represents an employee from your organization, such as a loan officer, investment advisor, doctor, nurse practitioner, or retail store specialist, who attends appointments with clients. Use the getAppointmentCandidates REST API to fetch the available service resources based on work type group and service territory.

  1. Create a page in your app where you can show the available service resources based on the work type group and service territory.

  2. Make a POST request on the getAppointmentCandidates REST API by passing the required workTypeGroupId and territoryIds parameters.

    Resource URI

    1https://yourInstance.salesforce.com/services/data/vXX.X/scheduling/getAppointmentCandidates

    For an Existing User (Account)

    To consider an existing user’s preferred visiting hours, pass accountId in the input request body. The preference is enforced when the Include Only Required Service Resources and Ignore Excluded Service Resources policy rules are enabled. See Scheduling Policy Rules in Salesforce Scheduler.

    Sample Request

    1{
    2   "startTime" : "2023-11-01T09:00:00.000+0000",
    3   "endTime" : "2023-11-25T19:00:00.000+0000",
    4   "accountId" : "001S7000001pFlJIAU",
    5   "workTypeGroupId" : "0VSS700000000sVOAQ",
    6   "territoryIds" : ["0HhS700000001DYKAY"],
    7   "engagementChannelTypeIds": [
    8    "0eFS70000004CG5MAM"
    9  ]
    10}

    Sample Response

    The API returns the available time slots and service resources.

    1{
    2  "candidates": [
    3    {
    4      "endTime": "2023-11-24T18:00:00.000+0000",
    5      "engagementChannelTypeIds": [
    6        "0eFS70000004CG5MAM"
    7      ],
    8      "resources": [
    9        "0HnS700000002jAKAQ"
    10      ],
    11      "startTime": "2023-11-24T17:00:00.000+0000",
    12      "territoryId": "0HhS700000001DYKAY"
    13    },
    14    {
    15      "endTime": "2023-11-24T18:15:00.000+0000",
    16      "engagementChannelTypeIds": [
    17        "0eFS70000004CG5MAM"
    18      ],
    19      "resources": [
    20        "0HnS700000002jAKAQ"
    21      ],
    22      "startTime": "2023-11-24T17:15:00.000+0000",
    23      "territoryId": "0HhS700000001DYKAY"
    24    },
    25    {
    26      "endTime": "2023-11-24T18:30:00.000+0000",
    27      "engagementChannelTypeIds": [
    28        "0eFS70000004CG5MAM"
    29      ],
    30      "resources": [
    31        "0HnS700000002jAKAQ"
    32      ],
    33      "startTime": "2023-11-24T17:30:00.000+0000",
    34      "territoryId": "0HhS700000001DYKAY"
    35    },
    36    {
    37      "endTime": "2023-11-24T18:45:00.000+0000",
    38      "engagementChannelTypeIds": [
    39        "0eFS70000004CG5MAM"
    40      ],
    41      "resources": [
    42        "0HnS700000002jAKAQ"
    43      ],
    44      "startTime": "2023-11-24T17:45:00.000+0000",
    45      "territoryId": "0HhS700000001DYKAY"
    46    },
    47    {
    48      "endTime": "2023-11-24T19:00:00.000+0000",
    49      "engagementChannelTypeIds": [
    50        "0eFS70000004CG5MAM"
    51      ],
    52      "resources": [
    53        "0HnS700000002jAKAQ"
    54      ],
    55      "startTime": "2023-11-24T18:00:00.000+0000",
    56      "territoryId": "0HhS700000001DYKAY"
    57    },
    58    {
    59      "endTime": "2023-11-24T19:15:00.000+0000",
    60      "engagementChannelTypeIds": [
    61        "0eFS70000004CG5MAM"
    62      ],
    63      "resources": [
    64        "0HnS700000002jAKAQ"
    65      ],
    66      "startTime": "2023-11-24T18:15:00.000+0000",
    67      "territoryId": "0HhS700000001DYKAY"
    68    },
    69    {
    70      "endTime": "2023-11-24T19:30:00.000+0000",
    71      "engagementChannelTypeIds": [
    72        "0eFS70000004CG5MAM"
    73      ],
    74      "resources": [
    75        "0HnS700000002jAKAQ"
    76      ],
    77      "startTime": "2023-11-24T18:30:00.000+0000",
    78      "territoryId": "0HhS700000001DYKAY"
    79    }
    80  ]
    81}

    For a Guest User (Lead)

    Sample Request

    1{
    2   "startTime" : "2023-11-01T09:00:00.000+0000",
    3   "endTime" : "2023-11-25T19:00:00.000+0000",
    4   "workTypeGroupId" : "0VSS700000000sVOAQ",
    5   "territoryIds" : ["0HhS700000001DYKAY"],
    6   "engagementChannelTypeIds": [
    7    "0eFS70000004CG5MAM"
    8  ]
    9}

    Sample Response

    The API returns the available time slots and service resources.

    1{
    2  "candidates": [
    3    {
    4      "endTime": "2023-11-24T18:00:00.000+0000",
    5      "engagementChannelTypeIds": [
    6        "0eFS70000004CG5MAM"
    7      ],
    8      "resources": [
    9        "0HnS700000002jAKAQ"
    10      ],
    11      "startTime": "2023-11-24T17:00:00.000+0000",
    12      "territoryId": "0HhS700000001DYKAY"
    13    },
    14    {
    15      "endTime": "2023-11-24T18:15:00.000+0000",
    16      "engagementChannelTypeIds": [
    17        "0eFS70000004CG5MAM"
    18      ],
    19      "resources": [
    20        "0HnS700000002jAKAQ"
    21      ],
    22      "startTime": "2023-11-24T17:15:00.000+0000",
    23      "territoryId": "0HhS700000001DYKAY"
    24    },
    25    {
    26      "endTime": "2023-11-24T18:30:00.000+0000",
    27      "engagementChannelTypeIds": [
    28        "0eFS70000004CG5MAM"
    29      ],
    30      "resources": [
    31        "0HnS700000002jAKAQ"
    32      ],
    33      "startTime": "2023-11-24T17:30:00.000+0000",
    34      "territoryId": "0HhS700000001DYKAY"
    35    },
    36    {
    37      "endTime": "2023-11-24T18:45:00.000+0000",
    38      "engagementChannelTypeIds": [
    39        "0eFS70000004CG5MAM"
    40      ],
    41      "resources": [
    42        "0HnS700000002jAKAQ"
    43      ],
    44      "startTime": "2023-11-24T17:45:00.000+0000",
    45      "territoryId": "0HhS700000001DYKAY"
    46    },
    47    {
    48      "endTime": "2023-11-24T19:00:00.000+0000",
    49      "engagementChannelTypeIds": [
    50        "0eFS70000004CG5MAM"
    51      ],
    52      "resources": [
    53        "0HnS700000002jAKAQ"
    54      ],
    55      "startTime": "2023-11-24T18:00:00.000+0000",
    56      "territoryId": "0HhS700000001DYKAY"
    57    },
    58    {
    59      "endTime": "2023-11-24T19:15:00.000+0000",
    60      "engagementChannelTypeIds": [
    61        "0eFS70000004CG5MAM"
    62      ],
    63      "resources": [
    64        "0HnS700000002jAKAQ"
    65      ],
    66      "startTime": "2023-11-24T18:15:00.000+0000",
    67      "territoryId": "0HhS700000001DYKAY"
    68    },
    69    {
    70      "endTime": "2023-11-24T19:30:00.000+0000",
    71      "engagementChannelTypeIds": [
    72        "0eFS70000004CG5MAM"
    73      ],
    74      "resources": [
    75        "0HnS700000002jAKAQ"
    76      ],
    77      "startTime": "2023-11-24T18:30:00.000+0000",
    78      "territoryId": "0HhS700000001DYKAY"
    79    }
    80  ]
    81}
  3. Parse the JSON response, and show the available service resources on the page so that the user can select a primary service resource.

    Here’s how a Select Service Resource page can look.

    A representation of the Select Service Resource screen.

    Here’s how a page can look when the user selects a primary service resource.

    A representation of the Select Service Resource screen with the primary resource selected.

On the next page in your app, show the selected primary resource. You can also show the other service resources, including assets, so that users can add them as required resources. Then, show the consolidated time slots for all the selected resources.