Hi,
I am facing an issue in executing custom actions.
rasa-core==0.11.3
rasa-core-sdk==0.11.5
rasa-nlu==0.13.2
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 rasa_core_sdk.events 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 )
dispatcher.utter_message(response)
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
else:
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 = datetime.datetime.now()
currentDate = (now - delta).strftime('%Y-%m-%d')
util = UtilMetods()
print(currentDate)
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)
print("ISerror:",isError)
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 {}".
format(total_number_of_files,total_number_of_error_files,total_numbber_of_correct_files))
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)
dispatcher.utter_message(response)
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/runpy.py”, line 193, in _run_module_as_main** ** “main”, mod_spec)** ** File “/anaconda3/lib/python3.6/runpy.py”, line 85, in _run_code** ** exec(code, run_globals)** ** File “/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/endpoint.py”, line 89, in ** ** action_package_name=cmdline_args.actions)** ** File “/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/endpoint.py”, line 55, in endpoint_app** ** executor.register_package(action_package_name)** ** File “/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/executor.py”, line 154, in register_package** ** self.register_action(action)** ** File “/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/executor.py”, line 105, in register_action** ** self.register_function(action.name(), action.run)** ** File “/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/init.py”, line 150, in name** ** raise NotImplementedError** NotImplementedError
Could someone please help to resolve??