Skip to content

Commit 15e9574

Browse files
committed
added python example
1 parent 68ece1a commit 15e9574

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.idea/
22
logs/*
33
!logs/
4-
*.pyc
4+
*.pyc
5+
venv/
6+
env/

examples/python/app.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import requests,json
2+
3+
'''
4+
define initial payload
5+
set input = 'init_conversation' so that bot will return default welcome message
6+
'''
7+
payload = {
8+
"currentNode": "",
9+
"complete": None,
10+
"context": {},
11+
"parameters": [],
12+
"extractedParameters": {},
13+
"speechResponse": "",
14+
"intent": {},
15+
"input": "init_conversation",
16+
"missingParameters": []
17+
}
18+
19+
while True:
20+
r = requests.post("http://localhost:8001/api/v1", json=payload)
21+
# replace payload variable with api result
22+
payload = json.loads(r.text)
23+
24+
print("Iky\t" + payload.get("speechResponse"))
25+
26+
# read user input
27+
payload["input"]=raw_input("You:\t")

0 commit comments

Comments
 (0)