1// Copyright 2023 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.cloud.dialogflow.cx.v3;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/api/resource.proto";
23import "google/cloud/dialogflow/cx/v3/response_message.proto";
24import "google/protobuf/duration.proto";
25import "google/protobuf/empty.proto";
26import "google/protobuf/field_mask.proto";
27import "google/protobuf/struct.proto";
28
29option cc_enable_arenas = true;
30option csharp_namespace = "Google.Cloud.Dialogflow.Cx.V3";
31option go_package = "cloud.google.com/go/dialogflow/cx/apiv3/cxpb;cxpb";
32option java_multiple_files = true;
33option java_outer_classname = "WebhookProto";
34option java_package = "com.google.cloud.dialogflow.cx.v3";
35option objc_class_prefix = "DF";
36option ruby_package = "Google::Cloud::Dialogflow::CX::V3";
37option (google.api.resource_definition) = {
38  type: "servicedirectory.googleapis.com/Service"
39  pattern: "projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}"
40};
41
42// Service for managing [Webhooks][google.cloud.dialogflow.cx.v3.Webhook].
43service Webhooks {
44  option (google.api.default_host) = "dialogflow.googleapis.com";
45  option (google.api.oauth_scopes) =
46      "https://www.googleapis.com/auth/cloud-platform,"
47      "https://www.googleapis.com/auth/dialogflow";
48
49  // Returns the list of all webhooks in the specified agent.
50  rpc ListWebhooks(ListWebhooksRequest) returns (ListWebhooksResponse) {
51    option (google.api.http) = {
52      get: "/v3/{parent=projects/*/locations/*/agents/*}/webhooks"
53    };
54    option (google.api.method_signature) = "parent";
55  }
56
57  // Retrieves the specified webhook.
58  rpc GetWebhook(GetWebhookRequest) returns (Webhook) {
59    option (google.api.http) = {
60      get: "/v3/{name=projects/*/locations/*/agents/*/webhooks/*}"
61    };
62    option (google.api.method_signature) = "name";
63  }
64
65  // Creates a webhook in the specified agent.
66  rpc CreateWebhook(CreateWebhookRequest) returns (Webhook) {
67    option (google.api.http) = {
68      post: "/v3/{parent=projects/*/locations/*/agents/*}/webhooks"
69      body: "webhook"
70    };
71    option (google.api.method_signature) = "parent,webhook";
72  }
73
74  // Updates the specified webhook.
75  rpc UpdateWebhook(UpdateWebhookRequest) returns (Webhook) {
76    option (google.api.http) = {
77      patch: "/v3/{webhook.name=projects/*/locations/*/agents/*/webhooks/*}"
78      body: "webhook"
79    };
80    option (google.api.method_signature) = "webhook,update_mask";
81  }
82
83  // Deletes the specified webhook.
84  rpc DeleteWebhook(DeleteWebhookRequest) returns (google.protobuf.Empty) {
85    option (google.api.http) = {
86      delete: "/v3/{name=projects/*/locations/*/agents/*/webhooks/*}"
87    };
88    option (google.api.method_signature) = "name";
89  }
90}
91
92// Webhooks host the developer's business logic. During a session, webhooks
93// allow the developer to use the data extracted by Dialogflow's natural
94// language processing to generate dynamic responses, validate collected data,
95// or trigger actions on the backend.
96message Webhook {
97  option (google.api.resource) = {
98    type: "dialogflow.googleapis.com/Webhook"
99    pattern: "projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}"
100  };
101
102  // Represents configuration for a generic web service.
103  message GenericWebService {
104    // Required. The webhook URI for receiving POST requests. It must use https
105    // protocol.
106    string uri = 1 [(google.api.field_behavior) = REQUIRED];
107
108    // The user name for HTTP Basic authentication.
109    string username = 2 [deprecated = true];
110
111    // The password for HTTP Basic authentication.
112    string password = 3 [deprecated = true];
113
114    // The HTTP request headers to send together with webhook
115    // requests.
116    map<string, string> request_headers = 4;
117
118    // Optional. Specifies a list of allowed custom CA certificates (in DER
119    // format) for HTTPS verification. This overrides the default SSL trust
120    // store. If this is empty or unspecified, Dialogflow will use Google's
121    // default trust store to verify certificates. N.B. Make sure the HTTPS
122    // server certificates are signed with "subject alt name". For instance a
123    // certificate can be self-signed using the following command,
124    // ```
125    //    openssl x509 -req -days 200 -in example.com.csr \
126    //      -signkey example.com.key \
127    //      -out example.com.crt \
128    //      -extfile <(printf "\nsubjectAltName='DNS:www.example.com'")
129    // ```
130    repeated bytes allowed_ca_certs = 5
131        [(google.api.field_behavior) = OPTIONAL];
132  }
133
134  // Represents configuration for a [Service
135  // Directory](https://cloud.google.com/service-directory) service.
136  message ServiceDirectoryConfig {
137    // Required. The name of [Service
138    // Directory](https://cloud.google.com/service-directory) service.
139    // Format: `projects/<Project ID>/locations/<Location
140    // ID>/namespaces/<Namespace ID>/services/<Service ID>`.
141    // `Location ID` of the service directory must be the same as the location
142    // of the agent.
143    string service = 1 [
144      (google.api.field_behavior) = REQUIRED,
145      (google.api.resource_reference) = {
146        type: "servicedirectory.googleapis.com/Service"
147      }
148    ];
149
150    // Generic Service configuration of this webhook.
151    GenericWebService generic_web_service = 2;
152  }
153
154  // The unique identifier of the webhook.
155  // Required for the
156  // [Webhooks.UpdateWebhook][google.cloud.dialogflow.cx.v3.Webhooks.UpdateWebhook]
157  // method.
158  // [Webhooks.CreateWebhook][google.cloud.dialogflow.cx.v3.Webhooks.CreateWebhook]
159  // populates the name automatically. Format: `projects/<Project
160  // ID>/locations/<Location ID>/agents/<Agent ID>/webhooks/<Webhook ID>`.
161  string name = 1;
162
163  // Required. The human-readable name of the webhook, unique within the agent.
164  string display_name = 2 [(google.api.field_behavior) = REQUIRED];
165
166  // Required. The webhook configuration.
167  oneof webhook {
168    // Configuration for a generic web service.
169    GenericWebService generic_web_service = 4;
170
171    // Configuration for a [Service
172    // Directory](https://cloud.google.com/service-directory) service.
173    ServiceDirectoryConfig service_directory = 7;
174  }
175
176  // Webhook execution timeout. Execution is considered failed if Dialogflow
177  // doesn't receive a response from webhook at the end of the timeout period.
178  // Defaults to 5 seconds, maximum allowed timeout is 30 seconds.
179  google.protobuf.Duration timeout = 6;
180
181  // Indicates whether the webhook is disabled.
182  bool disabled = 5;
183}
184
185// The request message for
186// [Webhooks.ListWebhooks][google.cloud.dialogflow.cx.v3.Webhooks.ListWebhooks].
187message ListWebhooksRequest {
188  // Required. The agent to list all webhooks for.
189  // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`.
190  string parent = 1 [
191    (google.api.field_behavior) = REQUIRED,
192    (google.api.resource_reference) = {
193      child_type: "dialogflow.googleapis.com/Webhook"
194    }
195  ];
196
197  // The maximum number of items to return in a single page. By default 100 and
198  // at most 1000.
199  int32 page_size = 2;
200
201  // The next_page_token value returned from a previous list request.
202  string page_token = 3;
203}
204
205// The response message for
206// [Webhooks.ListWebhooks][google.cloud.dialogflow.cx.v3.Webhooks.ListWebhooks].
207message ListWebhooksResponse {
208  // The list of webhooks. There will be a maximum number of items returned
209  // based on the page_size field in the request.
210  repeated Webhook webhooks = 1;
211
212  // Token to retrieve the next page of results, or empty if there are no more
213  // results in the list.
214  string next_page_token = 2;
215}
216
217// The request message for
218// [Webhooks.GetWebhook][google.cloud.dialogflow.cx.v3.Webhooks.GetWebhook].
219message GetWebhookRequest {
220  // Required. The name of the webhook.
221  // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
222  // ID>/webhooks/<Webhook ID>`.
223  string name = 1 [
224    (google.api.field_behavior) = REQUIRED,
225    (google.api.resource_reference) = {
226      type: "dialogflow.googleapis.com/Webhook"
227    }
228  ];
229}
230
231// The request message for
232// [Webhooks.CreateWebhook][google.cloud.dialogflow.cx.v3.Webhooks.CreateWebhook].
233message CreateWebhookRequest {
234  // Required. The agent to create a webhook for.
235  // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`.
236  string parent = 1 [
237    (google.api.field_behavior) = REQUIRED,
238    (google.api.resource_reference) = {
239      child_type: "dialogflow.googleapis.com/Webhook"
240    }
241  ];
242
243  // Required. The webhook to create.
244  Webhook webhook = 2 [(google.api.field_behavior) = REQUIRED];
245}
246
247// The request message for
248// [Webhooks.UpdateWebhook][google.cloud.dialogflow.cx.v3.Webhooks.UpdateWebhook].
249message UpdateWebhookRequest {
250  // Required. The webhook to update.
251  Webhook webhook = 1 [(google.api.field_behavior) = REQUIRED];
252
253  // The mask to control which fields get updated. If the mask is not present,
254  // all fields will be updated.
255  google.protobuf.FieldMask update_mask = 2;
256}
257
258// The request message for
259// [Webhooks.DeleteWebhook][google.cloud.dialogflow.cx.v3.Webhooks.DeleteWebhook].
260message DeleteWebhookRequest {
261  // Required. The name of the webhook to delete.
262  // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
263  // ID>/webhooks/<Webhook ID>`.
264  string name = 1 [
265    (google.api.field_behavior) = REQUIRED,
266    (google.api.resource_reference) = {
267      type: "dialogflow.googleapis.com/Webhook"
268    }
269  ];
270
271  // This field has no effect for webhook not being used.
272  // For webhooks that are used by pages/flows/transition route groups:
273  //
274  // *  If `force` is set to false, an error will be returned with message
275  //    indicating the referenced resources.
276  // *  If `force` is set to true, Dialogflow will remove the webhook, as well
277  //    as any references to the webhook (i.e.
278  //    [Webhook][google.cloud.dialogflow.cx.v3.Fulfillment.webhook] and
279  //    [tag][google.cloud.dialogflow.cx.v3.Fulfillment.tag]in fulfillments that
280  //    point to this webhook will be removed).
281  bool force = 2;
282}
283
284// The request message for a webhook call. The request is sent as a JSON object
285// and the field names will be presented in camel cases.
286//
287// You may see undocumented fields in an actual request. These fields are used
288// internally by Dialogflow and should be ignored.
289message WebhookRequest {
290  // Represents fulfillment information communicated to the webhook.
291  message FulfillmentInfo {
292    // Always present.
293    // The value of the
294    // [Fulfillment.tag][google.cloud.dialogflow.cx.v3.Fulfillment.tag] field
295    // will be populated in this field by Dialogflow when the associated webhook
296    // is called. The tag is typically used by the webhook service to identify
297    // which fulfillment is being called, but it could be used for other
298    // purposes.
299    string tag = 1;
300  }
301
302  // Represents intent information communicated to the webhook.
303  message IntentInfo {
304    // Represents a value for an intent parameter.
305    message IntentParameterValue {
306      // Always present. Original text value extracted from user utterance.
307      string original_value = 1;
308
309      // Always present. Structured value for the parameter extracted from user
310      // utterance.
311      google.protobuf.Value resolved_value = 2;
312    }
313
314    // Always present. The unique identifier of the last matched
315    // [intent][google.cloud.dialogflow.cx.v3.Intent].
316    // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
317    // ID>/intents/<Intent ID>`.
318    string last_matched_intent = 1 [(google.api.resource_reference) = {
319      type: "dialogflow.googleapis.com/Intent"
320    }];
321
322    // Always present. The display name of the last matched
323    // [intent][google.cloud.dialogflow.cx.v3.Intent].
324    string display_name = 3;
325
326    // Parameters identified as a result of intent matching. This is a map of
327    // the name of the identified parameter to the value of the parameter
328    // identified from the user's utterance. All parameters defined in the
329    // matched intent that are identified will be surfaced here.
330    map<string, IntentParameterValue> parameters = 2;
331
332    // The confidence of the matched intent. Values range from 0.0 (completely
333    // uncertain) to 1.0 (completely certain).
334    float confidence = 4;
335  }
336
337  // Represents the result of sentiment analysis.
338  message SentimentAnalysisResult {
339    // Sentiment score between -1.0 (negative sentiment) and 1.0 (positive
340    // sentiment).
341    float score = 1;
342
343    // A non-negative number in the [0, +inf) range, which represents the
344    // absolute magnitude of sentiment, regardless of score (positive or
345    // negative).
346    float magnitude = 2;
347  }
348
349  // Always present. The unique identifier of the
350  // [DetectIntentResponse][google.cloud.dialogflow.cx.v3.DetectIntentResponse]
351  // that will be returned to the API caller.
352  string detect_intent_response_id = 1;
353
354  // The original conversational query.
355  oneof query {
356    // If [natural language text][google.cloud.dialogflow.cx.v3.TextInput] was
357    // provided as input, this field will contain a copy of the text.
358    string text = 10;
359
360    // If an [intent][google.cloud.dialogflow.cx.v3.IntentInput] was provided as
361    // input, this field will contain a copy of the intent identifier. Format:
362    // `projects/<Project ID>/locations/<Location ID>/agents/<Agent
363    // ID>/intents/<Intent ID>`.
364    string trigger_intent = 11 [(google.api.resource_reference) = {
365      type: "dialogflow.googleapis.com/Intent"
366    }];
367
368    // If [natural language speech
369    // audio][google.cloud.dialogflow.cx.v3.AudioInput] was provided as input,
370    // this field will contain the transcript for the audio.
371    string transcript = 12;
372
373    // If an [event][google.cloud.dialogflow.cx.v3.EventInput] was provided as
374    // input, this field will contain the name of the event.
375    string trigger_event = 14;
376
377    // If [DTMF][google.cloud.dialogflow.cx.v3.DtmfInput] was provided as input,
378    // this field will contain the DTMF digits.
379    string dtmf_digits = 17;
380  }
381
382  // The language code specified in the [original
383  // request][QueryInput.language_code].
384  string language_code = 15;
385
386  // Always present. Information about the fulfillment that triggered this
387  // webhook call.
388  FulfillmentInfo fulfillment_info = 6;
389
390  // Information about the last matched intent.
391  IntentInfo intent_info = 3;
392
393  // Information about page status.
394  PageInfo page_info = 4;
395
396  // Information about session status.
397  SessionInfo session_info = 5;
398
399  // The list of rich message responses to present to the user. Webhook can
400  // choose to append or replace this list in
401  // [WebhookResponse.fulfillment_response][google.cloud.dialogflow.cx.v3.WebhookResponse.fulfillment_response];
402  repeated ResponseMessage messages = 7;
403
404  // Custom data set in
405  // [QueryParameters.payload][google.cloud.dialogflow.cx.v3.QueryParameters.payload].
406  google.protobuf.Struct payload = 8;
407
408  // The sentiment analysis result of the current user request. The field is
409  // filled when sentiment analysis is configured to be enabled for the request.
410  SentimentAnalysisResult sentiment_analysis_result = 9;
411}
412
413// The response message for a webhook call.
414message WebhookResponse {
415  // Represents a fulfillment response to the user.
416  message FulfillmentResponse {
417    // Defines merge behavior for `messages`.
418    enum MergeBehavior {
419      // Not specified. `APPEND` will be used.
420      MERGE_BEHAVIOR_UNSPECIFIED = 0;
421
422      // `messages` will be appended to the list of messages waiting to be sent
423      // to the user.
424      APPEND = 1;
425
426      // `messages` will replace the list of messages waiting to be sent to the
427      // user.
428      REPLACE = 2;
429    }
430
431    // The list of rich message responses to present to the user.
432    repeated ResponseMessage messages = 1;
433
434    // Merge behavior for `messages`.
435    MergeBehavior merge_behavior = 2;
436  }
437
438  // The fulfillment response to send to the user. This field can be omitted by
439  // the webhook if it does not intend to send any response to the user.
440  FulfillmentResponse fulfillment_response = 1;
441
442  // Information about page status. This field can be omitted by the webhook if
443  // it does not intend to modify page status.
444  PageInfo page_info = 2;
445
446  // Information about session status. This field can be omitted by the webhook
447  // if it does not intend to modify session status.
448  SessionInfo session_info = 3;
449
450  // Value to append directly to
451  // [QueryResult.webhook_payloads][google.cloud.dialogflow.cx.v3.QueryResult.webhook_payloads].
452  google.protobuf.Struct payload = 4;
453
454  // The target to transition to. This can be set optionally to indicate an
455  // immediate transition to a different page in the same host flow, or a
456  // different flow in the same agent.
457  oneof transition {
458    // The target page to transition to.
459    // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
460    // ID>/flows/<Flow ID>/pages/<Page ID>`.
461    string target_page = 5 [(google.api.resource_reference) = {
462      type: "dialogflow.googleapis.com/Page"
463    }];
464
465    // The target flow to transition to.
466    // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
467    // ID>/flows/<Flow ID>`.
468    string target_flow = 6 [(google.api.resource_reference) = {
469      type: "dialogflow.googleapis.com/Flow"
470    }];
471  }
472}
473
474// Represents page information communicated to and from the webhook.
475message PageInfo {
476  // Represents form information.
477  message FormInfo {
478    // Represents parameter information.
479    message ParameterInfo {
480      // Represents the state of a parameter.
481      enum ParameterState {
482        // Not specified. This value should be never used.
483        PARAMETER_STATE_UNSPECIFIED = 0;
484
485        // Indicates that the parameter does not have a value.
486        EMPTY = 1;
487
488        // Indicates that the parameter value is invalid. This field can be used
489        // by the webhook to invalidate the parameter and ask the server to
490        // collect it from the user again.
491        INVALID = 2;
492
493        // Indicates that the parameter has a value.
494        FILLED = 3;
495      }
496
497      // Always present for
498      // [WebhookRequest][google.cloud.dialogflow.cx.v3.WebhookRequest].
499      // Required for
500      // [WebhookResponse][google.cloud.dialogflow.cx.v3.WebhookResponse].
501      // The human-readable name of the parameter, unique within the form. This
502      // field cannot be modified by the webhook.
503      string display_name = 1;
504
505      // Optional for both
506      // [WebhookRequest][google.cloud.dialogflow.cx.v3.WebhookRequest] and
507      // [WebhookResponse][google.cloud.dialogflow.cx.v3.WebhookResponse].
508      // Indicates whether the parameter is required. Optional parameters will
509      // not trigger prompts; however, they are filled if the user specifies
510      // them. Required parameters must be filled before form filling concludes.
511      bool required = 2;
512
513      // Always present for
514      // [WebhookRequest][google.cloud.dialogflow.cx.v3.WebhookRequest].
515      // Required for
516      // [WebhookResponse][google.cloud.dialogflow.cx.v3.WebhookResponse]. The
517      // state of the parameter. This field can be set to
518      // [INVALID][google.cloud.dialogflow.cx.v3.PageInfo.FormInfo.ParameterInfo.ParameterState.INVALID]
519      // by the webhook to invalidate the parameter; other values set by the
520      // webhook will be ignored.
521      ParameterState state = 3;
522
523      // Optional for both
524      // [WebhookRequest][google.cloud.dialogflow.cx.v3.WebhookRequest] and
525      // [WebhookResponse][google.cloud.dialogflow.cx.v3.WebhookResponse]. The
526      // value of the parameter. This field can be set by the webhook to change
527      // the parameter value.
528      google.protobuf.Value value = 4;
529
530      // Optional for
531      // [WebhookRequest][google.cloud.dialogflow.cx.v3.WebhookRequest]. Ignored
532      // for [WebhookResponse][google.cloud.dialogflow.cx.v3.WebhookResponse].
533      // Indicates if the parameter value was just collected on the last
534      // conversation turn.
535      bool just_collected = 5;
536    }
537
538    // Optional for both
539    // [WebhookRequest][google.cloud.dialogflow.cx.v3.WebhookRequest] and
540    // [WebhookResponse][google.cloud.dialogflow.cx.v3.WebhookResponse]. The
541    // parameters contained in the form. Note that the webhook cannot add or
542    // remove any form parameter.
543    repeated ParameterInfo parameter_info = 2;
544  }
545
546  // Always present for
547  // [WebhookRequest][google.cloud.dialogflow.cx.v3.WebhookRequest]. Ignored for
548  // [WebhookResponse][google.cloud.dialogflow.cx.v3.WebhookResponse]. The
549  // unique identifier of the current page. Format: `projects/<Project
550  // ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>/pages/<Page
551  // ID>`.
552  string current_page = 1 [
553    (google.api.resource_reference) = { type: "dialogflow.googleapis.com/Page" }
554  ];
555
556  // Always present for
557  // [WebhookRequest][google.cloud.dialogflow.cx.v3.WebhookRequest]. Ignored for
558  // [WebhookResponse][google.cloud.dialogflow.cx.v3.WebhookResponse]. The
559  // display name of the current page.
560  string display_name = 4;
561
562  // Optional for both
563  // [WebhookRequest][google.cloud.dialogflow.cx.v3.WebhookRequest] and
564  // [WebhookResponse][google.cloud.dialogflow.cx.v3.WebhookResponse].
565  // Information about the form.
566  FormInfo form_info = 3;
567}
568
569// Represents session information communicated to and from the webhook.
570message SessionInfo {
571  // Always present for
572  // [WebhookRequest][google.cloud.dialogflow.cx.v3.WebhookRequest]. Ignored for
573  // [WebhookResponse][google.cloud.dialogflow.cx.v3.WebhookResponse]. The
574  // unique identifier of the
575  // [session][google.cloud.dialogflow.cx.v3.DetectIntentRequest.session]. This
576  // field can be used by the webhook to identify a session.
577  // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
578  // ID>/sessions/<Session ID>` or `projects/<Project ID>/locations/<Location
579  // ID>/agents/<Agent ID>/environments/<Environment ID>/sessions/<Session ID>`
580  // if environment is specified.
581  string session = 1 [(google.api.resource_reference) = {
582    type: "dialogflow.googleapis.com/Session"
583  }];
584
585  // Optional for
586  // [WebhookRequest][google.cloud.dialogflow.cx.v3.WebhookRequest]. Optional
587  // for [WebhookResponse][google.cloud.dialogflow.cx.v3.WebhookResponse]. All
588  // parameters collected from forms and intents during the session. Parameters
589  // can be created, updated, or removed by the webhook. To remove a parameter
590  // from the session, the webhook should explicitly set the parameter value to
591  // null in [WebhookResponse][google.cloud.dialogflow.cx.v3.WebhookResponse].
592  // The map is keyed by parameters' display names.
593  map<string, google.protobuf.Value> parameters = 2;
594}
595