Encountered an exception while running action 'utter_example'.Bot will continue, but the actions events are lost

so i make rasabot but rasabot get answer from file format json, so i use this script in action.py

import json
from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher

class ActionGetStudentInfo1(Action):
    def name(self) -> Text:
        return "action_siswa_1"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
            
        # Baca file JSON
        with open('data/json/answer.json', 'r') as f:
            data = json.load(f)
            
        # Temukan data yang sesuai dengan intent
        for student in data:
            if student['jurusan'] == 'Rekayasa Perangkat Lunak':
                # Kirim respons ke pengguna
                dispatcher.utter_message(text=f"{student['nama']} merupakan siswa jurusan {student['jurusan']}")
                break
        
        return []
    
class ActionGetStudentInfo2(Action):
    def name(self) -> Text:
        return "action_siswa_2"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
            
        # Baca file JSON
        with open('data/json/answer.json', 'r') as f:
            data = json.load(f)
            
        # Temukan data yang sesuai dengan intent
        for student in data:
            if student['jurusan'] == 'MultiMedia':
                # Kirim respons ke pengguna
                dispatcher.utter_message(text=f"{student['nama']} merupakan siswa jurusan {student['jurusan']}")
                break
        
        return []

class ActionGetStudentInfo3(Action):
    def name(self) -> Text:
        return "action_siswa_3"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
            
        # Baca file JSON
        with open('data/json/answer.json', 'r') as f:
            data = json.load(f)
            
        # Temukan data yang sesuai dengan intent
        for student in data:
            if student['jurusan'] == 'Manajemen Perkantoran':
                # Kirim respons ke pengguna
                dispatcher.utter_message(text=f"{student['nama']} merupakan siswa jurusan {student['jurusan']}")
                break
        
        return []

and this data in file format json :

[
    {
        "id" : "1",
        "nama" : "Aiyub Heriyanto",
        "jurusan" : "Rekayasa Perangkat Lunak",
        "intent" : "siswa_1"
    },
    {
        "id" : "2",
        "nama" : "Afand Fathur Rozi",
        "jurusan" : "MultiMedia",
        "intent" : "siswa_2"
    },
    {
        "id" : "3",
        "nama" : "Dhony Fajriansyah",
        "jurusan" : "Manajamen Perkantoran",
        "intent" : "siswa_3"
    }
]

but if i run rasa shell i got error like this:

2023-03-03 14:01:54 ERROR    rasa.core.processor  - Encountered an exception while running action 'utter_example'.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 "C:\Users\aiyub\anaconda3\lib\site-packages\rasa\core\processor.py", line 874, in _run_action
    events = await action.run(
  File "C:\Users\aiyub\anaconda3\lib\site-packages\rasa\core\actions\action.py", line 305, in run
    message = await nlg.generate(self.utter_action, tracker, output_channel.name())
  File "C:\Users\aiyub\anaconda3\lib\site-packages\rasa\core\nlg\callback.py", line 74, in generate
    response = await self.nlg_endpoint.request(
  File "C:\Users\aiyub\anaconda3\lib\site-packages\rasa\utils\endpoints.py", line 173, in request
    raise ClientResponseError(
rasa.utils.endpoints.ClientResponseError: 404, Not Found, body='b'{"description":"Not Found","status":404,"message":"Requested URL /nlg not found"}''

how to solve this problem ?

Have you tried altering the URL for NLG? The error states it can’t access NLG server.

1 Like

Yes i tried to altering with nlg server but i don’t know how to use nlg server in rasa so i use custom action

I see. Have you followed everything inside the NLG Servers and setup your own NLG server to listen on the given endpoint?

Let me know what you did so far and maybe I can give you a hand with this.