Quick start
Get the script api_tutorial.py below and run it:
python3 api_tutorial.py http://35.159.33.67:5000
Starts chat and returns chat_id.
-
URL
/start
-
Method:
POST
-
Data Params
Required:
text=[string]
-
Success Response:
- Code: 200
Content:{ chat_id : '0eb17eb4-c2cf-4b6d-943b-4bad780c2e91' }
- Code: 200
-
Sample Call:
import requests base_url = 'http://35.159.33.67:5000' url = base_url + '/start' r = requests.post(url, json={'text': text}) print(r.json())
Send message to the bot
Sends message to the bot and get response.
-
URL
/message
-
Method:
POST
-
Data Params
Required:
text=[string]
chat_id=[string]
-
Success Response:
- Code: 200
Content:{ text : 'Hello!' }
- Code: 200
-
Sample Call:
import requests base_url = 'http://35.159.33.67:5000' url = base_url + '/message' r = requests.post(url, json={'text': 'Hi', 'chat_id': chat_id}) print(r.json())
Finish the chat
Finish the chat with bot.
-
URL
/end
-
Method:
POST
-
Data Params
Required:
chat_id=[string]
-
Success Response:
- Code: 200
Content:{ 'message': 'ok' }
- Code: 200
-
Sample Call:
import requests base_url = 'http://35.159.33.67:5000' url = base_url + '/end' r = requests.post(url, json={'chat_id': chat_id}) print(r.json())