FormAction From rasa_core_sdk ERROR with import

importing FormAction from Rasa Core sdk throws an error.

from rasa_core_sdk.forms import FormAction

Gives me the error stack of:

Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
  File "/home/ubuntu/anaconda3/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/endpoint.py", line 89, in <module>
action_package_name=cmdline_args.actions)
  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/endpoint.py", line 55, in endpoint_app
executor.register_package(action_package_name)
  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/executor.py", line 153, in register_package
self.register_action(action)
  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/executor.py", line 105, in register_action
self.register_function(action.name(), action.run)
  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/forms.py", line 96, in name
raise NotImplementedError
NotImplementedError

Why is it Raising this NotImplementedError if no where in my code I have created an instance of this class ?

How are you using it, if you’ve imported it?

I am running

make run-actions

From the Makefile. If that import is at the top of the file, that error is thrown.

It throws the error before I even used it like

class CustomAction(FormAction):

can you post your actions.py file?

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from rasa_core_sdk.forms import FormAction, EntityFormField, BooleanFormField
from rasa_core_sdk import Action, Tracker
from rasa_core_sdk.events import SlotSet, EventType
from bot import RestaurantAPI
import random

#connect to MongoDb from local network
import pymongo
from pymongo import MongoClient

import json
from bson import ObjectId
import sys

client = MongoClient('mongodb://172.31.24.16:27017')
db = client.simba
users = db.users

FORM_SLOT_NAME = "requested_slot"


def doc_to_dict( doc ):
    doc['_id'] = str(doc['_id'])
    return doc

def create_new_user(caller_id):
    if caller_id is not None:
        users.insert_one({"caller_id": caller_id})
        return users.find_one({"caller_id": caller_id})
    else:
        #test user
        return {"first_name": "Adrian"}

def user_from_db(caller_id):
    if caller_id is not None:
        #query the database for a user with this number
        user = users.find_one({"caller_id": caller_id})
        print( "usrer: ")
        print( user )
        if user is not None:
            print( user )
            return doc_to_dict(user)
    else:
        return None

class LoanApplicationForm(FormAction):
    def name(self):
        return 'action_personal_loan_form'
    
    @staticmethod
    def required_fields():
        return [
            FreeTextFormField("caller_last_name"),
            FreeTextFormField("caller_street"),
            FreeTextFormField("caller_city"),
            FreeTextFormField("caller_state"),
            FreeTextFormField("caller_zip_code"),
            FreeTextFormField("caller_employer"),
            BooleanFormField("caller_steady_income", "confirm", "deny"),
            FreeTextFormField("caller_length_employment"),
            FreeTextFormField("caller_monthly_debt"),
            FreeTextFormField("caller_ssn")]

    def submit(self, dispatcher, tracker, domain):
        dispatcher.utter_message("The form is now complete.")    
        return []
class ActionRouteSuperAgent(Action):
    def name(self):
        return 'action_route_super_agent'

    def run(self, dispatcher, tracker, domain):
        dispatcher.utter_message("Is there anything else that I can help you with today?")
        return [SlotSet("current_agent", "superagent")]

I solved the problem by manually pasting the FormAction Class and all FormFields into my actual actions.py file.

can you share how you did it if possible then share the code of class “FormAction”