I would like to code actions and responses to gain finer control as opposed to how we do using UI in DialogFlow. But building a whole platform like DialogFlow would take a lot of time, but is there any nlp or conversational Api opensourced on top of which we can perhaps write python code?
You can also use Rasa Rasa NLU and Rasa Core are completely open source, and you can use them as an alternative to Dialogflow, IBM Watson, or Lex. There is a very active community of developers, and a bunch of tutorials and additional tools built by the community.
Disclaimer - I'm a maintainer of these libraries.
You can use RASA's open source project: https://github.com/RasaHQ/rasa
It is open source and also works with Python. You will also have control of your own data. However, it is not as easy as dialogflow and will require some time to setup.
For more differences refer here: https://www.kommunicate.io/blog/dialogflow-vs-rasa-which-one-to-choose/
You can also explore Wit.ai, IBM Watson Assistant, I have written a post on their differences here: https://www.kommunicate.io/blog/dialogflow-vs-lex-vs-watson-vs-wit-vs-azure-bot/
You can use Watson API from IBM which is provided along with its cloud platform, bluemix. Alternatively, you can also use Amazon Lex.