How to call rasa from an existing assistant

How do I call rasa from this code snippet?

from gtts import gTTS import speech_recognition as sr import os

import re

import webbrowser import smtplib

import requests

from weather import Weather

def talkToMe(audio): # “speaks audio passed as argument”

for line in audio.splitlines():
    os.system("say " + audio)

#  use the system's inbuilt say command instead of mpg123
#  text_to_speech = gTTS(text=audio, lang='en')
#  os.system('mpg123 audio.mp3')

def myCommand(): # “listens for commands”

r = sr.Recognizer()

with sr.Microphone() as source:
    r.pause_threshold = 1
    r.adjust_for_ambient_noise(source, duration=1)
    audio = r.listen(source)

    command = r.recognize_google(audio).lower()
    print('You said: ' + command + '\n')  How can I call rasa here?

#loop back to continue to listen for commands if unrecognizable speech is received
except sr.UnknownValueError:
    print('Your last command couldn\'t be heard')
    command = myCommand();

return command

def assistant(command): “if statements for executing commands”

if 'open reddit' in command:
    reg_ex ='open reddit (.*)', command)
    url = ''
    if reg_ex:
        subreddit =
        url = url + 'r/' + subreddit

elif 'open website' in command:
    reg_ex ='open website (.+)', command)
    if reg_ex:
        domain =
        url = 'https://www.' + domain

elif 'what\'s up' in command:
    talkToMe('Just doing my thing')
# elif 'joke' in command:
#     res = requests.get(
#             '',
#             headers={"Accept":"application/json"}
#             )
#     if res.status_code ==
#         talkToMe(str(res.json()['joke']))
#     else:
#         talkToMe('oops!I ran out of jokes')

# elif 'current weather in' in command:
#     reg_ex ='current weather in (.*)', command)
#     if reg_ex:
#         city =
#         weather = Weather()
#         location = weather.lookup_by_location(city)
#         condition = location.condition()
#         talkToMe('The Current weather in %s is %s The tempeture is %.1f degree' % (city, condition.text(), (int(condition.temp())-32)/1.8))
# elif 'weather forecast in' in command:
#     reg_ex ='weather forecast in (.*)', command)
#     if reg_ex:
#         city =
#         weather = Weather()
#         location = weather.lookup_by_location(city)
#         forecasts = location.forecast()
#         for i in range(0,3):
#             talkToMe('On %s will it %s. The maximum temperture will be %.1f degree.'
#                      'The lowest temperature will be %.1f degrees.' % (forecasts[i].date(), forecasts[i].text(), (int(forecasts[i].high())-32)/1.8, (int(forecasts[i].low())-32)/1.8))

elif 'email' in command:
    talkToMe('Who is the recipient?')
    recipient = myCommand()

    if 'John' in recipient:
        talkToMe('What should I say?')
        content = myCommand()

        #init gmail SMTP
        mail = smtplib.SMTP('', 587)

        #identify to server

        #encrypt session

        mail.login('username', 'password')

        #send message
        mail.sendmail('John Fisher', '', content)

        #end mail connection

        talkToMe('Email sent.')

        talkToMe('I don\'t know what you mean!')

talkToMe(‘I am ready for your command’)

#loop to continue executing multiple commands while True: assistant(myCommand())

Hey @MikeyBeez. I think I would try building a small custom connector which would define your bot’s input and output channels and connect your Rasa assistant to it. So basically, you would build your assistant with Rasa, define a custom connector like the following: Custom Connectors. Then when you start the assistant’s server, it should listen for your input’s through the input channel you defined. There are a few tutorials where I build custom connectors. For example: Going beyond ‘Hey Google’: building a Rasa-powered Google Assistant. Have a look and let me know if there is anything more specifically I can help.