Running flask along with Rasa server


I have created a file that would listen on webhooks/twilio/webhook/ for the response from Twilio. The file is to know if the attachment received is pdf or not. My idea is that I would keep running this file so that every request is noted and if the user sends a file, it will send a message to the custom action. The file looks like:

import requests
from flask import Flask, request, redirect
from twilio.twiml.messaging_response import MessagingResponse
app = Flask(__name__)

@app.route("/webhooks/twilio/webhook/", methods=['POST'])
def receiveMedia():

    if request.values['NumMedia'] != '0':
        # Use the message SID as a filename.
        filename = request.values['MediaContentType0'] == 'application/pdf'
        image_url = request.values['MediaUrl0']
    return ""

if __name__ == '__main__':

Running this file using command python3 and then running the Rasa server conflicts each other and when the bot is deployed, it just listens to one of the instances of the server.

Any idea where I can put this code so that every response that is coming, could be received by both chatbot and file?

Apologies if I am not very clear with my question.

Thanks. :slight_smile:

I was able to accomplish this by using custom connector.