Error in custom actions


I am facing an issue in executing custom actions.




i created an endpoint.yml file as below action_endpoint: url: “http://localhost:5055/webhook/

and my actions file look like as below. removed Db credentials.

from future import absolute_import from future import division from future import unicode_literals from future import print_function

from rasa_core_sdk import Action from import SlotSet

class ActionDepositStatus(Action): def name(self): return ‘action_deposit_status’

def run(self, dispatcher, tracker, domain):
        import cx_Oracle
        # Connect as user "hr" with password "welcome" to the "oraclepdb" service running on this computer.

        connection = cx_Oracle.connect(conn_str)
        cursor = connection.cursor()
        agency_id = tracker.get_slot('Jurisdiction')
        deposit_Status = tracker.get_slot('depositStatus')
        agencyids = {'federal': 957, 'flsui': 1}
        depositStatuses = {'pending': "0", 'failed': "F",'held':"1"}
        #cursor.execute(u'SELECT * FROM mt_ntrol')
        cursor.execute(u"select  status, amount as amount from mt_deposit_history where A_ID = :agencyid and STATUS = :status",{"agencyid":agencyids[agency_id],"status":depositStatuses[deposit_Status]})
        row = cursor.fetchone()
        depositstatus = row[0]
        response = """It is currently $$  {}  in {} status for {}. """.format(row[1],deposit_Status, agency_id )
        return [SlotSet('depositStatus',deposit_Status),SlotSet('Jurisdiction',agency_id)]

class UtilMetods(Action):

def areThereAnyErrors(self,procid,connection):

    errormessagecursor = connection.cursor()
    errormessagecursor.execute(u"select  count(*) from MT_PROS_SAGE where proc_id = :procid and msg_Type =    :messageType",{"procid": procid, "messageType": 'E'})
    counts = errormessagecursor.fetchone()
    errorCount = counts[0]
    print("error count is {}".format(errorCount))
    if errorCount == 0:
        return False
        return True

class ActionDayStatus(Action):

def name(self):
    return 'action_day_status'

def run(self, dispatcher, tracker, domain):
    import cx_Oracle
    import datetime
        # Connect as user "hr" with password "welcome" to the "oraclepdb" service running on this computer.
    conn_str = db
    connection = cx_Oracle.connect(conn_str)
    cursor = connection.cursor()
    dateIndicator = tracker.get_slot('requiredDate')
    delta = datetime.timedelta(days = 1)
    now =
    currentDate = (now - delta).strftime('%Y-%m-%d')
    util = UtilMetods()
    cursor = connection.cursor()

    cursor.execute(u"select  * from M_ILE where DATE >= TO_DATE(:createDate,'YYYY/MM/DD') fetch first 50 rows only",{"createDate":currentDate})

    all_files = cursor.fetchall()
    total_number_of_files = len(all_files)

    print("total_number_of_files are {}".format(total_number_of_files))
    total_number_of_error_files = 0
    for row in all_files:
        print("Values:", row[0],row[1])
        procid = row[0]
        isError = util.areThereAnyErrors(procid,connection)
        if isError :
            total_number_of_error_files = total_number_of_error_files + 1
        else :
            childProcessCursor = connection.cursor()
            childProcessCursor.execute(u"select id from MT_PRS where parent_proc_Id = :procid",{"procid":procid})
            childprocids = childProcessCursor.fetchall()
            for row in childProcessCursor.fetchall():
                isError = util.areThereAnyErrors(row[0],connection)
                if isError:
                    total_number_of_error_files = total_number_of_error_files + 1
    total_numbber_of_correct_files = total_number_of_files - total_number_of_error_files

    print("Total number of files are {}. Errors in {} files and correct files are {}".

    response = """Total number of files are {}. Errors in {} files and correct files are {} for date {}""".format(total_number_of_files,total_number_of_error_files,total_numbber_of_correct_files,currentDate)

    return [SlotSet('requiredDate',dateIndicator)]

class ActionRestarted(Action): def name(self): return ‘action_restarted’ def run(self, dispatcher, tracker, domain): return[Restarted()] class ActionSlotReset(Action): def name(self): return ‘action_slot_reset’ def run(self, dispatcher, tracker, domain): return[AllSlotsReset()]

After running python -m rasa_core_sdk.endpoint --actions actions

i am getting below error

Traceback (most recent call last): ** File “/anaconda3/lib/python3.6/”, line 193, in _run_module_as_main** ** “main”, mod_spec)** ** File “/anaconda3/lib/python3.6/”, line 85, in _run_code** ** exec(code, run_globals)** ** File “/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/”, line 89, in ** ** action_package_name=cmdline_args.actions)** ** File “/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/”, line 55, in endpoint_app** ** executor.register_package(action_package_name)** ** File “/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/”, line 154, in register_package** ** self.register_action(action)** ** File “/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/”, line 105, in register_action** ** self.register_function(,** ** File “/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/”, line 150, in name** ** raise NotImplementedError** NotImplementedError

Could someone please help to resolve??

Hey @sivaramkappaganthu. You get the error due to the way UtilMetods class is implemented. It inherits Action class which needs two functions to be implemented - name and run (just like you have in all other custom action classes). Since you don’t have these functions implemented in UtilMetods class, you are getting NotImplementedError. Since, as I understand, UtilMetods is not an actual custom action that is included in your training stories, I would suggest you either incorporate the code of this class inside ActionDayStatus (where it is used) or change the implementation of this class so it would not inherit from the Action class.

Awesome.!! Thank you so much for help.

After modifying the util methods. BOT just working fine.

However, it triggered one more question for me. So now hitting python -m rasa_core_sdk.endpoint --actions actions will also make rasa core server up. That means there is no need to hit the command any more??

$ python -m
–enable_api -d models/dialogue
-u models/nlu/current
-o out.log –cors *

Will the above command become obsolete? Bot is working fine when i am hitting through postman. But i did not make rasa server up. Am wondering id the rasa core sdk command did that?? Could you please clarify??

Just a reminder to post issues like your original one in our github repos :slight_smile: no need to do it now, but just for future reference