question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with database and RASA connection

See original GitHub issue

Rasa Core version: 0.13.0

Python version: 0.14.1

Operating system (windows, osx, …): Linux

Issue: I am facing some issues while trying to fetch data from MySQL database.

I am getting an error as follows:

2019-03-11 17:37:50 DEBUG rasa_core.processor - Predicted next action ‘action_db’ with prob 1.00. 2019-03-11 17:37:50 DEBUG rasa_core.actions.action - Calling action endpoint to run action ‘action_db’. 2019-03-11 17:37:50 ERROR rasa_core.actions.action - Failed to run custom action ‘action_db’. Action server responded with a non 200 status code of 404. Make sure your action server properly runs actions and returns a 200 once the action is executed. Error: 404 Client Error: NOT FOUND for url: http://localhost:5055/webhook/ 2019-03-11 17:37:50 ERROR rasa_core.processor - Encountered an exception while running action ‘action_db’. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code. 2019-03-11 17:37:50 DEBUG rasa_core.processor - Failed to execute custom action.

Content of domain file (if used & relevant):


slots:
  personid:
    type: text
  stockid:
    type: text
  matches:
    type: unfeaturized

intents:
 - greet
 - bye
 - affirmative
 - negative
 - personid
 - stockid
 - inform

entities:
 - personid
 - stockid

templates:
  utter_greet:
    - 'Hello! How can I help?'
  utter_goodbye:
    - 'Talk to you later.'
    - 'Bye bye :('
  utter_ask_personid:
    - 'Tell me your id please'
    - 'May I know your id please?'
  utter_ask_stock:
    - 'Tell me the stock name please'
    - 'Could you please tell me the stock name?'

actions:
 - utter_greet
 - utter_goodbye
 - utter_ask_stock
 - utter_ask_personid
 - action_db

Content of action file :

from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals

from rasa_core_sdk import Action
from rasa_core_sdk.events import SlotSet

import MySQLdb

class ActionDb(Action):
	def name(self):
		return "action_db"

	def run(self, dispatcher, tracker, domain): 
		db = MySQLdb.connect("localhost","root","root","DBforChatbot")
		cursor = db.cursor()
		PersonID = tracker.get_slot('personid')
		StockID = tracker.get_slot('stockid')
		q = "select StockName, StockBalance from Persons WHERE (PersonID = '%d' and StockName = '%s');" % (PersonID, StockID)
		try:
			cursor.execute(q)
			if cursor.execute(q)==0:
				print("Sorry, could not find any relevant data. Please contact 1234 for further assistance.")
			results = cursor.fetchall()
			not all(results)
			for row in results:
				stockname = row[0]
				stockbal = row[1]
				# Now print fetched result
				details = ("stockname=%s,stockbal=%d" % (stockname,stockbal))
				print(details)
		except:
			print ("Error: unable to fetch data")
	
		db.close()
		response = """The detail is as follows {}.""".format(results)
						
		dispatcher.utter_message(response)
		return [SlotSet('stockid',StockID)]

Content of endpoints file (if used & relevant):

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

Content of dialogue_management_model file:

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import logging
import rasa_core
from rasa_core.agent import Agent
from rasa_core.policies.keras_policy import KerasPolicy
from rasa_core.policies.memoization import MemoizationPolicy
from rasa_core.interpreter import RasaNLUInterpreter
from rasa_core.utils import EndpointConfig
from rasa_core.run import serve_application
from rasa_core import config

logger = logging.getLogger(__name__)


def train_dialogue(domain_file = 'testbot_domain.yml',
					model_path = './models/dialogue',
					training_data_file = './data/stories.md'):
					
	agent = Agent(domain_file, policies = [MemoizationPolicy(), KerasPolicy(max_history=3, epochs=200, batch_size=50)])
	data = agent.load_data(training_data_file)	
	

	agent.train(data)
				
	agent.persist(model_path)
	return agent
	
def run_test_bot(serve_forever=True):
	interpreter = RasaNLUInterpreter('./models/nlu/default/testbotnlu')
	action_endpoint = EndpointConfig(url="http://localhost:5055/webhook/")
	agent = Agent.load('./models/dialogue', interpreter=interpreter, action_endpoint=action_endpoint)
	rasa_core.run.serve_application(agent ,channel='cmdline')
		
	return agent
	
if __name__ == '__main__':
	train_dialogue()
	run_test_bot()

Hi @tmbo @akelad @EPedrotti , could you please help here. Thanks.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
dezykumcommented, May 14, 2019

Hi Ujjwalsas9 can you elaborate what you fixed to get this resolved.

0reactions
siddharthchauhancommented, Feb 17, 2020

Can @Ujjwalsas9 please tell me what you fixed in this? I am doing similar kind of thing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Database - Rasa
In your Oracle database, create an empty database called rasa and configure a user/password that has access to it.
Read more >
python 3.x - Connecting Rasa to a database to store responses
I'm trying to connect my rasa open source chatbot to a local database and store response from the user. But I couldn't succeed...
Read more >
Connecting your Rasa Assistant to a Database - YouTube
Today we'll work on connecting our rasa assistant to a database.What's livecoding? It's folks working on real projects in real time with ...
Read more >
Rasa Livecoding: Querying a database with a chatbot - YouTube
This week we'll be expanding our assistant to be able to query multiple database fields at once.(Special community member ticket for the ...
Read more >
Create Chatbot using Rasa Part-1 - Towards Data Science
Rasa is an open source machine learning framework for building AI ... In the same python script, you can connect to your backend...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found