Vegetable oils such as corn oil, peanut oil, and soy oil are reacted with polyamines to form a mixture containing amides, imides, half esters, and glycerol with subsequent treatment with a strong acid such as sulfonic acid to produce a product mix that has good detergent properties in fuels and lubricants.