Salesforce Field Service Integration with Route Optimization API
Prerequisites
To successfully integrate Salesforce Field Service with NextBillion.ai, ensure you have the following prerequisites in place:
-
Salesforce Field Service Account Credentials: You will need valid credentials, including a username and password, to access your Salesforce Field Service account.
-
NextBillion.ai's API Key: Obtain an API key from NextBillion.ai, which serves as the authentication mechanism for accessing their services and data. This key is essential for secure and authorized communication between your systems and NextBillion.ai's APIs.
Generating Access Token
-
Create a Salesforce Account: Begin by setting up a Salesforce account if you haven't already.
-
Create a Custom App: Once your Salesforce account is established, create a custom application within the Salesforce platform.
-
Configure OAuth for Connection: Configure OAuth settings to establish a secure connection. Before testing the connection, keep these important considerations in mind:
-
Specify Callback URL: Ensure that you specify a valid callback URL.
-
Retrieve Consumer Key and Secret: Obtain your Consumer Key and Secret, which are essential for authentication.
-
-
Test the API Connection: Use Postman or a similar tool to test the API connection and generate the access token.
-
Generate API Access Token: After testing the connection successfully, generate the API access token.
-
Verify Basic CRUD Operations: Finally, verify that basic CRUD (Create, Read, Update, Delete) operations are functioning as expected using the generated access token.
Since the integration is not live in the Salesforce app, the following steps illustrate the approach used in Retool, a custom software development platform. A similar procedure may be followed once the NB.ai's Route Optimization API is integrated with Salesforce.
Populate Data from Salesforce
To enrich your Salesforce application, you need to populate the following key components:
Service Appointments
Import and integrate service appointment data from your Salesforce application.
Sample API Request
When the following cURL command is executed, it sends a GET request to Salesforce, which responds with the results of the specified query, typically in JSON format. This allows you to retrieve Salesforce data that matches the criteria defined in the query, which can then be used for integration purposes.
Sample API Response
The integrated dashboard will resemble the following image:
Service Resources
Likewise, ensure that service resource information is efficiently integrated and populated within your Salesforce environment. Retrieve a list of your Technicians, which represent your vehicles. This information will be used to optimize routes based on vehicle capacity and other parameters.
Sample API Request
Sample API Response
After successfully populating the data from Salesforce, your integerated dashboard will look something like this:
Integration with Route Optimization API
After successfully pulling the necessary data from Salesforce, integrate the fetched data with Route Optimization using the following API endpoint.
Map the fetched Salesforce data to the respective API parameters. Configure optimization settings such as shift start and end time, service time, and start and end location coordinates.
Once you have successfully retrieved the required data from Salesforce, the next step is to seamlessly integrate this data with the Route Optimization service using the provided API.
Follow these steps to achieve a successful integration:
Step 1: Define Data Structures
Begin by setting up the necessary data structures to facilitate the integration. These include arrays and variables for vehicles, shifts, start and end locations, vehicle attributes, and stop attributes.
Step 2: Configure Optimization Settings
Specify optimization settings to tailor the routing process to your specific needs. These settings typically include shift start and end times, service times, and the coordinates of start and end locations.
Step 3: Prepare Data for Route Optimization
Assemble the data required for route optimization. This involves creating arrays for locations, jobs, and shipments. Additionally, you'll populate the vehicle and job attributes as needed.
Step 4: Store Data and Trigger Optimization
Store the prepared data structures in local storage for future reference and initiate the route optimization process.
By following these steps, you can effectively connect and integrate Salesforce data with the Route Optimization API, ensuring efficient routing and resource allocation for your tasks or deliveries.
Create Jobs with Route Optimization API
This integration step showcases how to utilize NextBillion.ai's Route Optimization API to create optimization jobs, allowing for efficient route planning and resource allocation. The API response provides critical job information, enabling further interaction and tracking within the integration workflow.
POST Query
To create optimization jobs, a POST request is sent to the designated API endpoint using the curl command-line tool or an equivalent HTTP client.
API Request
The request payload contains essential information needed for the optimization job. It is structured as a JSON object and includes the following elements:
-
locations
: Specifies location data, including IDs, descriptions, coordinates, and time windows. -
jobs
: Defines job details, such as IDs, descriptions, location indices, service times, and time windows. -
vehicles
: Describes vehicle properties, including IDs, starting indices, time windows, and task capacities. -
options
: Specifies optimization settings, such as routing mode. -
result
: Initially set to null, as it awaits the response from the API.
API Response
Upon successfully processing the request, the API responds with a JSON object containing the following details:
Retrieving Optimized Route Result
To obtain the optimized route results after initiating a route optimization job, you can utilize the provided GET query. This query enables you to fetch the optimized route details from the Route Optimization API.
GET Query
In the above URL, two query parameters are used:
-
id
: This parameter specifies the unique identifier associated with the optimization job. It is obtained from thenbaiOptimizationRun.data.id
variable. -
key
: ThelocalStorage.values.apiKey
variable provides the API key necessary for authentication.
Example JSON Response
Upon making the GET request, the API will respond with a JSON object containing the optimized route details. Here's an example of what the JSON response may look like:
Accessing Optimized Routes in NextBillion.ai’s Optimizer
To visualize and analyze the optimized routes generated by NextBillion's Optimizer, you can use the following URL.
The above URL will take you to NextBillion's Optimizer interface where you can explore and interact with the optimized route results associated with your specific request ID and API key. This provides a convenient way to gain insights into your optimized routes for enhanced decision-making and resource management
By integrating Salesforce Field Service with NextBillion.ai's Route Optimization API, businesses can streamline field operations, reduce costs, and provide better service to customers. This integration enhances efficiency and competitiveness in the market, ultimately leading to improved customer satisfaction.