Dialog is not following stories.md after introducing custom actions

Rasa Core version :0.12.3

Python version : Python 3.6.8

Operating system (windows, osx, …): Ubuntu 16.04

Issue : dialog is not following stories.md after introducing custom actions. Using Jupyter notebook for writing and testing the code.

I am really new to Rasa and have been exploring it for the purpose of building a chatbot. Having a difficult time when it comes to custom actions.

I was playing with utterances in the actions till now and the flow of dialog was going fine. I tried writing some custom actions for the chatbot but the flow gets struck in the first conversation itself.

a path in stories.md file is as below:-

#happy path model enquiry 1

  • greet
    • utter_greet
  • Customer_enquiry_model
    • action_get_model_config
    • utter_did_that_help
  • mood_affirm
    • utter_mood_affirm
  • OPPO_Phones_Price
    • action_get_model_price
    • utter_did_that_help
  • mood_affirm
    • utter_mood_affirm
  • goodbye
    • utter_goodbye

For the path mentioned , I am getting :-

Your bot is ready to talk! Type your messages here or send ‘stop’

Me :Hi I am Arghya

Bot : I am not sure what you are aiming for.

expected :- utter_greet

it seems that the bot is not able to predict the action as in the path.

Please guide me where i am going wrong and nudge me to the right direction.

the nlu.md training file is as below :-

intent:CEO_info

intent:CustomerCare_info

intent:Customer_enquiry_model

  • Yes I am looking for f10
  • I want to know about f20
  • tell me about f10
  • give me the detail of model name
  • I would say model name
  • details about f20
  • information about f30
  • enlighten me about x10
  • looking for this model

intent:OPPO_Phones_Price

  • want to buy F7 what is the price?
  • wanna buy E10, tell me the price?
  • interested in f7, give me the price
  • interested to go for t66, price pls
  • what is the market value of f7?
  • may I know the worth of f7?
  • can I have the price of g14?
  • let me know the price of e10?
  • share the price of x20?
  • want to know the price of i10?
  • price of ur phone please?
  • do u have the price of y10
  • price please
  • what is the price
  • price of this particular phone

intent:Official_Website

intent:Oppo_store_ocation

  • shop address please
  • Where is your shop situated?
  • your nearest shop address
  • tell me your location please
  • where are you located at?
  • give me your shop address
  • where is your outlet at?
  • nearest store please
  • where is the nearest store?
  • where is the nearest store of oppo?
  • shop near to me
  • address of the shop near to me
  • location of the shop near to me

intent:Oppo_product_comparison

intent:Service_Center_OR_Factory

intent:about_OPPO

  • ollie what do you know about oppo?
  • what is oppo?
  • what do you know about oppo?
  • which field you belong to?
  • what is ur business?
  • what is oppo about?
  • what do u do?
  • can i know about ur services?
  • what does Oppo do?

intent:brand_info

  • Ollie what brand you belong to?
  • what is ur brand?
  • brand name?
  • which brand do you represent?
  • which brand do you work for?
  • give me some information about the brand you are working for.
  • may I know about your brand name?
  • which brand are you?

intent:goodbye

  • see you
  • good by
  • see you later
  • bye
  • goodbye
  • have a nice day
  • see you around
  • bye bye
  • see you later
  • that’s all!Thank you.
  • Nope.take care.
  • I got all I need.Thanks.
  • It was really helpful.Thanks.
  • Ciao

intent:greet

  • hey I am Peter
  • hello there I am Hans
  • hi I am Tom
  • hello there
  • good morning
  • good evening
  • morning
  • hey there
  • let’s go
  • hey dude
  • good morning
  • good evening
  • good afternoon
  • Hi,I am Arghya
  • hi
  • hello
  • hi Arghya here

intent:city_name

intent:model_name_lookout

  • I want to know about g12 and x12
  • tell me about t16 and f7
  • I am interested in Model1 and Model2.
  • give me the detail of Model1 and Model2
  • Take Model1 and Model2
  • I would say Model1 and Model2
  • compare Model1 and Model2

intent:mood_affirm

  • yes
  • indeed
  • of course
  • that sounds good
  • correct
  • sure
  • exactly
  • hundred percent correct
  • that’s right
  • yup
  • yeep
  • sounds right
  • looks nice

intent:mood_deny

  • no
  • never
  • I don’t think so
  • don’t like that
  • no way
  • not really
  • nope
  • na
  • not exactly
  • double no
  • not that

intent:provide_founder

  • Oppo is Owned by whom?
  • Oppo is established by?
  • Can u tell me owner
  • who is oppo’s owner
  • oppo’s owner
  • who owns Oppo?
  • Oppo founded by whom?
  • Who is the founder of oppo?
  • oppo is owned by whom?
  • oppo mobile is owned by whom?
  • who owns oppo?
  • tell me the name of the owner of oppo.
  • name of the owner?
  • owner’s name?
  • owner please?
  • who is the owner of oppo?

lookup:PERSON

/home/arghya/rasa_test/data/place_finder/PERSON.txt

lookup:model

/home/arghya/rasa_test/data/place_finder/model.txt

lookup:customer_location

/home/arghya/rasa_test/data/place_finder/customer_location.txt

action server code :-

from future import absolute_import

from future import division

from future import unicode_literals

from rasa_core.domain import Domain

from rasa_core.trackers import EventVerbosity

import logging

logger = logging.getLogger( name )

import requests

import json

from rasa_core_sdk import Action

from rasa_core_sdk.events import SlotSet

from rasa_core_sdk.events import UserUtteranceReverted

from rasa_core_sdk.events import AllSlotsReset

from rasa_core_sdk.events import Restarted

class SaveCityName(Action):

 def name(self):
     return 'action_save_city_name'

 def run(self, dispatcher, tracker, domain):
    orig = next(tracker.get_latest_entity_values("customer_location"), None)
    if not orig:
        dispatcher.utter_message("Please enter a valid city name")
        return [UserUtteranceReverted()]
    return [SlotSet('customer_location',orig)]

class SaveModelName(Action):

def name(self):
     return 'action_save_model_name'
    
def run(self, dispatcher, tracker, domain):
    inp = next(tracker.get_latest_entity_values("model"), None)
    if not inp:
        dispatcher.utter_message("Please enter a valid model")
        return [UserUtteranceReverted()]
    return [SlotSet('model',inp)]

class ActionSlotReset(Action):

def name(self): 
    return 'action_slot_reset'
def run(self, dispatcher, tracker, domain): 
    return[AllSlotsReset()]

class getServiceCentreLocation(Action):

def name(self):
    return 'action_get_service_centre_location'
def run(self):
    print("you will receive the service location once the database is up.Working on it :) ")
    pass

class getShopLocation(Action):

   def name(self):
       return 'action_get_shop_location'
  def run(self):
    print("you will receive the shop location once the database is up and running.Thanks for the wait.Next Question please? :)")
    pass

class getModelPrice(Action):

def name(self):
    return 'action_get_model_price'
def run(self):
    print("you will receive the price of the model once the database is up and running.Thanks for the wait.Next Question please? :)")
    pass

class getModelConfig(Action):

def name(self):
    return 'action_get_model_config'
def run(self):
    print("you will receive the model configuration once the database is up and running.Thanks for the wait.Next Question please? :)")
    pass   

model.txt PERSON.txt

Content of domain file (if used & relevant): domain.yml

intents:

  • greet
  • goodbye
  • provide_founder
  • about_OPPO
  • brand_info
  • CustomerCare_info
  • Service_Center_OR_Factory
  • Oppo_store_location
  • CEO_info
  • Official_Website
  • OPPO_Phones_Price
  • Customer_enquiry_model
  • Oppo_product_comparison
  • model_name_lookout
  • mood_affirm
  • mood_deny
  • city_name

slots: PERSON: type: text model: type: text customer_location: type: text workshop_location: type: text shop_location: type: text

entities:

  • PERSON
  • information
  • customer_location
  • workshop_location
  • shop_location
  • web_address
  • model
  • feature

actions:

  • utter_greet

  • utter_goodbye

  • utter_did_that_help

  • utter_unclear

  • utter_city_name

  • utter_Oppo_shop_location

  • utter_provide_founder

  • utter_about_OPPO

  • utter_brand_info

  • utter_CustomerCare_info

  • utter_Service_Center_OR_Factory

  • utter_CEO_info

  • utter_Official_Website

  • utter_OPPO_Phones_Price

  • utter_Customer_enquiry_model

  • utter_Oppo_product_comparison

  • utter_model_name_lookout

  • utter_mood_affirm

  • utter_mood_deny

  • utter_happy

  • utter_more_info

  • utter_thanks

  • utter_deny

  • utter_confirm

  • utter_check_another_one

  • action_save_city_name

  • action_get_service_centre_location

  • action_slot_reset

  • action_get_shop_location

  • action_save_model_name

  • action_get_model_price

  • action_restart

  • action_get_model_config templates: utter_greet:

    • text: “Hey, {PERSON}!This is Ollie,your assistant.How may I help you?”
    • text: “Hi {PERSON}!I am here to help.Shoot!”
    • text: “Hi,how can I help you?”

    utter_goodbye:

    • text: “Bye {PERSON} and take care!”
    • text: “Bye”

    utter_did_that_help:

    • text: “Did that help you {PERSON}?”

    utter_unclear:

    • text: “I am not sure what you are aiming for.”

    utter_thanks:

    • text: “You are very welcome.”
    • text: “Glad I could help!” utter_deny:
    • text: “That’s a shame. Let me know if you change your mind.”

    utter_provide_founder:

    • text: “Oppo’s founder is Chen Mingyong.”

    utter_about_OPPO:

    • text: “Oppo Electronics Corporation, commonly referred to as Oppo, is a Chinese consumer electronics and mobile communication company, known for its smartphones, Blu-ray players and other electronic devices. A leading manufacturer of smartphones, Oppo was the top smartphone brand in China in 2016 and was ranked No. 8 worldwide”

    utter_brand_info:

    • text: “I work for Oppo Mobile”

    utter_CustomerCare_info:

    • text: “Oppo’s customer care number is 1800 103 2777”

    utter_CEO_info:

    • text: “CEO of Oppo is Chen Mingyong.Started his position from 2/11/2017.”

    utter_Official_Website:

    • text: “Official website is: www.oppo.in”

    utter_Oppo_product_comparison:

    • text: “Decision is yours:Here is the feature list of {model} and {model}:”

    utter_happy:

    • text: “Great carry on!”

    utter_more_info:

    • text: “Please provide more details so that i can understand your query”

    utter_mood_affirm:

    • text: “Glad that i was useful.Next Question if any?”

    utter_mood_deny:

    • text: “Try again!”

    utter_city_name:

    • text: “Which city are you from {PERSON}?”
    • text: “Which city are you from?”
    • text: “Name of the city please?”

    utter_confirm:

    • text: “I will be making inquiry for customer_location: {customer_location}. Is that correct?” utter_check_another_one:
    • text: “Do you want to make another inquiry?”

This basically means your intent isn’t getting classified correctly. Run the NLU server and hit the chat query once to see if it correctly identifies the intent

I checked the chat query and the intents are being classified correctly by the NLU server. for the query : “Hi I am Arghya” the result of pprint(interpreter.parse(“I am Arghya”)) is

{‘entities’: [{‘confidence’: None, ‘end’: 14, ‘entity’: ‘PERSON’, ‘extractor’: ‘ner_mitie’, ‘start’: 8, ‘value’: ‘Arghya’}], ‘intent’: {‘confidence’: 0.6571330642134279, ‘name’: ‘greet’}, ‘intent_ranking’: [{‘confidence’: 0.6571330642134279, ‘name’: ‘greet’}, {‘confidence’: 0.09446779527877744, ‘name’: ‘city_name’}, {‘confidence’: 0.0400228170128286, ‘name’: ‘mood_deny’}, {‘confidence’: 0.03340266453139138, ‘name’: ‘goodbye’}, {‘confidence’: 0.019552058361452504, ‘name’: ‘Customer_enquiry_model’}, {‘confidence’: 0.019350730188458353, ‘name’: ‘Oppo_product_comparison’}, {‘confidence’: 0.01843151750064483, ‘name’: ‘mood_affirm’}, {‘confidence’: 0.016625951193141118, ‘name’: ‘CustomerCare_info’}, {‘confidence’: 0.016560706697613795, ‘name’: ‘model_name_lookout’}, {‘confidence’: 0.013907684670814468, ‘name’: ‘provide_founder’}], ‘text’: ‘Hi I am Arghya’}