-
Notifications
You must be signed in to change notification settings - Fork 8
/
setupDialogflow.sh
80 lines (63 loc) · 2.66 KB
/
setupDialogflow.sh
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
bold() {
echo ". $(tput bold)" "$*" "$(tput sgr0)";
}
err() {
echo "$*" >&2;
}
bold "Set all vars..."
set -a
source ./properties
set +a
bold "Set all .env vars..."
set -a
source chatserver/.env
set +a
ACCESS_TOKEN="$(gcloud auth application-default print-access-token)"
echo $MY_CHATBASE_VERSION;
echo $ACCESS_TOKEN;
bold "Zipping Intents..."
zip -r chatserver/dialogflow/agent/agent.zip chatserver/dialogflow/agent
bold "Uploading Intents to $GCLOUD_STORAGE_BUCKET_NAME..."
gsutil cp chatserver/dialogflow/agent/agent.zip gs://$GCLOUD_STORAGE_BUCKET_NAME/
bold "Create a Dialogflow Agent..."
echo $ACCESS_TOKEN
IMPORTFILES="{\"agentUri\":\"gs://$GCLOUD_STORAGE_BUCKET_NAME/agent.zip\"}"
JSONPROD="{\"defaultLanguageCode\":\"en\",\"displayName\":\"$PROD_AGENT_NAME\",\"parent\":\"projects/$PROJECT_ID\",\"timeZone\":\"America/Los_Angeles\"}"
curl -H "Content-Type: application/json; charset=utf-8" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d $JSONPROD "https://dialogflow.googleapis.com/v2/projects/$PROJECT_ID/agent"
## TODO ITS IN A DIFFERENT PROJECT SO YOU NEED
## THE RIGHTS
JSONTEST="{\"defaultLanguageCode\":\"en\",\"displayName\":\"$TEST_AGENT_NAME\",\"parent\":\"projects/$TEST_AGENT_PROJECT_ID\",\"timeZone\":\"America/Los_Angeles\"}"
curl -H "Content-Type: application/json; charset=utf-8" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d $JSONTEST "https://dialogflow.googleapis.com/v2/projects/$TEST_AGENT_PROJECT_ID/agent"
## TODO ITS IN A DIFFERENT PROJECT SO YOU NEED
## THE RIGHTS
JSONDEV="{\"defaultLanguageCode\":\"en\",\"displayName\":\"$DEV_AGENT_NAME\",\"parent\":\"projects/$DEV_AGENT_PROJECT_ID\",\"timeZone\":\"America/Los_Angeles\"}"
curl -H "Content-Type: application/json; charset=utf-8" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d $JSONDEV "https://dialogflow.googleapis.com/v2/projects/$DEV_AGENT_PROJECT_ID/agent"
bold "Import Intents to Prod"
curl -X POST \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json; charset=utf-8" \
-d $IMPORTFILES \
https://dialogflow.googleapis.com/v2/projects/$PROJECT_ID/agent:import
## TODO ITS IN A DIFFERENT PROJECT SO YOU NEED
## THE RIGHTS
bold "Import Intents to Dev"
curl -X POST \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json; charset=utf-8" \
-d $IMPORTFILES \
https://dialogflow.googleapis.com/v2/projects/$DEV_AGENT_PROJECT_ID/agent:import
## TODO ITS IN A DIFFERENT PROJECT SO YOU NEED
## THE RIGHTS
bold "Import Intents to Test"
curl -X POST \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json; charset=utf-8" \
-d $IMPORTFILES \
https://dialogflow.googleapis.com/v2/projects/$TEST_AGENT_PROJECT_ID/agent:import