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/", line 193, in _run_module_as_main
"__main__", mod_spec)
  File "/home/ubuntu/anaconda3/lib/python3.6/", line 85, in _run_code
exec(code, run_globals)
  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/", line 89, in <module>
  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/", line 55, in endpoint_app
  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/", line 153, in register_package
  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/", line 105, in register_action
  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/rasa_core_sdk/", line 96, in name
raise 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 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 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://')
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})
        #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)
        return None

class LoanApplicationForm(FormAction):
    def name(self):
        return 'action_personal_loan_form'
    def required_fields():
        return [
            BooleanFormField("caller_steady_income", "confirm", "deny"),

    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 file.

1 Like

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