Problem Rasa (docker) vs Mysql (local)

Hello everyone, I’m struggling connecting rasa 2.8 (docker) with mysql (local), my bot is rule-based.

It doesn’t connect to mysql in ‘action_submit’. I’ve tested the ‘action_submit’ and it’s working if I use a normal utter just to print.

Is it possible to make this connection rasa(docker) with mysql(local)?

Bellow my action/rule and error msg.

Rules

- rule: 
  steps:
  - intent: greet
  - action: utter_greet
  - action: register_form
  - active_loop: register_form

- rule: 
  condition:
  - active_loop: register_form
  steps:
  - action: register_form
  - active_loop: null
  - slot_was_set:
    - requested_slot: null
  - action: action_submit

Actions

import mysql.connector
from rasa_sdk import Tracker, FormValidationAction, Action
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.types import DomainDict

class ActionSubmit(Action):

    def name(self) -> Text:
        return "action_submit"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
   DataUpdate(tracker.get_slot("user_name"), tracker.get_slot("user_cel"),
                             tracker.get_slot("user_birth"),
                             tracker.get_slot("user_age"), tracker.get_slot("user_fname"),
                             tracker.get_slot("user_mname"),
                             tracker.get_slot("user_bname"), tracker.get_slot("user_gname"),
                             tracker.get_slot("user_uni"),
                             tracker.get_slot("user_email"), tracker.get_slot("user_loc"),
                             tracker.get_slot("user_loc_num"),
                             tracker.get_slot("user_card"), tracker.get_slot("user_city"),
                             tracker.get_slot("user_nb"),
                             tracker.get_slot("user_street"), tracker.get_slot("user_oel"),
                             tracker.get_slot("user_doc_one"),
                             tracker.get_slot("user_doc_two"), tracker.get_slot("user_doc_three"))
       
   return []

def DataUpdate(user_name, user_cel, user_birth, user_age, user_fname, user_mname, user_bname, user_gname, user_uni, user_email, user_loc, 
user_loc_num, user_card, user_city, user_nb, user_street, user_oel, user_doc_one, user_doc_two, user_doc_three):
    mydb = mysql.connector.connect(
        host="localhost",
        user="root",
        password="root",
        database="TestDB"
    )

    mycursor = mydb.cursor()

    sql = 'INSERT INTO UserCisam (user_name, user_cel, user_birth, user_age, user_fname, user_mname, 
          user_bname, user_gname, user_uni, user_email, user_loc, 
          user_loc_num, user_card, user_city, user_nb, user_street, user_oel, 
          user_doc_one, user_doc_two, user_doc_three) VALUES ("{0}","{1}","{2}","{3}","{4}","{5}",
          "{6}","{7}","{8}","{9}","{10}","{11}","{12}","{13}","{14}","{15}","{16}","{17}","{18}","{19}");'.format(user_name, user_cel, user_birth, user_age, user_fname, user_mname, user_bname, user_gname, user_uni, user_email, user_loc, 
user_loc_num, user_card, user_city, user_nb, user_street, user_oel, user_doc_one, user_doc_two, user_doc_three)
    mycursor.execute(sql)
    mydb.commit()

Error

2022-07-23 05:11:56 DEBUG    rasa.core.policies.rule_policy  - There is a rule for the next action 'action_submit'.
2022-07-23 05:11:56 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_2_RulePolicy.
2022-07-23 05:11:56 DEBUG    rasa.core.processor  - Predicted next action 'action_submit' with confidence 1.00.
2022-07-23 05:11:56 DEBUG    rasa.core.actions.action  - Calling action endpoint to run action 'action_submit'.
2022-07-23 05:11:56 ERROR    rasa.core.processor  - Encountered an exception while running action 'action_submit'.Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.
Traceback (most recent call last):
  File "/opt/venv/lib/python3.8/site-packages/rasa/core/actions/action.py", line 685, in run
    response = await self.action_endpoint.request(
  File "/opt/venv/lib/python3.8/site-packages/rasa/utils/endpoints.py", line 172, in request
    raise ClientResponseError(
rasa.utils.endpoints.ClientResponseError: 500, Internal Server Error, body='b'{"description":"Internal Server Error","status":500,"message":"The server encountered an internal error and cannot complete your request."}''

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/venv/lib/python3.8/site-packages/rasa/core/processor.py", line 772, in _run_action
    events = await action.run(
  File "/opt/venv/lib/python3.8/site-packages/rasa/core/actions/action.py", line 709, in run
    raise RasaException("Failed to execute custom action.") from e
rasa.shared.exceptions.RasaException: Failed to execute custom action.
2022-07-23 05:11:56 DEBUG    rasa.core.processor  - Policy prediction ended with events '[]'.
2022-07-23 05:11:56 DEBUG    rasa.core.processor  - Action 'action_submit' ended with events '[]'.
2022-07-23 05:11:56 DEBUG    rasa.core.processor  - Current slot values:

I can’t find the issue looking your logs But, you can use @ChrisRahme actions bot to guide you

ChrisRahme/FYP-Chatbot