Hi i want to write custom action for weather api how can write api url: http://api.weatherstack.com/ api key : 062863cfebd4ad1479b484ce0dbfd228
intents like: what is the weather in london
Hi i want to write custom action for weather api how can write api url: http://api.weatherstack.com/ api key : 062863cfebd4ad1479b484ce0dbfd228
intents like: what is the weather in london
hey @sunilskn, check this out:
hey @sunilskn, you can do like this , just replace the url and parse the data , must be working
from rasa_sdk import Action
from rasa_sdk.events import SlotSet
import requests
import json
class ActionCheckWeather(Action):
def name(self):
return "action_check_api"
def run(self, dispatcher, tracker, domain):
response = requests.get("https://jsonplaceholder.typicode.com/todos/1")
jsonResponse = response.json()
title = jsonResponse["title"]
id = jsonResponse["id"]
messageToUser = "The user id is {} and title is {} And this coming from an api call".format(id, title)
dispatcher.utter_message(messageToUser)
return []