I have documented the shared mod helper that you can use for this, along with a few related helpers you can use to create & give new items in dialogs based on root templates rather than item instances: DB_GiveTemplateFromPlayerDialogEvent and DB_GiveTemplateFromNpcToPlayerDialogEvent.

I have also updated and hopefully clarified the documentation about frame delays, which is quite important in this context.