Is there some way to run a script when an email is received?

I found the code to enable plus addressing, but I want to also auto-filter the mail into the folder of the plus address.

For example, if you send email to

bobjase+microsoft@myDomain.com

I want to put the message into the "microsoft" subfolder (and create it if it doesn't already exist).

I would be happy to write a script to do it if there isn't something already built in, but I don't know how to initiate the script when a plus-addressed message is received.