Skip to content

Commit

Permalink
Basic tests for default flow + intents
Browse files Browse the repository at this point in the history
  • Loading branch information
mmurakowski-verily committed Oct 24, 2023
1 parent ed9503c commit 9913498
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mmv1/products/dialogflowcx/Flow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,23 @@ virtual_fields:
Marks this as the [Default Start Flow](https://cloud.google.com/dialogflow/cx/docs/concept/flow#start) for an agent. When you create an agent, the Default Start Flow is created automatically.
The Default Start Flow cannot be deleted; deleting the `google_dialogflow_cx_flow` resource does nothing to the underlying GCP resources.
examples:
- !ruby/object:Provider::Terraform::Examples
name: 'dialogflowcx_flow_basic'
primary_resource_id: 'basic_flow'
vars:
agent_name: 'dialogflowcx-agent'
- !ruby/object:Provider::Terraform::Examples
name: 'dialogflowcx_flow_full'
primary_resource_id: 'basic_flow'
vars:
agent_name: 'dialogflowcx-agent'
bucket_name: 'dialogflowcx-bucket'
- !ruby/object:Provider::Terraform::Examples
skip_docs: true
name: 'dialogflowcx_flow_default_start_flow'
primary_resource_id: 'default_start_flow'
vars:
agent_name: 'dialogflowcx-agent'
skip_sweeper: true
id_format: '{{parent}}/flows/{{name}}'
import_format: ['{{parent}}/flows/{{name}}']
Expand Down
12 changes: 12 additions & 0 deletions mmv1/products/dialogflowcx/Intent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ examples:
primary_resource_id: 'basic_intent'
vars:
agent_name: 'dialogflowcx-agent'
- !ruby/object:Provider::Terraform::Examples
skip_docs: true
name: 'dialogflowcx_intent_default_negative_intent'
primary_resource_id: 'default_negative_intent'
vars:
agent_name: 'dialogflowcx-agent'
- !ruby/object:Provider::Terraform::Examples
skip_docs: true
name: 'dialogflowcx_intent_default_welcome_intent'
primary_resource_id: 'default_welcome_intent'
vars:
agent_name: 'dialogflowcx-agent'
skip_sweeper: true
id_format: '{{parent}}/intents/{{name}}'
import_format: ['{{parent}}/intents/{{name}}']
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
resource "google_dialogflow_cx_agent" "agent" {
display_name = "<%= ctx[:vars]["agent_name"] %>"
location = "global"
default_language_code = "en"
time_zone = "America/New_York"
}

resource "google_dialogflow_cx_intent" "default_welcome_intent" {
parent = google_dialogflow_cx_agent.agent.id
is_default_welcome_intent = true
display_name = "Default Welcome Intent"
priority = 1
training_phrases {
parts {
text = "Hello"
}
repeat_count = 1
}
}


resource "google_dialogflow_cx_flow" "<%= ctx[:primary_resource_id] %>" {
parent = google_dialogflow_cx_agent.agent.id
is_default_start_flow = true
display_name = "Default Start Flow"

nlu_settings {
classification_threshold = 0.3
model_type = "MODEL_TYPE_STANDARD"
}

transition_routes {
intent = google_dialogflow_cx_intent.default_welcome_intent.id
trigger_fulfillment {
messages {
text {
text = ["Response to default welcome intent."]
}
}
}
}

event_handlers {
event = "custom-event"
trigger_fulfillment {
messages {
text {
text = ["This is a default flow."]
}
}
}
}

event_handlers {
event = "sys.no-match-default"
trigger_fulfillment {
messages {
text {
text = ["We've updated the default flow no-match response!"]
}
}
}
}

event_handlers {
event = "sys.no-input-default"
trigger_fulfillment {
messages {
text {
text = ["We've updated the default flow no-input response!"]
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
resource "google_dialogflow_cx_agent" "agent" {
display_name = "<%= ctx[:vars]["agent_name"] %>"
location = "global"
default_language_code = "en"
time_zone = "America/New_York"
}


resource "google_dialogflow_cx_intent" "<%= ctx[:primary_resource_id] %>" {
parent = google_dialogflow_cx_agent.agent.id
is_default_negative_intent = true
display_name = "Default Negative Intent"
priority = 1
training_phrases {
parts {
text = "Never match this phrase"
}
repeat_count = 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
resource "google_dialogflow_cx_agent" "agent" {
display_name = "<%= ctx[:vars]["agent_name"] %>"
location = "global"
default_language_code = "en"
time_zone = "America/New_York"
}


resource "google_dialogflow_cx_intent" "<%= ctx[:primary_resource_id] %>" {
parent = google_dialogflow_cx_agent.agent.id
is_default_welcome_intent = true
display_name = "Default Welcome Intent"
priority = 1
training_phrases {
parts {
text = "Hello"
}
repeat_count = 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ if isDefaultStartFlow || isDefaultWelcomeIntent || isDefaultNegativeIntent {
d.SetId(id)

// and defer to the Update method:
log.Printf("[DEBUG] Updating default <%= resource_name -%>")
return resource<%= resource_name -%>Update(d, meta)
}

0 comments on commit 9913498

Please sign in to comment.