When you create documents programmatically, do they then show up in the console exactly as they do when you add them manually? Same collection, all that? Have you checked the logs for the function to see if there are any errors or unexpected things there?
If events are being triggered from adding documents in the console, there is likely nothing wrong with your function's connection/trigger. The console uses the same SDKs to write to Firestore as your code does. I suspect that there is an undiscovered error somewhere along the way, or perhaps you are writing to a different collection than your trigger matches.
Cheers,
Michael