Rasa with webservice

I want webservice response as a intent

You do this by customizing your own actions. You can check out this repo on how they are using their location api

I could not find the tell me a joke repo but I have the code, hope this helps.

import logging
import requests
import json
from rasa_core_sdk import Action

logger = logging.getLogger(__name__)


class ActionJoke(Action):
    def name(self):
        # define the name of the action which can then be included in training stories
        return "action_joke"

    def run(self, dispatcher, tracker, domain):
        # what your action should do
        request = json.loads(
            requests.get("https://api.chucknorris.io/jokes/random").text
        )  # make an api call
        joke = request["value"]  # extract a joke from returned json response
        dispatcher.utter_message(joke)  # send the message back to the user
        return []

This repo is also pretty good too~ https://github.com/RasaHQ/rasa-demo/tree/master/demo

1 Like