Slipping gears on new Electra Townie 8i
The 8i uses what Shimano calls a cassette joint. It's wraps the cable around the back side of the hub and as the shifter pulls the cable it moves a bracket counterclockwise backwards on the hub body. Cable tension on a brand new Nexus/Alfine 8-speed hub needs to be precise.

Do this:


Shift the bike into 4th gear
Find the cable tension indicator. There is one on the top and the bottom of the hub. The top one is a small plastic window. The bottom one is a small piece of metal painted yellow. It may be easier to find if you can flip the bike over
Turn the barrel adjuster on the shifter until you see the outboard yellow line move
Keep turning the adjuster in either direction (probably out, counterclockwise) until the yellow lines are aligned
shift into 3rd gear, then back into 4th and adjust again
shift into 5 gear, then back into 4th and adjust again
repeat until you're satisfied with adjustment. 


This should stop your gear slippage. If the shifter cable isn't properly lubricated or there's binding somewhere then you should see a problem while dialing in the adjustment. If you can't get this adjustment right to your satisfaction take the bike back and have the shop do it. They shouldn't charge you for this if the bike is new. Make sure they test ride it so they can experience the problem.

If this is an old hub and you've ridden it misadjusted for a long time it is possible to damage the hubs innards. Replacing the hub guts should only be done at a shop that deals with these hubs regularly and has the special lubricating bath that they require for proper maintenance.