Retailers closed out 2019 with solid gains, according to the National Retail Federation, which reported holiday sales grew 4.1% over the previous year’s numbers. It’s now an annual ritual for analysts to look at holiday retail activity and note the growing share of online sales, which, while impressive, still account for only about 10% of total retail spending. Foot traffic may have been down for brick-and-mortar stores on Black Friday, but the Financial Times reported that 2019 Cyber Monday sales set new records.

Lighter than expected foot traffic at brick-and-mortar locations fueled concerns about the “retail apocalypse” that has roiled the sector with store closures and job losses over the past several years, even as consumer spending grows. But online or in-store, it’s all retail sales, and whether “Black Friday” lives up to its name in any given year, turning ledger entries from red to black, depends on how individual retailers have responded to modern shopping habits and evolving consumer expectations.

When online sales increase, it’s not just e-commerce giants that benefit stores that have adjusted to new consumer spending patterns are growing their share of online revenue too. Adobe Analytics found that smartphone sales accounted for a record $3 billion in sales on Cyber Monday, and many customers shopped with their phones and then chose in-store pickup to complete the transaction.

Changing consumer expectations can doom retail outlets that fail to adjust. But evolving shopper behavior also signals an amazing opportunity for retailers to reimagine the customer experience and use emerging technologies behind the scenes to accommodate new shopping patterns. The important thing to keep in mind is that the decisions retailers make now will affect their long-term viability, and AI and machine learning will play a key role in defining retail success as the new decade unfolds.

Learn More: Watch These 3 Trends to Drive Greater Flexibility and Personalization in Retail

Using AI to Improve Agility

Due to the timing of the Thanksgiving holiday in the U.S., the 2019 seasonal shopping window was narrower than usual, giving retailers less time to adjust to emerging trends and demands. That provided an advantage to retailers who use AI to make decisions, which is something for retailers to think about before the next holiday shopping season gets underway. AI helps retailers gain efficiency and improve agility at every stage of operations, including supply chain, marketing, sales and customer outreach.

Retailers prepare early for anticipated spikes in sales (like holidays) because of lengthy supply chain lead times, but AI allows them to adjust along the way as the technology detects patterns in the data and separates signals from noise. By alerting the retailer of emerging trends that human analysis would miss, AI gives retailers time to change product mixes, merchandising, messaging, etc., to increase sales.

AI can also help retailers deliver a better customer experience. Early AI adopters like Amazon are experts at this, using data to make on-point recommendations. As the customer journey becomes more complex with multiple devices playing a role and options like in-store pickup vs. shipping in the mix, AI can capture and manage that data too, creating personalized recommendations for all customers.

Using AI can also help retailers operate more efficiently by reducing costly errors. Returns are a huge expense in retail, reducing profits by up to 20%. There are factors retailers can’t control directly, such as supplier inconsistencies on size and fit. But AI can assist by focusing on buyer behavior and adjusting recommendations. In this way, AI can help stores cut returns while creating satisfied customers.

Another way AI can drive retail innovation is by helping chains put the right store types in the right places, aligning product mix with local demand. Currently, retail chains tend to have a limited range of store types, but AI allows them to expand their range to fit local demographics. AI can also help retailers on the backend, powering the infrastructure that moves goods to meet demand.

Learn More: How to Improve E-Commerce Consumer Experience in 2020

Finding the Right Risk-Reward Balance

Large, established chain stores with an extensive inventory and long-term supplier relationships should have been well-positioned to sell online when startups like Amazon began disrupting retail. But because they were complicated organizations with many stakeholders, those stores were risk-averse, and they fell behind. Some tried to adjust after it became clear they had to, but by then, it was too late.

By focusing too much on the risk involved in rethinking business models and investing in new technologies, many legacy brands lost out. Others considered the rewards instead of just focusing on the risks, so they were able to adjust to changing consumer expectations and deliver the type of retail experience customer want, staking a claim to the future.

Newcomers like Stitch Fix have found success by going all-in on AI, combining the personal shopper concept with machine learning technology. It was a risk to start a new business in the crowded fashion space, but the company succeeded by offering a service that appeals to digital natives. That’s just one example of how rethinking retail with AI to create a new experience for customers can pay off.