Hi I am tryind to use the custom channel implementation from rasa docs getting below error while hitting from postman. In Rasa 1.10 Any help is appreciated @Juste
[2021-03-11 16:39:36 +0530] [19968] [ERROR] Exception occurred while handling uri: 'http://localhost:5005/webhooks/myio/webhook'
Traceback (most recent call last):
File "\local\continuum\anaconda3\envs\rasax\lib\site-packages\sanic\app.py", line 976, in handle_request
response = await response
File "\custom_channel.py", line 50, in receive
metadata=metadata,
File "\local\continuum\anaconda3\envs\rasax\lib\site-packages\rasa\core\channels\channel.py", line 83, in handler
await app.agent.handle_message(*args, **kwargs)
File "local\continuum\anaconda3\envs\rasax\lib\site-packages\rasa\core\agent.py", line 486, in handle_message
return await processor.handle_message(message)
File "\local\continuum\anaconda3\envs\rasax\lib\site-packages\rasa\core\processor.py", line 94, in handle_message
tracker = await self.log_message(message, should_save_tracker=False)
File "\local\continuum\anaconda3\envs\rasax\lib\site-packages\rasa\core\processor.py", line 252, in log_message
await self._handle_message_with_tracker(message, tracker)
File "\local\continuum\anaconda3\envs\rasax\lib\site-packages\rasa\core\processor.py", line 486, in _handle_message_with_tracker
parse_data = await self._parse_message(message, tracker)
File "local\continuum\anaconda3\envs\rasax\lib\site-packages\rasa\core\processor.py", line 459, in _parse_message
if message.text.startswith(INTENT_MESSAGE_PREFIX):
AttributeError: 'NoneType' object has no attribute 'startswith'
credential.yml
custom_channel.MyIO:
custom_channel.py
class MyIO(InputChannel):
def name(self) -> Text:
"""Name of your custom channel."""
return "myio"
def blueprint(
self, on_new_message: Callable[[UserMessage], Awaitable[None]]
) -> Blueprint:
custom_webhook = Blueprint(
"custom_webhook_{}".format(type(self).__name__),
inspect.getmodule(self).__name__,
)
@custom_webhook.route("/", methods=["GET"])
async def health(request: Request) -> HTTPResponse:
return response.json({"status": "ok"})
@custom_webhook.route("/webhook", methods=["POST"])
async def receive(request: Request) -> HTTPResponse:
sender_id = request.json.get("sender") # method to get sender_id
text = request.json.get("text") # method to fetch text
input_channel = self.name() # method to fetch input channel
metadata = self.get_metadata(request) # method to get metadata
collector = CollectingOutputChannel()
await on_new_message(
UserMessage(
text,
collector,
sender_id,
input_channel=input_channel,
metadata=metadata,
)
)
return response.json(collector.messages)
return custom_webhook