Skip to content

Instantly share code, notes, and snippets.

@cgawron
Created October 6, 2023 08:58
Show Gist options
  • Save cgawron/1a24e64d23a4bec33585d7389613ba0a to your computer and use it in GitHub Desktop.
Save cgawron/1a24e64d23a4bec33585d7389613ba0a to your computer and use it in GitHub Desktop.
from rasa_sdk import Action
from rasa_sdk.events import SlotSet
import requests
class ActionTellJoke(Action):
def name(self) -> Text:
return "action_tell_joke"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
response = requests.get('https://witzapi.de/api/joke/')
joke = response.json()
joketext = joke[0]['text']
dispatcher.utter_message(text=joketext)
return []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment