i am facing this issue:TypeError: ‘Response’ object is not subscriptable. i am trying to make cryptocurrency chatbot with rasa but when I run the code from actions.py that error occur here is the code:
from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.events import SlotSet
from rasa_sdk.executor import CollectingDispatcher
import requests
class Actioncrypto(Action):
def name(self) -> Text:
return "action_get_crypto"
def run(self, dispatcher: CollectingDispatcher,tracker: Tracker, domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
loc= tracker.get_slot('crypto')
re= requests.get('https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?CMC_PRO_API_KEY=###'.format(loc)).json()
current= re.json()
print (current)
priceof= current['data']['quote']['USD']['price']
nameof=current['data']['name']
response = """here is the price of {} : {}""".format(nameof,priceof)
dispatcher.utter_message(response)
return [SlotSet('crypto', loc)]