-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequestAPI.py
More file actions
33 lines (29 loc) · 1016 Bytes
/
Copy pathrequestAPI.py
File metadata and controls
33 lines (29 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import requests
import json
import os
from time import sleep
from sys import exit
def rasaStart():
currentDIR = os.path.dirname(os.path.realpath(__file__)).replace("\\","/")
currentDIR += "/models/"
print(currentDIR)
command = 'rasa run --model "{}"'.format(currentDIR)
os.system(command)
def messageBot(sender,message):
r=requests.post("http://localhost:5005/webhooks/rest/webhook",data=json.dumps({'sender':sender,'message':message}))
try:
print("==>"+eval(r.text)[0]["text"])
except:
print("==>"+"Sorry, I am not able to understand your message")
def onlineStatus():
r=requests.post("http://localhost:5005/webhooks/rest/webhook",data=json.dumps({'sender':'Dillu','message': '41 72 65 20 79 6F 75 20 61 6C 69 76 65 3F'}))
response = eval(r.text)[0]["text"]
if response == 'I am alive :)':
print("Rasa has successfully started...")
else:
exit()
def main():
rasaStart()
onlineStatus()
if __name__=='__main__':
main()