Skip to content

Commit d988b25

Browse files
Adding initial Playbook support for Dialogflow CX (#14446) (#1083)
[upstream:5556dbed76a17ce82cf6bb0fb1682240daaf116c] Signed-off-by: Modular Magician <[email protected]>
1 parent a2eb4dd commit d988b25

File tree

8 files changed

+332
-0
lines changed

8 files changed

+332
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This file has some scaffolding to make sure that names are unique and that
2+
# a region and zone are selected when you try to create your Terraform resources.
3+
4+
locals {
5+
name_suffix = "${random_pet.suffix.id}"
6+
}
7+
8+
resource "random_pet" "suffix" {
9+
length = 2
10+
}
11+
12+
provider "google" {
13+
region = "us-central1"
14+
zone = "us-central1-c"
15+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
resource "google_dialogflow_cx_agent" "agent" {
2+
display_name = "dialogflowcx-agent-basic-${local.name_suffix}"
3+
location = "global"
4+
default_language_code = "en"
5+
time_zone = "America/New_York"
6+
description = "Example description."
7+
}
8+
9+
resource "google_dialogflow_cx_playbook" "my-playbook" {
10+
parent = google_dialogflow_cx_agent.agent.id
11+
display_name = "Example Display Name"
12+
goal = "Example Goal"
13+
playbook_type = "ROUTINE"
14+
instruction {
15+
steps {
16+
text = "step 1"
17+
steps = jsonencode([
18+
{
19+
"text": "step 1 1"
20+
},
21+
{
22+
"text": "step 1 2",
23+
"steps": [
24+
{
25+
"text": "step 1 2 1"
26+
},
27+
{
28+
"text": "step 1 2 2"
29+
}
30+
]
31+
},
32+
{
33+
"text": "step 1 3"
34+
}
35+
])
36+
}
37+
steps {
38+
text = "step 2"
39+
}
40+
steps {
41+
text = "step 3"
42+
}
43+
}
44+
}

dialogflowcx_playbook_basic/motd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
===
2+
3+
These examples use real resources that will be billed to the
4+
Google Cloud Platform project you use - so make sure that you
5+
run "terraform destroy" before quitting!
6+
7+
===
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Dialogflowcx Playbook Basic - Terraform
2+
3+
## Setup
4+
5+
<walkthrough-author name="[email protected]" analyticsId="UA-125550242-1" tutorialName="dialogflowcx_playbook_basic" repositoryUrl="https://github.com/terraform-google-modules/docs-examples"></walkthrough-author>
6+
7+
Welcome to Terraform in Google Cloud Shell! We need you to let us know what project you'd like to use with Terraform.
8+
9+
<walkthrough-project-billing-setup></walkthrough-project-billing-setup>
10+
11+
Terraform provisions real GCP resources, so anything you create in this session will be billed against this project.
12+
13+
## Terraforming!
14+
15+
Let's use {{project-id}} with Terraform! Click the Cloud Shell icon below to copy the command
16+
to your shell, and then run it from the shell by pressing Enter/Return. Terraform will pick up
17+
the project name from the environment variable.
18+
19+
```bash
20+
export GOOGLE_CLOUD_PROJECT={{project-id}}
21+
```
22+
23+
After that, let's get Terraform started. Run the following to pull in the providers.
24+
25+
```bash
26+
terraform init
27+
```
28+
29+
With the providers downloaded and a project set, you're ready to use Terraform. Go ahead!
30+
31+
```bash
32+
terraform apply
33+
```
34+
35+
Terraform will show you what it plans to do, and prompt you to accept. Type "yes" to accept the plan.
36+
37+
```bash
38+
yes
39+
```
40+
41+
42+
## Post-Apply
43+
44+
### Editing your config
45+
46+
Now you've provisioned your resources in GCP! If you run a "plan", you should see no changes needed.
47+
48+
```bash
49+
terraform plan
50+
```
51+
52+
So let's make a change! Try editing a number, or appending a value to the name in the editor. Then,
53+
run a 'plan' again.
54+
55+
```bash
56+
terraform plan
57+
```
58+
59+
Afterwards you can run an apply, which implicitly does a plan and shows you the intended changes
60+
at the 'yes' prompt.
61+
62+
```bash
63+
terraform apply
64+
```
65+
66+
```bash
67+
yes
68+
```
69+
70+
## Cleanup
71+
72+
Run the following to remove the resources Terraform provisioned:
73+
74+
```bash
75+
terraform destroy
76+
```
77+
```bash
78+
yes
79+
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This file has some scaffolding to make sure that names are unique and that
2+
# a region and zone are selected when you try to create your Terraform resources.
3+
4+
locals {
5+
name_suffix = "${random_pet.suffix.id}"
6+
}
7+
8+
resource "random_pet" "suffix" {
9+
length = 2
10+
}
11+
12+
provider "google" {
13+
region = "us-central1"
14+
zone = "us-central1-c"
15+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
resource "google_dialogflow_cx_agent" "agent" {
2+
display_name = "dialogflowcx-agent-${local.name_suffix}"
3+
location = "global"
4+
default_language_code = "en"
5+
time_zone = "America/New_York"
6+
description = "Example description."
7+
}
8+
9+
resource "google_storage_bucket" "bucket" {
10+
name = "dialogflowcx-bucket-${local.name_suffix}"
11+
location = "US"
12+
uniform_bucket_level_access = true
13+
}
14+
15+
resource "google_dialogflow_cx_webhook" "my_webhook" {
16+
parent = google_dialogflow_cx_agent.agent.id
17+
display_name = "MyWebhook"
18+
generic_web_service {
19+
uri = "https://example.com"
20+
}
21+
}
22+
23+
resource "google_dialogflow_cx_tool" "my_tool" {
24+
parent = google_dialogflow_cx_agent.agent.id
25+
display_name = "Example Tool"
26+
description = "Example Description"
27+
}
28+
29+
resource "google_dialogflow_cx_generator" "my_generator" {
30+
parent = google_dialogflow_cx_agent.agent.id
31+
display_name = "TF Prompt generator"
32+
llm_model_settings {
33+
model = "gemini-2.0-flash-001"
34+
prompt_text = "Return me some great results"
35+
}
36+
prompt_text {
37+
text = "Send me great results in french"
38+
}
39+
model_parameter {
40+
temperature = 0.55
41+
}
42+
}
43+
44+
resource "google_dialogflow_cx_playbook" "my-playbook" {
45+
parent = google_dialogflow_cx_agent.agent.id
46+
display_name = "Playbook Example with Fulfillment"
47+
goal = "Example Goal"
48+
instruction {
49+
guidelines = "Example Guidelines"
50+
steps {
51+
text = "step 1"
52+
steps = jsonencode([
53+
{
54+
"text": "step 1 1"
55+
},
56+
{
57+
"text": "step 1 2",
58+
"steps": [
59+
{
60+
"text": "step 1 2 1"
61+
},
62+
{
63+
"text": "step 1 2 2"
64+
}
65+
]
66+
},
67+
{
68+
"text": "step 1 3"
69+
}
70+
])
71+
}
72+
steps {
73+
text = "step 2"
74+
}
75+
steps {
76+
text = "step 3"
77+
}
78+
}
79+
80+
llm_model_settings {
81+
model = "gemini-2.0-flash-001"
82+
prompt_text = "Return me some great results"
83+
}
84+
85+
referenced_tools = [google_dialogflow_cx_tool.my_tool.id]
86+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
===
2+
3+
These examples use real resources that will be billed to the
4+
Google Cloud Platform project you use - so make sure that you
5+
run "terraform destroy" before quitting!
6+
7+
===
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Dialogflowcx Playbook Fulfillment - Terraform
2+
3+
## Setup
4+
5+
<walkthrough-author name="[email protected]" analyticsId="UA-125550242-1" tutorialName="dialogflowcx_playbook_fulfillment" repositoryUrl="https://github.com/terraform-google-modules/docs-examples"></walkthrough-author>
6+
7+
Welcome to Terraform in Google Cloud Shell! We need you to let us know what project you'd like to use with Terraform.
8+
9+
<walkthrough-project-billing-setup></walkthrough-project-billing-setup>
10+
11+
Terraform provisions real GCP resources, so anything you create in this session will be billed against this project.
12+
13+
## Terraforming!
14+
15+
Let's use {{project-id}} with Terraform! Click the Cloud Shell icon below to copy the command
16+
to your shell, and then run it from the shell by pressing Enter/Return. Terraform will pick up
17+
the project name from the environment variable.
18+
19+
```bash
20+
export GOOGLE_CLOUD_PROJECT={{project-id}}
21+
```
22+
23+
After that, let's get Terraform started. Run the following to pull in the providers.
24+
25+
```bash
26+
terraform init
27+
```
28+
29+
With the providers downloaded and a project set, you're ready to use Terraform. Go ahead!
30+
31+
```bash
32+
terraform apply
33+
```
34+
35+
Terraform will show you what it plans to do, and prompt you to accept. Type "yes" to accept the plan.
36+
37+
```bash
38+
yes
39+
```
40+
41+
42+
## Post-Apply
43+
44+
### Editing your config
45+
46+
Now you've provisioned your resources in GCP! If you run a "plan", you should see no changes needed.
47+
48+
```bash
49+
terraform plan
50+
```
51+
52+
So let's make a change! Try editing a number, or appending a value to the name in the editor. Then,
53+
run a 'plan' again.
54+
55+
```bash
56+
terraform plan
57+
```
58+
59+
Afterwards you can run an apply, which implicitly does a plan and shows you the intended changes
60+
at the 'yes' prompt.
61+
62+
```bash
63+
terraform apply
64+
```
65+
66+
```bash
67+
yes
68+
```
69+
70+
## Cleanup
71+
72+
Run the following to remove the resources Terraform provisioned:
73+
74+
```bash
75+
terraform destroy
76+
```
77+
```bash
78+
yes
79+
```

0 commit comments

Comments
 (0)