"Future" Sally will recall to her kids the story of how she met their father. Young Sally will be played by Greta Gerwig.
On "How I Met Your Mother," Bob Saget voiced Future Ted.
Ryan, 52, is most known for 90s films such as "Sleepless in Seattle" and "You've Got Mail" as well as the hit 1989 romantic comedy "When Harry Met Sally..."
She has made guest appearances on several TV series, including "Web Therapy," but this will be her first major prime-time role.
Ryan's most recent big-screen films include "Serious Moonlight" (2009) and "The Women" (2008).