Hi,
Can someone please provide an example of custom input channel on rasa core “version”: “0.12.3”. Below is the code I am using , but getting error as
agent.handle_channels(InputChannel(5004, “/chat”, input_channel)) TypeError: object() takes no parameters
Here is my app.py
from __future__ import print_function
from __future__ import unicode_literals
import logging
from rasa_core.channels import InputChannel
from rasa_core import utils
from rasa_core.agent import Agent
from rasa_core.interpreter import RasaNLUInterpreter
from rasa_core.channels.channel import UserMessage
from rasa_core.channels.channel import CollectingOutputChannel
from rasa_core.utils import EndpointConfig
from flask import Blueprint, request, jsonify
logger = logging.getLogger(__name__)
class SimpleWebBot(InputChannel):
def blueprint(self, on_new_message):
custom_webhook = Blueprint('custom_webhook', __name__)
@custom_webhook.route("/", methods=['GET'])
def health():
return jsonify({"status": "ok"})
@custom_webhook.route("/webhook", methods=['POST'])
def receive():
payload = request.json
sender_id = payload.get("sender", None)
text = payload.get("message", None)
out = CollectingOutputChannel()
on_new_message(UserMessage(text, out, sender_id))
responses = [m for _, m in out.messages]
return jsonify(responses)
return custom_webhook
def run(serve_forever=True):
interpreter = RasaNLUInterpreter("projects/default/mybotnlu")
action_endpoint = EndpointConfig(url="http://localhost:5055/webhook")
agent = Agent.load("projects/dialogue", interpreter=interpreter , action_endpoint=action_endpoint)
input_channel = SimpleWebBot()
if serve_forever:
agent.handle_channels(InputChannel(5004, "/chat", input_channel))
return agent
if __name__ == '__main__':
utils.configure_colored_logging(loglevel="INFO")
run()