// Copyright 2018 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.cloud.dialogflow.v2;

import "google/api/annotations.proto";
import "google/cloud/dialogflow/v2/context.proto";
import "google/cloud/dialogflow/v2/intent.proto";
import "google/cloud/dialogflow/v2/session.proto";
import "google/protobuf/struct.proto";

option cc_enable_arenas = true;
option csharp_namespace = "Google.Cloud.Dialogflow.V2";
option go_package = "google.golang.org/genproto/googleapis/cloud/dialogflow/v2;dialogflow";
option java_multiple_files = true;
option java_outer_classname = "WebhookProto";
option java_package = "com.google.cloud.dialogflow.v2";
option objc_class_prefix = "DF";


// The request message for a webhook call.
message WebhookRequest {
  // The unique identifier of detectIntent request session.
  // Can be used to identify end-user inside webhook implementation.
  // Format: `projects/<Project ID>/agent/sessions/<Session ID>`.
  string session = 4;

  // The unique identifier of the response. Contains the same value as
  // `[Streaming]DetectIntentResponse.response_id`.
  string response_id = 1;

  // The result of the conversational query or event processing. Contains the
  // same value as `[Streaming]DetectIntentResponse.query_result`.
  QueryResult query_result = 2;

  // Optional. The contents of the original request that was passed to
  // `[Streaming]DetectIntent` call.
  OriginalDetectIntentRequest original_detect_intent_request = 3;
}

// The response message for a webhook call.
message WebhookResponse {
  // Optional. The text to be shown on the screen. This value is passed directly
  // to `QueryResult.fulfillment_text`.
  string fulfillment_text = 1;

  // Optional. The collection of rich messages to present to the user. This
  // value is passed directly to `QueryResult.fulfillment_messages`.
  repeated Intent.Message fulfillment_messages = 2;

  // Optional. This value is passed directly to `QueryResult.webhook_source`.
  string source = 3;

  // Optional. This value is passed directly to `QueryResult.webhook_payload`.
  // See the related `fulfillment_messages[i].payload field`, which may be used
  // as an alternative to this field.
  //
  // This field can be used for Actions on Google responses.
  // It should have a structure similar to the JSON message shown here. For more
  // information, see
  // [Actions on Google Webhook
  // Format](https://developers.google.com/actions/dialogflow/webhook)
  // <pre>{
  //   "google": {
  //     "expectUserResponse": true,
  //     "richResponse": {
  //       "items": [
  //         {
  //           "simpleResponse": {
  //             "textToSpeech": "this is a simple response"
  //           }
  //         }
  //       ]
  //     }
  //   }
  // }</pre>
  google.protobuf.Struct payload = 4;

  // Optional. The collection of output contexts. This value is passed directly
  // to `QueryResult.output_contexts`.
  repeated Context output_contexts = 5;

  // Optional. Makes the platform immediately invoke another `DetectIntent` call
  // internally with the specified event as input.
  EventInput followup_event_input = 6;
}

// Represents the contents of the original request that was passed to
// the `[Streaming]DetectIntent` call.
message OriginalDetectIntentRequest {
  // The source of this request, e.g., `google`, `facebook`, `slack`. It is set
  // by Dialogflow-owned servers.
  string source = 1;

  // Optional. This field is set to the value of `QueryParameters.payload` field
  // passed in the request.
  google.protobuf.Struct payload = 3;
}
