This is probably the opposite of what people usually want to do.
Is it possible to write a piece of software that triggers Alexa?
Basically, like saying "Alexa, do something" to your Amazon Echo, but with code instead of talking. Perhaps by leveraging some Lambda function.
Best you can do is try, think about security issues that would open up if you could do what you wanted...
https://developer.amazon.com/blogs/alexa/post/bda9d70c-2f0d-454d-9939-2eb82868cf35/announcing-contact-and-motion-sensor-apis-and-integration-into-alexa-routines-adding-new-home-automation-features-for-customers-and-new-opportunities-for-smart-home-developers