Google search from Default or Custom action

I have this requirement where a user type something (by something I mean any text for which I have no intents) and as a response I don’t want to respond simply by a response like “Sorry!, I didn’t understand that.”, instead I want to take that text and make a google search and return some results to the user. For this I wrote a DefaultAction method as below:

class ActionDefault(Action):
	def name(self):
		# define the name of the action which can then be included in training stories
		return "action_default"
	def run(self, dispatcher, tracker, domain):
		show_result = ''
		#with requests.session() as c:
		msg = tracker.latest_message
		url = 'https://www.google.com'
		query = {'q': msg}
		results = requests.get(url, params=query)
		show_result = request['news_results']['link']
		dispatcher.utter_message(show_result)
		return []

But when I run this code, I get following ERROR:

raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 500 Server Error: INTERNAL SERVER ERROR for url: http://localhost:5055/webhook

I have following questions to ask:

  1. Is this the right way to do a google search from the rasa stack?
  2. If not, can anyone please provide some pointers?

My endpoint.yml looks as below:

action_endpoint: url: ‘http://localhost:5055/webhook

Got it working.

Thanks

please let us know how u handle the problem