how can I make right clicking a custom crafted item like a loot bag give the player custom loot

im having trouble figureing out hot to get a loot table to hand our after right clicking a custom item, all i can do at the moment is cutom craft an item. and give it componeynts like cutom model data for a new texure. if its possible how whould i add a loot table to it? maybe thought doing some commands on a right click with it etc idk any help would be loads thanks !!!
Continue to help post