Conditional Automated Request Shuffler 
Initial Design. 		<jesse@fsck.com> 9 Nov 99

#Try to find out what queue the incoming ticket is in
#Try to find out the default action for this invocation
#Read the ticket from STDIN
#Obtain the actor
#Obtain the serial # if we have one
#If the ticket has a ticket-id
	#if this is a 'comment'
		#add the current mime objects as a 'comment'

	#if this is 'correspondence'
		#add the current mime object as 'correspondence'


#if this ticket does not yet have a ticket id

  #For now:
	#Create a new ticket

  #In the distant future

	#load the regexp table matching this queue
	#check the message agains the regexp table, ordered by precedence
		#when we get a match
			#get the ruleset for that regexp from the actions table
  			#evaluate the ruleset in order of precedence.
			   #if we get an 'exit' stop proccesing ALL rulesets
wpw  			   #if we get a 'forward,' forward it to 'value'.

   			   #if we get a 'create,' create a request in 'value'
			   #elseif we get a 'map', add this as additional correspondence on ticket 'value'

    
		           #if we get an 'associate', associate the ticket number returned from the 
			   'create' or 'map' with the master ticket from 'value'

			   #if we get a 'reply', 
				#load the reply template with id 'value'      
				#replace strings in the template
				#send the template




CREATE TABLE Rules {
ID int AUTO_INCREMENT,
Desc varchar(120),
Regexp varchar(80),
Precedence int,
MatchField varchar(20), #Can be a headername or 'any' all header names
                        #end in :


CREATE TABLE Actions {
Rule int,
Action varchar(20), # Create, Forward, Squelch, Owner, Area, Associate
Value varchar(20), #queue or email address
Desc varchar(120)
}

CREATE TABLE Autoreplies {
ID int AUTO_INCREMENT,
Content text
);