This looks great, but I think I still need some help to implement it in the right way. Please check the format of my class CheckWorkingHours!
This is what I have done:
- text: "hi, I am your bot."
- text: "My dear customer. How can I help you?"
- text: "the price is only 1 Dollar"
- text: "Sorry my dear customer. Our service time starts at 7am and ends at 7 pm. This chat will end now. Please contact us later."
from datetime import datetime
import datetime as dt
def name(self): # type: () -> Text
def run(self, dispatcher, tracker, domain):
# type: (CollectingDispatcher, Tracker, Dict[Text, Any]) -> List[Dict[Text, Any]]
now = datetime.datetime.now()
today18pm = now.replace(hour=18, minute=0, second=0, microsecond=0)
today13am = now.replace(hour=13, minute=0, second=0, microsecond=0)
if today13am > now < today18pm:
message = 'Sorry my dear customer. Our service time starts at 7am and ends at 7 pm. This chat will end now. Please contact us later.'
message = 'How can I help you?'
I have also changed the story in order to call the action class. Is this the correct way?
Note, I know for sure, that the customer will always start with the intent greet. This is for sure due to some other reasons. Would it be enough, if my action class will be called only at this point? If the time is in between service time, the chatbot will run as usuall. Otherwise the chatbot will ask the customer to come back later. Done!
At the moment I get the following error message:
rasa_core.actions.action - Failed to run custom action 'action_check_working_hours'. Action server responded with a non 200 status code of 500. Make sure your action server properly runs actions and returns a 200 once the action is executed. Error: 500 Server Error: INTERNAL SERVER ERROR for url: http://localhost:5055/webhook
2019-06-13 14:28:51 ERROR rasa_core.processor - Encountered an exception while running action 'action_check_working_hours'. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code.