/ location based assignments

Build Uber-for-X within a day using HyperTrack

Uber’s business model has given rise to a large number of Uber-for-X services. Among other things X equals moving parking courier groceries flowers alcohol dog walking massages dry cleaning vets pharmacy car washes roadside assistance and marijuana. Through these on-demand platforms supply and demand are aggregated online for services to be fulfilled offline.

Core features for an Uber-for-X product

The following location features are at core of developing an Uber-for-X platform:

1. Location-based assignment

When the customer requests the service the platform needs to assign the request to a provider. The assignment decision involves multiple parameters and location is an important one. For example who is the nearest available provider who can service the customer in the shortest amount of time?

2. Live tracking experience

Once you assign the customer request to the provider the customer would expect to track the real-time location of the order within your product experience complete with a live ETA and status.

3. Alerts

The operations team expects to keep an eye on the network and ongoing movement. During service hours the team especially cares about delays and mishaps that need to be handled proactively. The customer might value getting notified when the provider is about to arrive or when the provider is running delayed.

4. Mileage

Lastly the platform incurs cost for the miles traveled by providers. Depending on the business model this is used to calculate charges to customers reimbursements to providers or direct costs to the platform. The ability to automatically and accurately generate mileage directly impacts revenue and cost.

In this tutorial we will walk through the steps to build these features using HyperTrack.

Step-by-step implementation

The implementation involves a driver app (used by the provider to service requests) a customer app (used by the customer to order) a dashboard (used by the operations team to provide a great service experience) and a server (to orchestrate the above in one beautiful dance).

1. Get HyperTrack keys

Sign up to get your secret and publishable keys. The secret key is used on the server for backend-to-backend communication. The secret key is authorized for all API calls – to create edit list retrieve and delete data. The publishable key is used by the SDKs in the apps. The publishable key is authorized for read-only API calls for select data entities.

2. Install SDK in driver app and start tracking (driver app)

Now install our lightweight SDK into the driver app. Call the startTracking method when the driver logs-in into the app or becomes available for work. When you do so the SDK starts collecting location and activity data in the background and transmits them to our server with near-zero battery impact.

After you have installed the SDK set up FCM or APNS to enable our server to communicate with your driver app. This helps us control the SDK from our server. Once you do so our server can get locations from the SDK on-demand make the SDK inactive to save battery and recover from app crashes.

3. Create actions (server)

When the customer orders the service at a location through the app your server would create an order in your system. You may break the order into multiple parts depending on the nature of the service . For example pickup and dropoff (cabs) pickup and delivery (food) or travel and appointment (home services).

Create corresponding actions (say PICKUP and DROPOFF) on HyperTrack one action per part that the order breaks into. Pass along the order ID from your system as the lookup_id in ours. This way you will be able to lookup query and view these actions using the order ID in your system.

4. Assign actions (server)

Next up you need to assign the actions created for your orders. Use live locations of your drivers to improve assignment decisions.Get live location of drivers ordered by proximity from customer location. Remember to use the action_id of the PICKUP action created above. Once you get the list of nearby drivers and have made your assignment decision assign both (PICKUP and DROPOFF) actions to that driver.

5. Track order (dashboard)

Now that you have assigned both (PICKUP and DROPOFF) actions to the driver you can track them on your own customer service or operations dashboards. Embed the following URL https://dashboard.hypertrack.com/widget/actions;lookup_id=<LOOKUP_ID>?key=sk_xxxx as an iFrame widget.

LOOKUP_ID is the lookup_id that you used in step #3 and sk_xxxx is your account’s secret key to authenticate the widget.

6. Set up live tracking of PICKUP action (customer app)

Now we will track the PICKUP action in the customer app. Follow one of these guides Android/iOS to setup the HyperTrack SDK in the customer app. Then call trackAction method to live track the action within your app. Remember to use the PICKUP action_id created in step #3 when calling the trackAction method to track the PICKUP. The customer app needs to be aware of this action_id. You might need to send it to the customer app from the server.

7. Set up webhooks to send alerts (server)

This is an optional step that you could implement if you decide to alert the operations team or the customer of events that happen along the way. You may send these alerts as push notifications emails or dashboard notifications to your operations team or app notifications or SMS to your customers. For example you may notify the customer when the driver is a minute away from the pickup location so the customer and driver are better prepared and neither needs to wait. Follow this guide to set up webhooks and receive such events.

8. Complete action (driver app)

Once the driver reaches the PICKUP location mark the PICKUP action as complete based on the respective action performed by the driver in the driver app. Call the completeAction method (Android/iOS/ReactNative) in the driver app for the PICKUP action_id.

9. Set up live tracking of DROPOFF action (customer app)

Now that the pickup is complete the customer might want to track the DROPOFF action in the app. In the customer app refresh the tracking view and call trackAction method (Android](https://docs.hypertrack.com/usecases/livetracking/android/installing.html#step-4-track-actions)/iOS) for the DROPOFF action_id created in step #3.

10. Complete DROPOFF action (driver app)

Once driver reaches the DROPOFF location mark the DROPOFF action as complete based on the respective action performed by the driver in the driver app. Call the completeAction method (Android,iOS,ReactNative) in the driver app for the DROPOFF action_id.

11. Get mileage (server)

Now that both the actions are complete you can get mileage for these actions on the server.

Well done!

You are now all set with awesome location features for your Uber-for-X service. You have built location-based assignment live tracking experience alerts and mileage.

Did this tutorial help you build what you wanted? Please share your experience and what you are building with HyperTrack. We would love to feature your story on our blog!