This is how The Origins of Optimus Prime, Twilight Sparkle, and Megatron goes in episode 26 of season 1 of Ryan F-Freeman's Adventures of Transformers: Prime.
Ratchet: Do you recall when I mentioned that Optimus wasn’t always a Prime and Twilight wasn't always a Princess? Well, they weren’t always Optimus and Twilight either. They were once clerks in the Iacon Hall of Records named Orion Pax and Nightfall Twinkle. But as they learned more about Cybertron’s past, they grew increasingly concerned about the present corruption in high places and inequality among the masses. Orion and Nightfall became inspired by the words and ideas of a gladiator, one who had named himself after one of the thirteen original Primes – Megatronus. Megatronus vowed to challenge Cybertron’s leadership and demand that all Cybertronians be treated as equals. This gladiator turned revolutionary rapidly gained a loyal following. Soundwave, chief among them. Orion and Nightfall began corresponding with Megatronus, who came to be something of a mentor to them. As Megatronus left the gladiatorial arena for the political, he saw fit to shorten his name. Before long, Megatron appeared before the High Council to propose his vision for a just society. And it was here that he began to reveal his true colors. Proclaiming the need to overthrow the old guard with force and arrogantly demanding to be named the next Prime. But Orion and Nightfall did not believe in violence as a means of achieving justice. The sparks and minds of the Council were moved by Orion and Nightfall’s words. Here…for the first time since Cybertron’s Golden Age…stood someone worthy of being a Prime and a Princess. But that honor could only be achieved by earning the legendary Matrix of Leadership and Magic of the Alicorn. His ambitions thwarted, Megatron spitefully severed all ties with Orion, Nightfall, and the Council, and came to wage war on all who opposed him through his growing army of followers which he named Decepticons. He vowed to claim the Matrix and Alicorn magic for himself wherever they might lie. In time, warfare consumed Cybertron, poisoning the planet to its core. Orion and Nightfall journeyed there, hoping to reverse the ill effects and found themselves before the very spark of our life giver, Primus himself. The ailing Primus sensed the innatiability within Orion and Nightfall and bestowed the Matrix and Alicorn magic upon them. It was thus that a surprised and humbled Orion Pax and Nightfall Twinkle came to be Optimus and Twilight, the last of the Primes and the fourth Alicorn Princess.
Starlight Glimmer: Wow!
Trixie: Nice backstory!
Thorax: Wish I had a backstory like that.
Discord: Me too.
[Bee and Rarity come over]
Bumblebee: [beeps] (translation: I feel sad)
Rarity: I feel the same way. But I have faith in Optimus and Twilight. We all do.
Bumblebee: [beeps] (translation: How?)
Rarity: Because when we first met, I showed I was the bearer of the Element of Generosity. Have you ever done anything generous?
Bumblebee: [beeps] (translation: Well, I saved Optimus from the plague.)
Bumblebee: [beeps] (translation: Yes.)
Rarity: Well, one day, you might wield the Element of Generosity.
Bumblebee: [beeps] (translation: Really?)
Rarity: I mean it.
Bumblebee: [beeps] (translation: Then I'll use it to save Optimus and Twilight.)
Rarity: Okay. But you need to tell Arcee and Bulkhead.
Bumblebee: [beeps] (translation: Thank you.)
Rarity: You're welcome.
[Bee goes and Ratchet walks over to Rarity]
Ratchet: What were you and Bumblebee talking about?
Rarity: He wanted to know how to save Optimus and Twilight.
Rarity: He really thinks he can save Optimus and Twilight by using the Element of Generosity.
Ratchet: And your point?
Rarity: I think that each one of you may represent the Elements too.
Ratchet: You really think so?
Rarity: I know so.
Ratchet: And when will that happen?
Rarity: Maybe when you show an act of true friendship.
Ratchet: How do you know this?
Rarity: Well, it's kind of a long story.
Ratchet: You can tell me.
Rarity: Okay. But promise you'll keep this to yourself.
Ratchet: I promise.
Rarity: Okay. Well, in Equestria we used the Elements of Harmony to defeat two powerful villains Nightmare Moon and Discord, whom Fluttershy reformed.
Ratchet: Go on.
Rarity: And we also used them to save the Tree of Harmony from the plundervines and free the Sun and Moon Princesses.
Rarity: Discord planted them a long time from now. But they took a long time to grow.
Ratchet: And after that?
Rarity: A flower bloomed. It had a box which contained Rainbow Power that we used to defeat Tirek. But we need to find the keys. And each of the keys turned out to be in the form of gifts from friends we made.
[Meanwhile, Bee tells Bulkhead and Arcee his plan]
Ryan F-Freeman: Ok, Bee. What is the plan?
Bumblebee: [beeps] (translation: Bulkhead, Arcee and I will use the Elements of Generosity, Honesty and Loyalty to save Optimus and Twilight.)
Arcee: Are you sure?
Bumblebee: [beeps] (translation: Yes. I'm sure. If they used it after showing an act of true friendship, we can too.)
Crash Bandicoot: I think that is a good idea. And Ryan could find Megatron with Evil Ryan's help.
Bumblebee: [beeps] (translation: Thanks, Crash. Ryan has magic so he could be Twilight's equal.)
Arcee: Guys, you need stay here. Bee, Bulk, and I will handle it.
Evil Ryan: Let me and Ryan go with you. I can find Megatron because I got Unicron's blood in me. I can hear both his and Megatron's thoughts and know where he is.
Arcee: Fine but keep out of Con vision.
Evil Ryan: You can count on me and Ryan as Autobots.
Bumblebee: [beeps] (translation: Thanks you guys.)
Ryan F-Freeman: You're welcome. One thing. Twilight is the Element of Magic.
Bumblebee: [beeps] (translation: Yeah. But so is Optimus.)
Crash Bandicoot: Hey. I think Ryan's onto something. If Prime and Twilight are the Element of Magic, why not Ryan can be the same. Remember Ryan and Twilight confront Nightmare Moon?
Matau T. Monkey: Oh. Master Ryan and Twilight have something in common, eh? Same thing for me and Pinkie Pie.
Bumblebee: [beeps] (translation: How, Matau? What are you? The Element of Laughter?)
Crash Bandicoot: I wonder who will the Element of Kindness be?
Ryan F-Freeman: Don't know.
Matau T. Monkey: Anyone got any ideas?
Bertram T. Monkey: Ryan? How do you got both Twilight's and Optimus' memories in you? You think you're Optimus' student?
Ryan F-Freeman: Yes, Bertram. During my studies with Optimus' and Twilight's memeories, I discover a thing to restore Prime. Vector Sigma.
Fluttershy: Excuse me. Maybe Wreck-It Ralph can help you on this mission.
Bertram T. Monkey: You think she can use the Element of Kindness and Vector Sigma, Ryan?
Ryan F-Freeman: Yes. But the only thing that is in it, is the Key to Vector Sigma. Which holds an infinite knowledge of all Transformers on Cybdertron. Megatron has no idea what power it has.
Bumblebee: [beeps] (translation: Wow. That is awesome. Guess you did learn from their memories. So. Who did you and Twilight see at Canterlot?)
Ryan F-Freeman: Well. I met Princess Mi Amore Cadenza. But, Twilight and I like to call her Cadance. When me and Twilight see Cadance use green magic, she thinks she is "evil". But, I think she is not. She is really Queen Chrysalis in disguise. So, she transported me and Twilight to the caves under Canterlot where we found the REAL Cadence. We got out, Cadence frees Shining Armor and love blasted Chrysalis far away and then. [mimics the tune of "Here Comes the Bride] Got married. [kisses Fluttershy]
Discord: Jack could have you with Odette soon. And I did reform thanks to her.