Hello! Here is my endpoints file:
# This file contains the different endpoints your bot can use.
# Server where the models are pulled from.
# https://rasa.com/docs/rasa/model-storage#fetching-models-from-a-server
#models:
# url: http://my-server.com/models/default_core@latest
# wait_time_between_pulls: 10 # [optional](default: 100)
# Server which runs your custom actions.
# https://rasa.com/docs/rasa/custom-actions
action_endpoint:
url: "http://localhost:5055/webhook"
# Tracker store which is used to store the conversations.
# By default the conversations are stored in memory.
# https://rasa.com/docs/rasa/tracker-stores
#tracker_store:
# type: redis
# url: <host of the redis instance, e.g. localhost>
# port: <port of your redis instance, usually 6379>
# db: <number of your database within redis, e.g. 0>
# password: <password used for authentication>
# use_ssl: <whether or not the communication is encrypted, default false>
#tracker_store:
# type: mongod
# url: <url to your mongo instance, e.g. mongodb://localhost:27017>
# db: <name of the db within your mongo instance, e.g. rasa>
# username: <username used for authentication>
# password: <password used for authentication>
# Event broker which all conversation events should be streamed to.
# https://rasa.com/docs/rasa/event-brokers
#event_broker:
# url: localhost
# username: username
# password: password
# queue: queue
Here is my actions.py file:
# This files contains your custom actions which can be used to run
# custom Python code.
#
# See this guide on how to implement these action:
# https://rasa.com/docs/rasa/custom-actions
# 4/8/2022
import random
from typing import Any, Text, Dict, List
import wolframalpha
import webbrowser
import pywhatkit as kit
from pywhatkit import search
import time
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
class getTime(Action):
def name(self) -> Text:
return "action_time"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
epoch_time = 1586944173.957986
local_time = time.ctime(epoch_time)
dispatcher.utter_message(text=(f"It is {local_time}"))
return []
class givemood(Action):
def name(self) -> Text:
return "action_mood"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
dispatcher.utter_message(text=(f"This is a test"))
return []
class searchyt(Action):
def name(self) -> Text:
return "action_youtube"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
request = tracker.get_slot("video_request")
dispatcher.utter_message(text=(f"Alright one sec..."))
kit.playonyt(request)
return []
class google(Action):
def name(self) -> Text:
return "action_google"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
query = tracker.get_slot("search_request")
dispatcher.utter_message(text=(f"Alright one sec..."))
if "http" in query:
webbrowser.open_new_tab(query)
else:
search(query)
return []
class wa(Action):
def name(self) -> Text:
return "action_wa"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
query = tracker.get_slot("search_request")
dispatcher.utter_message(text=(f"Alright one sec..."))
app_id = "My Private Key"
client = wolframalpha.Client(app_id)
question = tracker.get_slot("wa_request")
res = client.query(question)
try:
answer = next(res.results).text
dispatcher.utter_message(text=(f"{answer}"))
except:
dialogue = random.randint(1, 2)
if dialogue == 1:
dispatcher.utter_message(text=(f"I don't know"))
elif dialogue == 2:
dispatcher.utter_message(text=(f"I couldn't find the answer\"))
return []
And here is my domain file:
version: "3.1"
intents:
- greet
- goodbye
- affirm
- deny
- mood_great
- mood_unhappy
- bot_challenge
- time
- thank
- fun
- mood
- ytr
- gr
- wa
actions:
- utter_fun
- utter_greet
- action_time
- action_mood
- action_youtube
- action_google
- action_wa
entities:
- video_request
- search_request
- wa_request
slots:
video_request:
type: text
influence_conversation: true
mappings:
- type: from_text
entity: video_request
intent: ytr
search_request:
type: text
influence_conversation: true
mappings:
- type: from_text
entity: search_request
intent: gr
wa_request:
type: text
influence_conversation: true
mappings:
- type: from_text
entity: wa_request
intent: wa
forms:
yt_form:
required_slots:
- video_request
gr_form:
required_slots:
- search_request
wa_form:
required_slots:
- wa_request
responses:
utter_greet:
- text: "hey"
- text: "heyyy"
- text: "hiii"
utter_cheer_up:
- text: "here's something to cheer you up:"
image: "https://i.imgur.com/nGF1K8f.jpg"
utter_did_that_help:
- text: "you ok now?"
utter_happy:
- text: "great!"
utter_goodbye:
- text: "bye!"
utter_iamabot:
- text: "I'm an AI"
- text: "I'm not a bot! I'm an AI!!"
utter_yourwelcome:
- text: "np"
- text: "your welcome!"
- text: "no problem"
utter_fun:
- text: "I like RPGs, movies, music..."
session_config:
session_expiration_time: 60
carry_over_slots_to_new_session: true