you will need to know the ID of the item to apply the discount code to.
In addition to the Based on session value trigger that is used for coupon codes, add another trigger:
Presence of an Item In the cart:
If item "<item ID>" "exists" in the cart.
the add you flat rate discount.