01. Custom Actions

Parcel io
Jun 2, 2021

Intención: Dar la hora

actions.py

import datetime as dt 
from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
class ActionHelloWorld(Action): def name(self) -> Text:
return "action_show_time"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
dispatcher.utter_message(text=f"{dt.datetime.now()}") return []

nlu.yml

version: "2.0"nlu:
- intent: give_time
examples
: |
- can you tell me what time it is
- tell me the time
- got the time
- what time is it

stories.yml

version: "2.0"stories:- story: path about time
steps:

- intent: greet
- action: utter_greet
- intent: give_time
- action: action_show_time

domain.yml

version: "2.0"intents:
- give_time
actions:
- action_show_time

--

--