NEXT time you stop for petrol at a self-serve pump, say hello to the robot in front of you. Its life story can tell you a lot about the robot economy roaring toward us like an EF5 tornado on the prairie.

Yeah, your automated petrol pump killed a lot of jobs over the years, but its biography might give you hope that the coming wave of automation driven by artificial intelligence (AI) will turn out better for almost all of us than a lot of people seem to think.

The first crude version of an automated petrol-delivering robot appeared in 1964 at a station in Westminster, Colorado. Short Stop convenience store owner John Roscoe bought an electric box that let a clerk inside activate any of the pumps outside.

Self-serve pumps didn’t catch on until the 1970s, when pump-makers added automation that let customers pay at the pump, and over the next 30 years, stations across the world installed these task-specific robots and fired attendants.

By the 2000s, the petrol attendant job had all but disappeared. The loss of those jobs was undoubtedly devastating for the individuals who had them, but the broader impact has been pretty positive for the rest of us.

As has happened throughout the history of automation, some jobs got destroyed by automated petrol pumps, but new and often better jobs were created. Attendants went away, but to make the sophisticated pumps, companies hired software coders, engineers, sales staff, and project managers.

Station owners took their extra profits and turned their stations into mini-supermarkets, which needed clerks, and built more petrol stations, which needed more pumps and those companies then hired more people.

Consumers spent less money on petrol because they weren’t paying for someone else to pump it. That left them more money for iPhones or fish tacos ordered on Seamless, creating more new kinds of employment.

A generation of petrol station attendants got smoked, but the automation sent some clear signals that relying on such unskilled jobs isn’t a great career plan. Those signals led to more parents encouraging their kids to go to college.

In 1970, 14% of men in the US held four-year college degrees, and 8% of women did. By 2015, that was up to 32% of men and women. So over time, we took hundreds of thousands of people out of the pool of those who might want a petrol station attendant job and pushed them up, toward the professional job market, adding a lot of value to society and their wallets.

While technology is partly responsible for years of middle-class wage stagnation, it has mostly hurt the less educated and helped the more educated.

Economists have shown time and again that automation helps overall standards of living rise, literacy rates improve, average lifespans lengthen and crime rates fall.

After waves of automation — the Industrial Revolution, mechanization, computerization — we’re way better off in almost every way. As Matt Ridley details in his book The Rational Optimist, in 1900, the average American spent $76 out of every $100 on food, clothing and shelter; today, he or she spends $37.

To buy a Model T in 1908 took about 4,700 hours of work; today, the average person has to work about 1,000 hours to buy a car that’s a thousand times better than a Model T.

The United Nations estimates that poverty was reduced more in the past 50 years than in the previous 500. If progress has been less kind to the lower end of the workforce, it still helps that segment live better than before, at least by making products more affordable and better at the same time.

And now, even with software automating all kinds of work, there are signs that the technology is creating more jobs than it destroys.

Nearly 3m jobs were created from 2014 to 2015. Donald Trump won the presidential election by promising to bring jobs “back” to America — a promise believed by many who feel left behind by technology-driven shifts. Yet all evidence suggests that the jobs lie ahead, created by moving forward.

It’s hard to see how anyone could argue that we’d be better off today if Roscoe had never installed his automated device.

This is the scary part of the story.

Within maybe five years, AI will be better than humans at diagnosing medical images and better than legal assistants at researching case law, Surya Ganguli, a leading AI scientist at Stanford University, tells me.

Hawkins says we will eventually make machines that are great mathematicians. “Mathematicians try to figure out proofs and mathematical structure and see elegance in high-dimensional spaces in their heads,” he says.

“That’s not a ‘human’ thing. You can build an intelligent machine that is designed for that. It actually lives in a mathematical space, and its native behaviours are mathematical behaviours. And it can run a million times faster than a human and never get tired. It can be designed to be a brilliant mathematician.”

If you do something predictable and rote, then some time in the next 10 years you’ll probably feel like a petrol pump jockey, circa 1980.

One by one, companies will eliminate or marginalise your work. It will happen to the least educated first and fastest, hitting drivers, waiters, factory workers, and office administrators.

Then the robotisation of work will eat into more knowledge-based jobs. Low-level accounting will get eaten by software. So will basic writing: Bloomberg already uses AI to write company earnings reports.

Robots today can be better stock traders than humans. It won’t be long before you’ll be able to contact an AI doctor via your smartphone, talk to it about your symptoms, use your camera to show it anything it wants to see and get a triage diagnosis that tells you to either take a couple of Advil or get to a specialist.

Versions of AI have been around for decades. Google’s search engine is so accurate because it is built on AI and learns from billions of searches. AI is how Facebook directs items you most likely want to see to your news feed.

But for AI to be powerful enough to drive a truck or diagnose patients, it needs a few things that are just now exploding onto the scene. One is enormous amounts of data. Now that we do so many things online, every action gets recorded and stored, adding valuable data that can fuel AI.

The Internet of Things is putting sensors on people, in cars, in nature. To analyse that data and feed it into AI software takes enormous computing power, which has now become available and affordable to even a tiny garage startup through cloud companies like Amazon Web Services.

Put it all together, and we’ll soon be at a point when AI can get built to do almost anything, including, possibly, your job.

That realisation has set off a panic that is going viral faster than the latest Kim Kardashian butt photo.

A research paper from Oxford University proclaimed that machines will take over nearly half of all work done by humans. Some technologists have said 90% of the population will end up out of work.

There are smart, seemingly rational people who believe developed countries should institute a “guaranteed basic income” so that the masses who won’t be able to find work can avoid depredation.

In September, to help soothe the public and forestall intervention from government, most of the giants in AI formed a group called the Partnership on AI. “We passionately believe in the potential for [AI] to transform in a positive way our world,” Google’s Mustafa Suleyman said, Yoda-like, at the time.

“The concern is not that robots will take human jobs and render humans unemployable,” Jason Furman, chairman of the Council of Economic Advisers, said in a recent talk.

The worry is that the speed of AI’s encroachment on jobs “could lead to

sustained periods of time with a large fraction of people not working.”

US President Barack Obama recently weighed in about AI. “If properly harnessed, it can generate enormous prosperity and opportunity,” he said as guest editor of Wired.

“But it also has some downsides that we’re gonna have to figure out in terms of not eliminating jobs. It could increase inequality. It could suppress wages.”

In the long run, we’ll find equilibrium. But the transition in the short term will suck for a lot of people you know. And maybe for you.

And yet, there’s a happily ever after in here. Somewhere.

I talked recently with Ryan Detert, who started a company called Influential, which is built on AI from IBM’s Watson. The AI scours social media to find “influencers” who have a large number of followers and analyses the online personality of those individuals.

Then the company can work with brands — Kia and Corona are among its clients — to find influencers who match the traits of their target audiences. The brands then pay the influencers to tout the products. This is creating an entirely new job of brand influencer, not to mention new kinds of jobs at Influential and companies like it.

Over and over again, the robot economy will invent work we can’t even dream of today, much as the internet gave birth to unforeseen careers. Nobody’s grandmother was a search engine optimisation specialist. Today, that job pays pretty well.

Along the way, AI will also help people learn how to prosper in the age of AI. Sal Khan started Khan Academy by developing online tutorial videos for math and science students.

In its next phase, the organization is deploying AI in its lessons. The AI gets to know the student and understand how the person is learning so it can go over old material or add more challenging stuff.

Khan’s vision includes helping masses of people continually learn new skills that will make them more relevant in fast-changing job markets.

AI will be better than anything today at helping you find whatever new jobs it creates. AI will power software that gets to know you, your skills and your desires and will constantly monitor job openings and freelance opportunities all over the planet for you.

An AI matching system can bring unemployment numbers down dramatically by making sure more people find work.

Successful people in the AI age will focus on work that takes advantage of unique human strengths, like social interaction, creative thinking, decision-making with complex inputs, empathy and questioning. AI cannot think about data it doesn’t have.

It predicts what you want to see on Facebook based on what you’ve already liked. It can’t predict that you might like something that’s entirely different. Only humans can think that way. As Kelly says, the most valuable people in an age of push-button answers will be the people who ask the interesting questions.

AI’s proponents say it will collaborate with us, not compete against us. AI software in a conference room could listen to the conversation in a business meeting while constantly searching the internet for information that might be relevant, then serve it up when asked.

“It can bring in knowledge of the outside world that the humans might not be aware of,” says Ganguli, and that means the humans can make better decisions.

About a year ago, I saw cancer researcher M. Soledad Cepeda give a talk about AI in her work. She said AI software can analyse in two seconds the amount of data and text that a research assistant would need two weeks to plough through. That frees up the assistants to do more thoughtful work and speeds up the scientists’ search for cures.

By acting as our collaborator, AI will give us a chance at cracking our most pressing problems. It promises to help us end cancer, ease climate change, manage bursting cities and get our species to Mars.

We don’t know if we’ll succeed that, but one certainty is we can’t do it without AI. So if you’re still standing at that petrol pump filling your tank, here’s what the robot, based on its decades of experience, will tell you about the new robot economy: The one thing worse for the human race than developing AI would be stopping the development of AI.

If this is a fairy tale about work and jobs, AI is both the bad witch and good witch — destroyer and creator.

In such stories, good almost always wins. But in the middle of the story, the characters don’t know that. And that’s where we are now: face to face with the monster for the first time, doing everything we can to get through the scary forest alive.