-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtelma_ai.py
50 lines (34 loc) · 1.35 KB
/
telma_ai.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import requests
import json
# Call telma api to upload the cmb code and return a web page pointing to a graph representing the cmb code
def get_access_token():
url = "https://developer.telma.ai/api/oauth2/token"
headers = {
'accept': 'application/json',
'Authorization': 'Basic amFuLmhvcmFrQHR1dGFub3RhLmNvbTpLeUtVTWZ5UjVwaGRVQXo='
}
response = requests.request("POST", url, headers=headers)
access_token = response.json().get('access_token')
return access_token
def create_telma_graph(cmb_json, current_bot_version_id, bot_id):
access_token = get_access_token()
# current_bot_version_id = cmb_json.get('current_bot_version_id')
# bot_id = cmb_json.get('id')
print(bot_id)
print(current_bot_version_id)
url = 'https://developer.telma.ai/api/v1/bots/' + \
bot_id + '/bot_versions/' + current_bot_version_id
headers = {
'accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + access_token,
}
response = requests.request("PATCH", url, headers=headers, json=cmb_json)
print(response)
print(response.text)
# # argg = open("./json_cmb_examples/Letiště Praha Introduction.json")
# with open('./json_cmb_examples/nps_bot.json', encoding='UTF-8') as file:
# payload = json.load(file)
#
#
# create_telma_graph(payload)