I have a custom channel setup but when I make a request to that channel I get the default response instead. The custom channel code:
from rasa.core.channels.channel import RestInput, InputChannel,
OutputChannel, UserMessage, CollectingOutputChannel
from rasa.utils.common import raise_warning
from sanic import Blueprint, response
from sanic.request import Request
from sanic.response import HTTPResponse
from typing import Any, Awaitable, Callable, Dict, List, Optional, Text
class SparkGatewayRestInput(InputChannel):
@classmethod
def name(cls) -> Text:
return "spark-gateway"
@classmethod
def blueprint(
self, on_new_message: Callable[[UserMessage], Awaitable[Any]]
) -> Blueprint:
spark_webhook = Blueprint("spark_webhook", __name__)
@spark_webhook.route("/", methods=["GET"])
async def health(_: Request) -> HTTPResponse:
return response.json({"status": "ok"})
@spark_webhook.route("/webhook", methods=["POST"])
async def webhook(request: Request) -> HTTPResponse:
req_json = request.json
sender_id = req_json.get("sender", None)
text = req_json.get("message", None)
input_channel = req_json.get("input_channel") or self.name()
metadata = req_json.get("metadata", None)
collector = CollectingOutputChannel()
try:
await on_new_message(
UserMessage(
text,
collector,
sender_id,
input_channel=input_channel,
metadata=metadata,
)
)
except Exception:
logger.exception(
f"An exception occured while handling "
f"user message '{text}'."
)
return response.json(collector.messages)
return spark_webhook
I did notice that collector.messages returns an empty array, not sure if that is the issue here.
Here is an example response yaml:
utter_something:
- text: This is the default response
- text: This is the custom channel response
channel: spark-gateway
Im making the request to /webhooks/spark-gateway/webhook