Below is my virtual env:
Rasa Version : 3.6.15
Minimum Compatible Version: 3.5.0
Rasa SDK Version : 3.6.2
Python Version : 3.9.18
Operating System : Windows-10-10.0.22621-SP0
Python Path : C:\Users\alvin\miniconda3\envs\rasa-bot\python.exe
I’ve added below app.py and ensured that the action_endpoint is same as the url in endpoints.yml:
from flask import Flask, render_template, request, jsonify
import requests
ACTION_ENDPOINT = "http://localhost:5055/webhook"
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
@app.route("/webhook", methods=["POST"])
def webhook():
try:
user_message = request.json["message"]
print("User Message:", user_message)
# Send user message to the custom action server and get chatbot's response
action_response = requests.post(ACTION_ENDPOINT, json={"message": user_message})
action_response.raise_for_status() # Raise an error for bad responses
action_response_json = action_response.json()
print("Action Response:", action_response_json)
if action_response_json and isinstance(action_response_json, list):
bot_response = action_response_json[0].get(
"text", "Sorry, I didn't understand that."
)
else:
bot_response = "Sorry, I didn't understand that."
return jsonify({"response": bot_response})
except KeyError:
return jsonify({"response": "Error: 'message' key not found in the request."})
except requests.exceptions.RequestException as e:
print(f"Error communicating with the custom action server: {e}")
return jsonify(
{"response": "Sorry, there was an issue processing your request."}
)
if __name__ == "__main__":
app.run(debug=True, port=3000)
I’m able to access my botbox in 127.0.0.1:3000 but whatever I entered as message, it returned back the same and the action server shows an action call within an action.
I’ve read through the archives and can’t find a solution, appreciate someone can advise me as I’m very new to Rasa.
Thank you in advance.
br/CK