The question is not about integrating on any website. It's about chatbots using AI
There are inbuilt domains for web search, but those are not free to use.
So I was wondering if I can query google search engine directly and process it in the backend code and return it as required?
Yes. You can integrate Google Search, but you'll need to run a program (node/python) on a server that'll take the query parameters from the user and make the search and return a JSON.
Go to https://www.google.co.in/cse to make your own custom search engine. You can restrict search results from a specific website or not.