Listen to personalized podcasts and audio news timed to your Uber ride

Get in-the-know while you’re on the go — put your Uber on “Otto” pilot

Stanley Yuan
Uber Developers
5 min readNov 22, 2016

--

Otto Radio changes the way you listen to talk radio by curating playlists of audio stories personalized to your interests. You can get your own front page of news read to you and discover podcasts you’ll love — all with the push of a button. And now it’s easier than ever for Uber riders to keep up-to-date while they’re on the go with our Uber Trip Experience API integration.

To activate the Trip Experience, simply connect the two apps and the next time you request a ride with Uber, a playlist of news stories and podcasts perfectly timed to your trip will be waiting for you in your Otto Radio. No more wasted commutes and frustrating traffic jams. No more searching for something to read on your phone randomly. Otto Radio turns the time you spend on the go into a chance to learn, be entertained and stay informed about the things you care about most.

Otto Radio is a compelling example of how an app can leverage the Uber Trip Experiences API to differentiate their offering by giving users personalized podcasts and news timed to their ride.

Chris Saad, Head of Product, Uber Developer Platform

How does Otto Radio learn what you like?

Otto Radio crafts a truly personalized listening experience by analyzing a vast amount of data–whether expressed explicitly through your interest selections, implicitly based on how you interact with content or by matching you with content that other listeners with similar tastes have enjoyed. It also considers your travel patterns throughout the day so it can prepare the right amount of stories to cover your travel times. Since Otto Radio’s launch, user engagement has been incredibly strong, with each user tuning in to Otto Radio for ~40 minutes daily on average.

Bringing the Otto Radio Experience to Uber

The integration started with a natural product story — leveraging Otto Radio’s content curation capability to enrich the tens of billions of minutes spent in Uber rides. Otto Radio’s value proposition of delivering personalized audio news and podcasts with the push of a button is further enhanced thanks to the rich context offered by the Uber Trip Experiences API such as destination, pickup location, travel time, and UberPool status, if applicable. By closing the loop from making a ride request to streaming radio, Uber’s Trip Experience API boosts Otto Radio’s ability to deliver productive, educational and entertaining audio to more people on the go.

Implementation Details

Otto leverages multiple facets of the Trip Experiences API, but the core integration is facilitated by webhooks. Any time there is a new Uber trip, or a trip status changes, the Otto server gets an HTTPS POST to our webhook. Once this request comes in, we use the ‘/requests/current’ endpoint to get the full data about the current status, and alert the client of the change.

[NOTE: At the end of this article there is example code for basic handling of Uber webhook calls with an express.js server.]

That said, webhooks can only get us so far. Our webhook fires if there is a change in the Uber trip status (e.g. from no trip to processing request, or from driver arriving to on trip), but to be truly smart, Otto has to keep up for the entire Uber ride. Unexpected traffic, a detour to pick up an UberPool passenger, or a change in destination all impact the Otto experience and would be missed by listening to the webhook alone. To capture changes in the middle of a single state, the Otto server sets up a cron job to poll the ‘/requests/current’ endpoint once per minute while a user is on an active trip. This allows us to catch any changes to the ETA and tailor our user’s experience accordingly.

Once our server has detected a noteworthy event, a silent push notification is sent to the client containing the relevant data. The Otto client has two roles for the Trip Experience — calculating the correct ETA for the trip and displaying the correct information to the user. The client is tasked with calculating the ETA so that it can be in sync with the device’s clock, as well as to reduce some burden on the server. To calculate the ETA, we leverage a combination of the ‘/requests/current’, ‘/estimates/time’, and ‘/estimates/price’ endpoints, depending on the current trip status. For example, during the processing stage, we use the ‘/requests/time’ endpoint to get an ETA for when the driver will arrive, but the ‘requests/price’ endpoint to get an ETA for the entire trip. On the other hand, while the trip is in progress, we can get the ETA directly from the ‘/requests/current’ endpoint.

The goal for this integration was to turn every minute of your Uber ride into an opportunity to be entertained and stay informed, and the richness of the Trip Experience API makes that possible. Whether you’re a commute warrior or a visitor in a foreign city, Otto Radio makes it possible to have a personalized radio experience no matter where your journey takes you.

Download Otto Radio and put your next Uber on “Otto” pilot.

// from https://github.com/shernshiou/node-uber
var Uber = require(‘node-uber’);
// internal util file
var uberUtil = require(‘./uberutil.js’);
module.exports = function(app) {
// uber webhook
app.post(‘/uber/statuschanged’, function(req, res) {
if (!req.body.event_type ||
req.body.event_type !== ‘all_trips.status_changed’) {
// not from current version of API, safe to ignore
res.status(200).send();
return;
}
if (!req.body.meta || !req.body.meta.user_id) {
// can’t do anything without user_id
res.status(200).send();
return;
}
var uberId = req.body.meta.user_id; // internal function to get a uber user’s access token
// you will need to build this yourself
var userUberToken = uberUtil.getUberToken(uberId);
var uberClient = new Uber({
client_id: ‘’, // fill these in
client_secret: ‘’, // with your
server_token: ‘’, // appropriate values
access_token: userUberToken
});
// get full trip data
uberClient.requests.getCurrent(function (error, result) {
if (error) {
// returning 500 will resend to the webhook with a back off
res.status(500).send();
return;
}
// send push notification
// you will need to implement this yourself
uberUtil.sendPush(result);
res.status(200).send();
});
});
};

To get updates from the Uber Developer team in the future, follow our publication or follow us on Twitter.

Please tap or click “♥︎” to help to promote this story to others.

--

--

Stanley Yuan
Uber Developers

Builder and strategist by day, mathematician and economist by training, humanitarian at heart.