Custom channel for rasa

how to create a custom rasa rest channel for the rasa_core version 0.14.5. i tried following code.

from __future__ import absolute_import

from __future__ import division

from __future__ import print_function

from __future__ import unicode_literals

import logging

from import RestInput

from rasa_core import utils

from rasa_core.agent import Agent

from rasa_core.interpreter import RasaNLUInterpreter

from import UserMessage

from import CollectingOutputChannel

from import HttpInputComponent

from flask import Blueprint, request, jsonify

logger = logging.getLogger(__name__)

class SimpleWebBot(HttpInputComponent):

    """A simple web bot that listens on a url and responds."""

    def blueprint(self, on_new_message):

        custom_webhook = Blueprint('custom_webhook', __name__)

        @custom_webhook.route("/status", methods=['GET'])

        def health():

            return jsonify({"status": "ok"})

        @custom_webhook.route("/", 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):

    #path to your NLU model

    interpreter = RasaNLUInterpreter("RT_DEMO\models")

    # path to your dialogues models

    agent = Agent.load("RT_DEMO\data\", interpreter=interpreter)

    #http api endpoint for responses

    input_channel = SimpleWebBot()

    if serve_forever:

        agent.handle_channel(HttpInputChannel(5004, "/chat", input_channel))

    return agent

it shows import error for but rasa_core version 0.14.5 is already installed can some one help me?

@akhilsiby just a note, you’re on a very old (in fact archived) version of Rasa - if you’re going to the effort of creating a custom channel, I’d highly recommend upgrading to 2.x first.

As to your code: You need to import the modules like this:

from import RestInput

Not from rasa_core.