def run_telegram_bot(train=False, nlu_name=None, voice_output=False, url=None): webhook_url, bot_name, telegram_api_key = load_dm_config() if url: webhook_url = url + '/app/webhook' if train: train_bot() if not test_neo4j_connection(): return # Set Interpreter (NLU) to th given engine interpreter = select_interpreter(nlu_name) # load the trained agent model agent = Agent.load('./models/dialogue', interpreter) logging.info('Agent model loaded.') logging.info('Starting Telegram channel...') try: if voice_output: input_channel = (TelegramCustomInput(access_token=telegram_api_key, verify=bot_name, webhook_url=webhook_url, debug_mode=True)) else: input_channel = (TelegramInput(access_token=telegram_api_key, verify=bot_name, webhook_url=webhook_url, debug_mode=True)) agent.handle_channel(HttpInputChannel(5004, '/app', input_channel)) except Exception as err: logging.error("Error starting Telegram Channel: {}".format(err))
def run_concertbot_online(interpreter, domain_file="domain.yml", training_data_file='data/stories.md'): YOUR_FB_VERIFY = "rasa-bot" YOUR_FB_SECRET = "a9f5370c907e14a983051bd4d266c47b" YOUR_FB_PAGE_ID = "158943344706542" YOUR_FB_PAGE_TOKEN = "EAACZAVkjEPR8BANiwfuKaSVz8yxtLsytuOPvaUzUTlCMAmvuX9TdqGR5P4F1EepBfZCQoKhSR49zM5C9pYX9hmmv3qqiUnRCMDE0eJ1lWRjeqNYTLLA5nbXelSMw0p7neZBSyyIcNHS3e1lbbf2raWPY8IUosJZBMlDLLA7ZBJgTxZAZCvhbO84" input_channel = FacebookInput( fb_verify= YOUR_FB_VERIFY, # you need tell facebook this token, to confirm your URL fb_secret=YOUR_FB_SECRET, # your app secret fb_tokens={YOUR_FB_PAGE_ID: YOUR_FB_PAGE_TOKEN}, # page ids + tokens you subscribed to debug_mode=True # enable debug mode for underlying fb library ) agent = Agent(domain_file, policies=[MemoizationPolicy(), KerasPolicy()], interpreter=interpreter) #agent.handle_channel() agent.train_online(training_data_file, input_channel=HttpInputChannel(8080, "", input_channel), max_history=2, batch_size=50, epochs=200, max_training_samples=300) return agent
def run_telegram_bot(webhook_url, train=False): logging.basicConfig(level="INFO") try: KnowledgeGraph() except ServiceUnavailable: print('Neo4j connection failed. Program stopped.') return if train: train_bot() with open('keys.json') as f: data = json.load(f) telegram_api_key = data['telegram-api-key'] # set webhook of telegram bot try: telegram_url = 'https://api.telegram.org/bot' + telegram_api_key + '/setWebhook?url=' + webhook_url urllib.request.urlopen(telegram_url) except: print("Error setting telegram webhook") return interpreter = Interpreter() agent = Agent.load('./models/dialogue', interpreter) input_channel = (TelegramInput(access_token=telegram_api_key, verify='event123_bot', webhook_url=webhook_url, debug_mode=True)) agent.handle_channel(HttpInputChannel(5004, '/app', input_channel))
def run(serve_forever=True): interpreter = RasaNLUInterpreter("models/nlu/default/nlu_mod") agent = Agent.load('models/current/dialogue', interpreter=interpreter) input_channel = SimpleWebBot() if serve_forever: agent.handle_channel(HttpInputChannel(5004, "/chat", input_channel)) return agent
def run(serve_forever=True): #path to your NLU model nlu_interpreter = SnipsInterpreter() agent = Agent.load('./models/dialogue', interpreter=nlu_interpreter) #http api endpoint for responses input_channel = SimpleWebBot() if serve_forever: agent.handle_channel(HttpInputChannel(5010, '/', input_channel)) return agent
def run(): interpreter = RasaNLUInterpreter('models/nlu/default/current') agent = Agent.load('models/dialogue', interpreter=interpreter) input_channel = TelegramInput(access_token=TELEGRAM_ACCESS_TOKEN, verify=VERIFY, webhook_url=WEBHOOK_URL) agent.handle_channel(HttpInputChannel(5002, "", input_channel))
def run(serve_forever=True): # path to your NLU model interpreter = RasaNLUInterpreter("models/nlu/default/nlu_model") # path to your dialogues models agent = Agent.load("models/dialogue/default/dialogue_model", interpreter=interpreter) # http api endpoint for responses input_channel = TicketBot() if serve_forever: agent.handle_channel(HttpInputChannel(5004, "/", input_channel)) return agent
def run(serve_forever=True): # path to your NLU model interpreter = RasaNLUInterpreter("models/default/current") # path to your dialogues models agent = Agent.load("models/default/dialogue", interpreter=interpreter) # http api endpoint for responses input_channel = EdpAhdWebBot() if serve_forever: agent.handle_channel(HttpInputChannel(5004, "/chat", input_channel)) return agent
def server(serve_forever=True): # path to your NLU model interpreter = RasaNLUInterpreter("models/nlu/default/current") # path to your dialogues models agent = Agent.load("models/stories", interpreter=interpreter) # http api endpoint for responses input_channel = SimpleWebBot() if serve_forever: agent.handle_channel(HttpInputChannel(7454, "/bot", input_channel)) return agent
def runSlack(serve_forever=True): from rasa_core.channels import HttpInputChannel from rasa_core.channels.slack import SlackInput from rasa_core.agent import Agent from rasa_core.interpreter import RegexInterpreter # load your trained agent interpreter = RasaNLUInterpreter( "models/nlu/default/model_20180529-103257") agent = Agent.load("models/dialogue", interpreter=interpreter) input_channel = SlackInput( slack_token= "xoxb-371047401462-369661464209-wcn44I8JzTIfJVwE6soZp6XH", # this is the `bot_user_o_auth_access_token` #slack_channel = "@Bot-test" # the name of your channel to which the bot posts (optional) ) print(HttpInputChannel(5004, "/app", input_channel)) agent.handle_channel(HttpInputChannel(5002, "/app", input_channel))
def run_voice_channel(train=False, nlu_name=None, url=None): if train: train_bot() if url: webhook_url = url + '/app/webhook' interpreter = select_interpreter(nlu_name) agent = Agent.load('./models/dialogue', interpreter) input_channel = VoiceInput() agent.handle_channel(HttpInputChannel(5004, '/app', input_channel))
def run(serve_forever=True): #path to your NLU model interpreter = RasaNLUInterpreter( "models/nlu_v14/default/model_20180521-100433") # path to your dialogues models agent = Agent.load("models/dialogue", interpreter=interpreter) #http api endpoint for responses input_channel = SimpleWebBot() if serve_forever: agent.handle_channel(HttpInputChannel(5004, "/chat", input_channel)) return agent
def run_mood(serve_forever=True): agent = Agent.load("models/dialogue", interpreter = RasaNLUInterpreter("models/nlu/default/current")) input_channel = SlackInput(slack_token="xoxb-313317646164-lJx89zZa02JztX9Bcc40vAvn", # this is the `bot_user_o_auth_access_token` slack_channel="general" # the name of your channel to which the bot posts ) if serve_forever: agent.handle_channel(HttpInputChannel(5004, "/app", input_channel)) agent.handle_channel(ConsoleInputChannel()) return agent
def run(serve_forever=True): agentFolder = os.getcwd() + "/projects/Lambton/models/dialogue" interpreterFolder = os.getcwd( ) + "/projects/Lambton/models/nlu/default/current" #path to your NLU model interpreter = RasaNLUInterpreter(interpreterFolder) # path to your dialogues models agent = Agent.load(agentFolder, interpreter=interpreter) #http api endpoint for responses input_channel = nuRobot() if serve_forever: agent.handle_channel(HttpInputChannel(5004, "/chat", input_channel)) return agent
def run_nlu_core_server(port_number, serve_forever=True): #path to your NLU model # interpreter = RasaNLUInterpreter("./models/nlu/default/weathernlu") interpreter = "./models/nlu/default/weathernlu" # path to your dialogues models agent = Agent.load("./models/dialogue", interpreter=interpreter) #http api endpoint for responses input_channel = SimpleWebBot() if serve_forever: agent.handle_channel( HttpInputChannel(port_number, "/chat", input_channel)) return agent
def run(serve_forever=True): interpreter = RasaNLUInterpreter("models/nlu/default/current") #agent = Agent.load("models/dialogue", interpreter=interpreter) default_domain = TemplateDomain.load("domain.yml") agent = Agent(default_domain, policies=[SimplePolicy()], interpreter=interpreter) if serve_forever: #agent.handle_channel(ConsoleInputChannel()) agent.handle_channel( HttpInputChannel(3000, "/app", input_channel_telegram)) return agent
def run_bot(slack_params, console = False): nlu_interpreter = RasaNLUInterpreter('models/nlu/default/intents') agent = Agent.load('models/dialouge', interpreter=nlu_interpreter) if console == True: agent.handle_channel(ConsoleInputChannel()) else: input_channel = SlackInput(slack_params['slack_dev_token'], slack_params['slack_client_token'], slack_params['verification_token'], True) agent.handle_channel(HttpInputChannel(5004, "/", input_channel)) return agent
def run_slack_bot(): print("Loading agent...") # load your trained agent agent = run_bot() print("Agent loaded.") input_channel = SlackInput( slack_token=os. environ['SLACK_TOKEN'], # this is the `bot_user_o_auth_access_token` ) print("Starting server on port 5004") agent.handle_channel(HttpInputChannel(5004, "/app", input_channel))
def run(serve_forever=True): #path to your NLU model interpreter = RasaNLUInterpreter( "C:/Srikanth/2018-Hackathon/git/myHR/CustomerBot/customer_bot-master/models/nlu/current/" ) # path to your dialogues models agent = Agent.load( "C:/Srikanth/2018-Hackathon/git/myHR/CustomerBot/customer_bot-master/models/dialogue/", interpreter=interpreter) #http api endpoint for responses input_channel = SimpleWebBot() if serve_forever: agent.handle_channel(HttpInputChannel(5000, "/parse", input_channel)) return agent
def run(serve_forever=True): #path to your NLU model interpreter = RasaNLUInterpreter("models/current/nlu") # path to your dialogues models agent = Agent.load("models/current/dialogue", interpreter=interpreter) #http api endpoint for responses #input_channel = SimpleWebBot() input_channel = \ SlackInput(slack_token='xoxb-525465834114-525382855891-SYt6HyWl7IfVyhtX19z6jJec' , slack_channel='@devops') # this is the `bot_user_o_auth_access_token` if serve_forever: agent.handle_channel(HttpInputChannel(5004, "/chat", input_channel)) return agent
def run(serve_forever=True): #path to your NLU model interpreter = RasaNLUInterpreter( "C:/Murali/Testing/hackathon2018/customer_bot-master/models/nlu/current" ) # path to your dialogues models agent = Agent.load( "C:/Murali/Testing/hackathon2018/customer_bot-master/models/dialogue", interpreter=interpreter) #http api endpoint for responses input_channel = SimpleWebBot() if serve_forever: agent.handle_channel(HttpInputChannel(5009, "/chat", input_channel)) return agent
def run(serve_forever=True): # training_data_file = "data/stories.md" interpreter = RasaNLUInterpreter("model/nlu/default/current") # training_data = agent.load_data(STORIES) agent = Agent.load(MODEL_DIALOGUE, interpreter=interpreter) # agent = Agent.load(MODEL_DIALOGUE_TENSORFLOW)#, interpreter=interpreter) # input_channel = get_input_channel() # agent.handle_channel(input_channel) input_channel = get_input_channel("dda3ac6e") agent.handle_channel(HttpInputChannel(5004,"/", input_channel)) return agent
def run(): # load your trained agent interpreter = RasaNLUInterpreter('models/nlu/default/current') agent = Agent.load("models/dialogue", interpreter) input_channel = FacebookInput( fb_verify=VERIFY, # you need tell facebook this token, # to confirm your URL fb_secret=SECRET, # your app secret fb_access_token=FACEBOOK_ACCESS_TOKEN # token for the page # you subscribed to ) agent.handle_channel(HttpInputChannel(5001, "", input_channel))
def run_customer_bot(serve_forever=True): interpreter = RasaNLUInterpreter( 'C:/Srikanth/2018-Hackathon/git/myHR/CustomerBot/customer_bot-master/models/nlu/current/' ) agent = Agent.load( 'C:/Srikanth/2018-Hackathon/git/myHR/CustomerBot/customer_bot-master/models/dialogue/', interpreter=interpreter) print(agent) input_channel = SimpleWebBot() if serve_forever: agent.handle_channel(HttpInputChannel(5005, "/chat", input_channel)) print(agent) return agent
def run(serve_forever=True, port=5002): interpreter = RasaNLUInterpreter( "data/servicing-bot/rasa_servicing_en_nlu/current") agent = Agent.load("data/servicing-bot/dialogue", interpreter=interpreter) input_channel = FacebookInput( fb_verify= "rasa_bot", # you need tell facebook this token, to confirm your URL fb_secret="", # your app secret fb_tokens={"": ""}, # page ids + tokens you subscribed to debug_mode=True # enable debug mode for underlying fb library ) if serve_forever: agent.handle_channel(HttpInputChannel(port, "/app", input_channel)) return agent
def run_app(self): try: self.agent.handle_channel( HttpInputChannel(5004, "/", self.input_channel)) except Exception as e: logger.error("Unable to start slack app, exception : %s" % (str(e))) raise (e) #nlu_interpreter = RasaNLUInterpreter('./models/ourgroup/nlu/model_20181027T202656/default/restaurantnlu') #agent = Agent.load('./models/ourgroup/dialogue/model_20181027T202736', interpreter = nlu_interpreter) #input_channel = SlackInput('xoxp-460834353523-461984426807-465152376016-227cf68b2f965e85773c3d8c3de2b90c', #app verification token # 'xoxb-460834353523-467290740166-gSiOoS05TflKL19xb9dix609', # bot verification token # '048rGeNtBMmp2ipFkA7BAgiU', # slack verification token # True) #agent.handle_channel(HttpInputChannel(5004, '/', input_channel))
def run_cloud(serve_forever=True): fb_verify = "jarvis_demo_v1" fb_secret = "16de4c12bff8562acdf093063115cf5f" page_id = "253402548804134" fb_access_token = "EAADmdZBDoGiYBADkbun1mP1I3NmWevWW0Mtj5BItxGM2akMdIrqqIGgUIIRvgJMmVQojpRqfZBgWXcpdZBlL6N3woLnISCRD0AuLT76gIbKFZB7HJYdaNxzsyus8MVjlyngTqRonDSdUrcoMYXlflXvSlHvzSsNkXXZB5s9iY5wZDZD" input_channel = FacebookInput( fb_verify= fb_verify, # you need tell facebook this token, to confirm your URL fb_secret=fb_secret, # your app secret fb_access_token=fb_access_token, # token for the page you subscribed to ) interpreter = RasaNLUInterpreter("nlu_model/jarvis_nlu/default/current") agent = Agent.load("nlu_dialogue/models/jarvis_nlu", interpreter=interpreter) if serve_forever: agent.handle_channel(HttpInputChannel(9988, "", input_channel)) return agent
def run(serve_forever=True): interpreter = RasaNLUInterpreter("models/nlu/default/current") agent = Agent.load("models/dialogue", interpreter=interpreter) fb_verify = 'fractal' fb_secret = '3db0452e1e4b787d3058e14c624839bc' fb_tokens = { '162871184345992': 'EAAbctRsA3XkBAPeTSd4Q7SKuL0YvINDj30xYquxZC0tJfIZCCzahlDP78D63cTNqpIOQfmeWrnq2B1EFjtf5LHWA7UUQq4imZBSueYtZADcWZARxNWU1kj1SL5dVIn7nxZAj9wZCWmVOZCIkwwU4itzSzu1ZBU41vZC9GJrvbG75i0S5aO7rAYexwt', } input_channel = FacebookInput( fb_verify, fb_secret, fb_tokens, True ) if serve_forever: agent.handle_channel(HttpInputChannel(5000, '/app', input_channel)) return agent
def run_fb_webhook(a, b): print(a) print(b) domain_id = "default" try: agent = agents[domain_id] except: interpreter = RasaNLUInterpreter("{}/{}/nlu/default/current".format( model_folder, domain_id)) agent = Agent.load("{}/{}/dialogue".format(model_folder, domain_id), interpreter=interpreter) agents[domain_id] = agent input_channel = FacebookInput( fb_verify= "intelleibot", # you need tell facebook this token, to confirm your URL fb_secret="f229180435b992cf99b715cc07af5760", # your app secret fb_access_token= "EAAFDolR6SBcBAOTdzAvEDP1VjDIRhaxCc7G6T1GTmIWRmr9vPSKERgiIxeGZBfqx7BRySQ9CVZCQ09BC8SdAXOEpGOnek5I1U2zCeJOUrj7AN2ZBjaxLutVVHJg9OWfVut4uZCL90etmWrAOscr0PjU71mJKImfpgw8wRrEw6wZDZD" # token for the page you subscribed to ) agent.handle_channel(HttpInputChannel(5004, "/intelleibot", input_channel))
from rasa_core.channels import HttpInputChannel from rasa_core.agent import Agent from rasa_core.interpreter import RasaNLUInterpreter from rasa_slack_connector import SlackInput nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/restaurantnlu') agent = Agent.load('./models/dialogue', interpreter = nlu_interpreter) input_channel = SlackInput('xoxp-517280283250-517151581972-516736065809-6f37c4a1df0ecb3aa9b1e10dd8a7e94b', #app verification token 'xoxb-517280283250-516736066865-kODLJiSWGq0vX6tdfxIfxL6i', # bot verification token 'cyhtM54NFDEBlxRlklsyKIU5', # slack verification token True) agent.handle_channel(HttpInputChannel(5004, '/', input_channel))