Rasa run actions no work


import requests

    def Weather(city):
        api_address='api.openweathermap.org/data/2.5/weather?q={city name}&appid=484efc438f3dff6deba09dac61f1'
        url = city + api_address
        json_data = requests.get(url).json()
        format_add = json_data['main']
        return format_add


from typing import Any, Text, Dict, List

from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
from weather import Weather

class ActionHelloWorld(Action):
    def name(self) -> Text:
        return "action_weather_api"

    async def run(self, dispatcher: CollectingDispatcher,
             tracker: Tracker,
             domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
         dispatcher.utter_message(template="utter_temp" , tracker, temp=temp)

         return []


import requests

def Weather(city):
    url = base_url +"zip=" + city + ",us"  + "&appid=" + api_key + "&units=metric"
    weather = requests.get(url).json()

return weather ['main']

Do check the code first using app key base url and city ok run and check JSON data return or not? I just wrote the code, so check it.

@Rishabhh17 Try run and then see the error for action.py

How can I check through GCP terminal ?

It shows me this. This is in one terminal.

(bot) D:\chatbot\actions>rasa run actions
2021-08-12 13:53:17 INFO     rasa_sdk.endpoint  - Starting action endpoint server...
2021-08-12 13:53:17 ERROR    rasa_sdk.executor  - Failed to register package 'actions'.
Traceback (most recent call last):
  File "D:\Anaconda3\envs\bot\lib\site-packages\rasa_sdk\executor.py", line 262, in register_package
  File "D:\Anaconda3\envs\bot\lib\site-packages\rasa_sdk\executor.py", line 218, in _import_submodules
    package = self._import_module(package)
  File "D:\Anaconda3\envs\bot\lib\site-packages\rasa_sdk\executor.py", line 239, in _import_module
    module = importlib.import_module(name)
  File "D:\Anaconda3\envs\bot\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "D:\chatbot\actions\actions.py", line 14, in <module>
    from weather import Weather
ImportError: cannot import name 'Weather' from 'weather' (D:\chatbot\actions\weather.py)

When I talk to the bot then it shows that action server is not active. This in another terminal.

Bot loaded. Type a message and press enter (use '/stop' to exit): 
Your input ->  Hi                                                                                                           
Hey! How are you?
Your input ->  What is the weather today                                                                                    
Which city do you want to check for?.
Your input ->  Dubai                                                                                                        
2021-08-12 14:09:39 ERROR    rasa.core.actions.action  - Failed to run custom action 'action_weather_api'. Couldn't connect 
to the server at 'http://localhost:5055/webhook'. Is the server running? Error: Cannot connect to host localhost:5055 ssl:default [The remote computer refused the network connection]
2021-08-12 14:09:39 ERROR    rasa.core.processor  - Encountered an exception while running action 'action_weather_api'.Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.
Traceback (most recent call last):
  File "D:\Anaconda3\envs\bot\lib\site-packages\aiohttp\connector.py", line 969, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa
  File "D:\Anaconda3\envs\bot\lib\asyncio\base_events.py", line 1017, in create_connection
    raise exceptions[0]
  File "D:\Anaconda3\envs\bot\lib\asyncio\base_events.py", line 1002, in create_connection
    sock = await self._connect_sock(
  File "D:\Anaconda3\envs\bot\lib\asyncio\base_events.py", line 916, in _connect_sock
    await self.sock_connect(sock, address)
  File "D:\Anaconda3\envs\bot\lib\asyncio\proactor_events.py", line 702, in sock_connect
    return await self._proactor.connect(sock, address)
  File "D:\Anaconda3\envs\bot\lib\asyncio\windows_events.py", line 808, in _poll
    value = callback(transferred, key, ov)
  File "D:\Anaconda3\envs\bot\lib\asyncio\windows_events.py", line 595, in finish_connect
ConnectionRefusedError: [WinError 1225] The remote computer refused the network connection

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\Anaconda3\envs\bot\lib\site-packages\rasa\core\actions\action.py", line 685, in run
    response = await self.action_endpoint.request(
  File "D:\Anaconda3\envs\bot\lib\site-packages\rasa\utils\endpoints.py", line 163, in request
    async with session.request(
  File "D:\Anaconda3\envs\bot\lib\site-packages\aiohttp\client.py", line 1117, in __aenter__
    self._resp = await self._coro
  File "D:\Anaconda3\envs\bot\lib\site-packages\aiohttp\client.py", line 520, in _request
    conn = await self._connector.connect(
  File "D:\Anaconda3\envs\bot\lib\site-packages\aiohttp\connector.py", line 535, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "D:\Anaconda3\envs\bot\lib\site-packages\aiohttp\connector.py", line 892, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "D:\Anaconda3\envs\bot\lib\site-packages\aiohttp\connector.py", line 1051, in _create_direct_connection
    raise last_exc
  File "D:\Anaconda3\envs\bot\lib\site-packages\aiohttp\connector.py", line 1020, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "D:\Anaconda3\envs\bot\lib\site-packages\aiohttp\connector.py", line 975, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host localhost:5055 ssl:default [The remote computer refused the network connection]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Anaconda3\envs\bot\lib\site-packages\rasa\core\processor.py", line 772, in _run_action
    events = await action.run(
  File "D:\Anaconda3\envs\bot\lib\site-packages\rasa\core\actions\action.py", line 717, in run
    raise RasaException("Failed to execute custom action.")
rasa.shared.exceptions.RasaException: Failed to execute custom action.