Ansari was among the many stars in attendance at a recent New York City fundraiser for Obama's re-election campaign and the president took the opportunity to joke about his daughter's love of Parks and Recreation.
"Now, this is big because Malia is a big Parks and Recreation fan," the president told those in attendance, reports The Wrap. "So having Aziz here is like the only thing she thinks is worth me doing."
Obama added humorously: "I've got more Twitter followers than you, man. I just want to keep him humble and hungry. We all need somebody who does that. Fortunately, I have Michelle."
The US leader has more than 12.8m Twitter followers, while Ansari lags behind with 1.6m supporters on the social networking website.
The 900 guests who attended the fundraising event reportedly paid $1,000 (£634) each for a ticket.
> Bill Maher donates $1m to Barack Obama political support group
> Barack Obama sings live with Mick Jagger, BB King: Video