Share a Route with Multiple Recipients

See files for this Use Case on GitHub here

You can share a route with customers by email.

Description

Suppose you have several customers on one route and a customer wants to know about the shape of the route and what the delivery schedule looks like. With the Route4Me API, you can share the route with them directly via email.

Solution

Optimization Parameters and Addresses

Let's choose an Optimization Problem with 5 destinations, the Round Trip option, and these parameters:

ParameterTypeDescriptionHTTP method
api_keystringAPI KEY of the userGET
redirectintegerIf equal to 1, will be redirected, if 0 - notGET
addressesarrayValid JSON array of Address objects. Click here to see the JSON SchemaPOST
parametersRoute ParametersValid JSON string of RouteParameters object. Click here to see the JSON SchemaPOST

You can see the addresses on the map as:

Create an Optimization

The cURL example below shows you how to create new optimized routes for this Use Case:

ParameterTypeDescription
api_keystringAPI KEY of the user
input dataPOST dataValid JSON object string. Click here to see the JSON Schema
1 @ECHO OFF
2 
3 :: Single Depot, Multiple Driver, No Time Window
4 
5 ::See video tutorial here: http://support.route4me.com/route-planning-help.php?id=manual0:tutorial2:chapter2:subchapter1
6 
7 SET URL=https://www.route4me.com/api.v4/optimization_problem.php
8 SET apikey=11111111111111111111111111111111
9 SET route_path_output=Points
10 
11 ECHO ON
12 
13 curl -o file1.txt -g -X POST -k -d "@new_orders_existing_customer_optimization_data.json" "%URL%?api_key=%apikey%&route_path_output=%route_path_output%"
14 
15 timeout /t 30

You can expect an Optimization Problem (see link), which has generated two routes already.

View the Optimization details

You can get more details from the newly created Optimization Problem.

The endpoint: https://www.route4me.com/api.v4/optimization_problem.php

HTTP Parameters

AttributeTypeDescriptionHTTP
method
api_keystringAPI KEY of the userGET
optimization_problem_idstringOptimization problem IDGET


1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api.v4/optimization_problem.php
4 SET apikey=11111111111111111111111111111111
5 SET optprobid=49D8041BC3EDBA422B68E49F13768664
6 
7 ECHO ON
8 curl -o file1.txt -g -X GET -k "%URL%?api_key=%apikey%&optimization_problem_id=%optprobid%"
9 
10 timeout /t 30

See sample RESPONSE JSON data here

In the RESPONSE you can see an array of the addresses, which belong to 2 generated routes:

"route_id": "283B6FF6E41A6A1FA94CEE1E248DBD23",
"route_id": "8EC394C7D9639F694314D87ADAD1EDC8"

Let's choose the second route - which is longer and more complicated and therefore more likely to inspire inquiries from curious customers.

Details of the Chosen Route

You can get more details of this route.

The endpoint: https://www.route4me.com/api.v4/route.php

HTTP Parameters

AttributeTypeDescriptionHTTP
method
api_keystringAPI KEY of the userGET
route_idstringRoute IDGET
route_path_outputstringIf equal to 'Poitns', you'll get an array of the path points to next addressGET


1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api.v4/route.php
4 SET apikey=11111111111111111111111111111111
5 SET routeid=8EC394C7D9639F694314D87ADAD1EDC8
6 SET rpo=Points
7 
8 ECHO ON
9 
10 curl -o file1.txt -g -k -X GET "%url%?route_id=%routeid%&api_key=%apikey%&route_path_output=%rpo%"
11 
12 timeout /t 30

See sample RESPONSE JSON data here

Note
In the RESPONSE you can see the array of the fields path_to_next and use them to draw a route on a map, exactly as it is generated by the Route4Me API.

You can draw the generated route as:

Share the Route with Multiple Recipients

Now you can send information about the route to several customers.

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
recipient_email string A comma delimited list of e-mail addresses that will receive the shared route information. GET
response_format string Response format ENUM(NULL, 'xml', 'json', 'redirect') GET


Pay attention to the parameter recipient_email, which is where you can put a comma delimited list of e-mail addresses for the recipients.

1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/actions/route/share_route.php
4 SET apikey=11111111111111111111111111111111
5 SET routeid=8EC394C7D9639F694314D87ADAD1EDC8
7 SET response_format=json
8 
9 ECHO ON
10 
11 :: Example refers to the process of sharing a route by email
12 
13 curl -o file1.txt -g -X POST -k -H "Content-Type: multipart/form-data;" -F "recipient_email=%emails%" "%url%?api_key=%apikey%&route_id=%routeid%&response_format=%response_format%"
14 
15 timeout /t 30

You can expect this API response:

{"status":true}

And the recipients will receive the content in their email accounts:

As you can see, in the email there is detailed information about the route, including addresses, schedules, and directions. At the bottom of the email there is a button:

By clicking on this button, a recipient can start to edit the route on Route4Me's official website.

In fact, anyone who's reading this article can also press the button and start editing (as long as you're a registered user of Route4Me's web app, that is). Check it out!