session.proto 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. // Copyright 2022 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. syntax = "proto3";
  15. package google.cloud.dialogflow.v2;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/api/resource.proto";
  20. import "google/cloud/dialogflow/v2/audio_config.proto";
  21. import "google/cloud/dialogflow/v2/context.proto";
  22. import "google/cloud/dialogflow/v2/intent.proto";
  23. import "google/cloud/dialogflow/v2/session_entity_type.proto";
  24. import "google/protobuf/duration.proto";
  25. import "google/protobuf/field_mask.proto";
  26. import "google/protobuf/struct.proto";
  27. import "google/rpc/status.proto";
  28. import "google/type/latlng.proto";
  29. option cc_enable_arenas = true;
  30. option csharp_namespace = "Google.Cloud.Dialogflow.V2";
  31. option go_package = "google.golang.org/genproto/googleapis/cloud/dialogflow/v2;dialogflow";
  32. option java_multiple_files = true;
  33. option java_outer_classname = "SessionProto";
  34. option java_package = "com.google.cloud.dialogflow.v2";
  35. option objc_class_prefix = "DF";
  36. option (google.api.resource_definition) = {
  37. type: "dialogflow.googleapis.com/Session"
  38. pattern: "projects/{project}/agent/sessions/{session}"
  39. pattern: "projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}"
  40. pattern: "projects/{project}/locations/{location}/agent/sessions/{session}"
  41. pattern: "projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}"
  42. };
  43. // A service used for session interactions.
  44. //
  45. // For more information, see the [API interactions
  46. // guide](https://cloud.google.com/dialogflow/docs/api-overview).
  47. service Sessions {
  48. option (google.api.default_host) = "dialogflow.googleapis.com";
  49. option (google.api.oauth_scopes) =
  50. "https://www.googleapis.com/auth/cloud-platform,"
  51. "https://www.googleapis.com/auth/dialogflow";
  52. // Processes a natural language query and returns structured, actionable data
  53. // as a result. This method is not idempotent, because it may cause contexts
  54. // and session entity types to be updated, which in turn might affect
  55. // results of future queries.
  56. //
  57. // If you might use
  58. // [Agent Assist](https://cloud.google.com/dialogflow/docs/#aa)
  59. // or other CCAI products now or in the future, consider using
  60. // [AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent]
  61. // instead of `DetectIntent`. `AnalyzeContent` has additional
  62. // functionality for Agent Assist and other CCAI products.
  63. //
  64. // Note: Always use agent versions for production traffic.
  65. // See [Versions and
  66. // environments](https://cloud.google.com/dialogflow/es/docs/agents-versions).
  67. rpc DetectIntent(DetectIntentRequest) returns (DetectIntentResponse) {
  68. option (google.api.http) = {
  69. post: "/v2/{session=projects/*/agent/sessions/*}:detectIntent"
  70. body: "*"
  71. additional_bindings {
  72. post: "/v2/{session=projects/*/agent/environments/*/users/*/sessions/*}:detectIntent"
  73. body: "*"
  74. }
  75. additional_bindings {
  76. post: "/v2/{session=projects/*/locations/*/agent/sessions/*}:detectIntent"
  77. body: "*"
  78. }
  79. additional_bindings {
  80. post: "/v2/{session=projects/*/locations/*/agent/environments/*/users/*/sessions/*}:detectIntent"
  81. body: "*"
  82. }
  83. };
  84. option (google.api.method_signature) = "session,query_input";
  85. }
  86. // Processes a natural language query in audio format in a streaming fashion
  87. // and returns structured, actionable data as a result. This method is only
  88. // available via the gRPC API (not REST).
  89. //
  90. // If you might use
  91. // [Agent Assist](https://cloud.google.com/dialogflow/docs/#aa)
  92. // or other CCAI products now or in the future, consider using
  93. // [StreamingAnalyzeContent][google.cloud.dialogflow.v2.Participants.StreamingAnalyzeContent]
  94. // instead of `StreamingDetectIntent`. `StreamingAnalyzeContent` has
  95. // additional functionality for Agent Assist and other CCAI products.
  96. //
  97. // Note: Always use agent versions for production traffic.
  98. // See [Versions and
  99. // environments](https://cloud.google.com/dialogflow/es/docs/agents-versions).
  100. rpc StreamingDetectIntent(stream StreamingDetectIntentRequest) returns (stream StreamingDetectIntentResponse) {
  101. }
  102. }
  103. // The request to detect user's intent.
  104. message DetectIntentRequest {
  105. // Required. The name of the session this query is sent to. Format:
  106. // `projects/<Project ID>/agent/sessions/<Session ID>`, or
  107. // `projects/<Project ID>/agent/environments/<Environment ID>/users/<User
  108. // ID>/sessions/<Session ID>`. If `Environment ID` is not specified, we assume
  109. // default 'draft' environment (`Environment ID` might be referred to as
  110. // environment name at some places). If `User ID` is not specified, we are
  111. // using "-". It's up to the API caller to choose an appropriate `Session ID`
  112. // and `User Id`. They can be a random number or some type of user and session
  113. // identifiers (preferably hashed). The length of the `Session ID` and
  114. // `User ID` must not exceed 36 characters.
  115. //
  116. // For more information, see the [API interactions
  117. // guide](https://cloud.google.com/dialogflow/docs/api-overview).
  118. //
  119. // Note: Always use agent versions for production traffic.
  120. // See [Versions and
  121. // environments](https://cloud.google.com/dialogflow/es/docs/agents-versions).
  122. string session = 1 [
  123. (google.api.field_behavior) = REQUIRED,
  124. (google.api.resource_reference) = {
  125. type: "dialogflow.googleapis.com/Session"
  126. }
  127. ];
  128. // The parameters of this query.
  129. QueryParameters query_params = 2;
  130. // Required. The input specification. It can be set to:
  131. //
  132. // 1. an audio config
  133. // which instructs the speech recognizer how to process the speech audio,
  134. //
  135. // 2. a conversational query in the form of text, or
  136. //
  137. // 3. an event that specifies which intent to trigger.
  138. QueryInput query_input = 3 [(google.api.field_behavior) = REQUIRED];
  139. // Instructs the speech synthesizer how to generate the output
  140. // audio. If this field is not set and agent-level speech synthesizer is not
  141. // configured, no output audio is generated.
  142. OutputAudioConfig output_audio_config = 4;
  143. // Mask for [output_audio_config][google.cloud.dialogflow.v2.DetectIntentRequest.output_audio_config] indicating which settings in this
  144. // request-level config should override speech synthesizer settings defined at
  145. // agent-level.
  146. //
  147. // If unspecified or empty, [output_audio_config][google.cloud.dialogflow.v2.DetectIntentRequest.output_audio_config] replaces the agent-level
  148. // config in its entirety.
  149. google.protobuf.FieldMask output_audio_config_mask = 7;
  150. // The natural language speech audio to be processed. This field
  151. // should be populated iff `query_input` is set to an input audio config.
  152. // A single request can contain up to 1 minute of speech audio data.
  153. bytes input_audio = 5;
  154. }
  155. // The message returned from the DetectIntent method.
  156. message DetectIntentResponse {
  157. // The unique identifier of the response. It can be used to
  158. // locate a response in the training example set or for reporting issues.
  159. string response_id = 1;
  160. // The selected results of the conversational query or event processing.
  161. // See `alternative_query_results` for additional potential results.
  162. QueryResult query_result = 2;
  163. // Specifies the status of the webhook request.
  164. google.rpc.Status webhook_status = 3;
  165. // The audio data bytes encoded as specified in the request.
  166. // Note: The output audio is generated based on the values of default platform
  167. // text responses found in the `query_result.fulfillment_messages` field. If
  168. // multiple default text responses exist, they will be concatenated when
  169. // generating audio. If no default platform text responses exist, the
  170. // generated audio content will be empty.
  171. //
  172. // In some scenarios, multiple output audio fields may be present in the
  173. // response structure. In these cases, only the top-most-level audio output
  174. // has content.
  175. bytes output_audio = 4;
  176. // The config used by the speech synthesizer to generate the output audio.
  177. OutputAudioConfig output_audio_config = 6;
  178. }
  179. // Represents the parameters of the conversational query.
  180. message QueryParameters {
  181. // The time zone of this conversational query from the
  182. // [time zone database](https://www.iana.org/time-zones), e.g.,
  183. // America/New_York, Europe/Paris. If not provided, the time zone specified in
  184. // agent settings is used.
  185. string time_zone = 1;
  186. // The geo location of this conversational query.
  187. google.type.LatLng geo_location = 2;
  188. // The collection of contexts to be activated before this query is
  189. // executed.
  190. repeated Context contexts = 3;
  191. // Specifies whether to delete all contexts in the current session
  192. // before the new ones are activated.
  193. bool reset_contexts = 4;
  194. // Additional session entity types to replace or extend developer
  195. // entity types with. The entity synonyms apply to all languages and persist
  196. // for the session of this query.
  197. repeated SessionEntityType session_entity_types = 5;
  198. // This field can be used to pass custom data to your webhook.
  199. // Arbitrary JSON objects are supported.
  200. // If supplied, the value is used to populate the
  201. // `WebhookRequest.original_detect_intent_request.payload`
  202. // field sent to your webhook.
  203. google.protobuf.Struct payload = 6;
  204. // Configures the type of sentiment analysis to perform. If not
  205. // provided, sentiment analysis is not performed.
  206. SentimentAnalysisRequestConfig sentiment_analysis_request_config = 10;
  207. // This field can be used to pass HTTP headers for a webhook
  208. // call. These headers will be sent to webhook along with the headers that
  209. // have been configured through the Dialogflow web console. The headers
  210. // defined within this field will overwrite the headers configured through the
  211. // Dialogflow console if there is a conflict. Header names are
  212. // case-insensitive. Google's specified headers are not allowed. Including:
  213. // "Host", "Content-Length", "Connection", "From", "User-Agent",
  214. // "Accept-Encoding", "If-Modified-Since", "If-None-Match", "X-Forwarded-For",
  215. // etc.
  216. map<string, string> webhook_headers = 14;
  217. }
  218. // Represents the query input. It can contain either:
  219. //
  220. // 1. An audio config which
  221. // instructs the speech recognizer how to process the speech audio.
  222. //
  223. // 2. A conversational query in the form of text,.
  224. //
  225. // 3. An event that specifies which intent to trigger.
  226. message QueryInput {
  227. // Required. The input specification.
  228. oneof input {
  229. // Instructs the speech recognizer how to process the speech audio.
  230. InputAudioConfig audio_config = 1;
  231. // The natural language text to be processed. Text length must not exceed
  232. // 256 character for virtual agent interactions.
  233. TextInput text = 2;
  234. // The event to be processed.
  235. EventInput event = 3;
  236. }
  237. }
  238. // Represents the result of conversational query or event processing.
  239. message QueryResult {
  240. // The original conversational query text:
  241. //
  242. // - If natural language text was provided as input, `query_text` contains
  243. // a copy of the input.
  244. // - If natural language speech audio was provided as input, `query_text`
  245. // contains the speech recognition result. If speech recognizer produced
  246. // multiple alternatives, a particular one is picked.
  247. // - If automatic spell correction is enabled, `query_text` will contain the
  248. // corrected user input.
  249. string query_text = 1;
  250. // The language that was triggered during intent detection.
  251. // See [Language
  252. // Support](https://cloud.google.com/dialogflow/docs/reference/language)
  253. // for a list of the currently supported language codes.
  254. string language_code = 15;
  255. // The Speech recognition confidence between 0.0 and 1.0. A higher number
  256. // indicates an estimated greater likelihood that the recognized words are
  257. // correct. The default of 0.0 is a sentinel value indicating that confidence
  258. // was not set.
  259. //
  260. // This field is not guaranteed to be accurate or set. In particular this
  261. // field isn't set for StreamingDetectIntent since the streaming endpoint has
  262. // separate confidence estimates per portion of the audio in
  263. // StreamingRecognitionResult.
  264. float speech_recognition_confidence = 2;
  265. // The action name from the matched intent.
  266. string action = 3;
  267. // The collection of extracted parameters.
  268. //
  269. // Depending on your protocol or client library language, this is a
  270. // map, associative array, symbol table, dictionary, or JSON object
  271. // composed of a collection of (MapKey, MapValue) pairs:
  272. //
  273. // - MapKey type: string
  274. // - MapKey value: parameter name
  275. // - MapValue type:
  276. // - If parameter's entity type is a composite entity: map
  277. // - Else: depending on parameter value type, could be one of string,
  278. // number, boolean, null, list or map
  279. // - MapValue value:
  280. // - If parameter's entity type is a composite entity:
  281. // map from composite entity property names to property values
  282. // - Else: parameter value
  283. google.protobuf.Struct parameters = 4;
  284. // This field is set to:
  285. //
  286. // - `false` if the matched intent has required parameters and not all of
  287. // the required parameter values have been collected.
  288. // - `true` if all required parameter values have been collected, or if the
  289. // matched intent doesn't contain any required parameters.
  290. bool all_required_params_present = 5;
  291. // Indicates whether the conversational query triggers a cancellation for slot
  292. // filling. For more information, see the [cancel slot filling
  293. // documentation](https://cloud.google.com/dialogflow/es/docs/intents-actions-parameters#cancel).
  294. bool cancels_slot_filling = 21;
  295. // The text to be pronounced to the user or shown on the screen.
  296. // Note: This is a legacy field, `fulfillment_messages` should be preferred.
  297. string fulfillment_text = 6;
  298. // The collection of rich messages to present to the user.
  299. repeated Intent.Message fulfillment_messages = 7;
  300. // If the query was fulfilled by a webhook call, this field is set to the
  301. // value of the `source` field returned in the webhook response.
  302. string webhook_source = 8;
  303. // If the query was fulfilled by a webhook call, this field is set to the
  304. // value of the `payload` field returned in the webhook response.
  305. google.protobuf.Struct webhook_payload = 9;
  306. // The collection of output contexts. If applicable,
  307. // `output_contexts.parameters` contains entries with name
  308. // `<parameter name>.original` containing the original parameter values
  309. // before the query.
  310. repeated Context output_contexts = 10;
  311. // The intent that matched the conversational query. Some, not
  312. // all fields are filled in this message, including but not limited to:
  313. // `name`, `display_name`, `end_interaction` and `is_fallback`.
  314. Intent intent = 11;
  315. // The intent detection confidence. Values range from 0.0
  316. // (completely uncertain) to 1.0 (completely certain).
  317. // This value is for informational purpose only and is only used to
  318. // help match the best intent within the classification threshold.
  319. // This value may change for the same end-user expression at any time due to a
  320. // model retraining or change in implementation.
  321. // If there are `multiple knowledge_answers` messages, this value is set to
  322. // the greatest `knowledgeAnswers.match_confidence` value in the list.
  323. float intent_detection_confidence = 12;
  324. // Free-form diagnostic information for the associated detect intent request.
  325. // The fields of this data can change without notice, so you should not write
  326. // code that depends on its structure.
  327. // The data may contain:
  328. //
  329. // - webhook call latency
  330. // - webhook errors
  331. google.protobuf.Struct diagnostic_info = 14;
  332. // The sentiment analysis result, which depends on the
  333. // `sentiment_analysis_request_config` specified in the request.
  334. SentimentAnalysisResult sentiment_analysis_result = 17;
  335. }
  336. // The top-level message sent by the client to the
  337. // [Sessions.StreamingDetectIntent][google.cloud.dialogflow.v2.Sessions.StreamingDetectIntent] method.
  338. //
  339. // Multiple request messages should be sent in order:
  340. //
  341. // 1. The first message must contain
  342. // [session][google.cloud.dialogflow.v2.StreamingDetectIntentRequest.session],
  343. // [query_input][google.cloud.dialogflow.v2.StreamingDetectIntentRequest.query_input] plus optionally
  344. // [query_params][google.cloud.dialogflow.v2.StreamingDetectIntentRequest.query_params]. If the client
  345. // wants to receive an audio response, it should also contain
  346. // [output_audio_config][google.cloud.dialogflow.v2.StreamingDetectIntentRequest.output_audio_config].
  347. // The message must not contain
  348. // [input_audio][google.cloud.dialogflow.v2.StreamingDetectIntentRequest.input_audio].
  349. // 2. If [query_input][google.cloud.dialogflow.v2.StreamingDetectIntentRequest.query_input] was set to
  350. // [query_input.audio_config][google.cloud.dialogflow.v2.InputAudioConfig], all subsequent
  351. // messages must contain
  352. // [input_audio][google.cloud.dialogflow.v2.StreamingDetectIntentRequest.input_audio] to continue with
  353. // Speech recognition.
  354. // If you decide to rather detect an intent from text input after you
  355. // already started Speech recognition, please send a message with
  356. // [query_input.text][google.cloud.dialogflow.v2.QueryInput.text].
  357. //
  358. // However, note that:
  359. //
  360. // * Dialogflow will bill you for the audio duration so far.
  361. // * Dialogflow discards all Speech recognition results in favor of the
  362. // input text.
  363. // * Dialogflow will use the language code from the first message.
  364. //
  365. // After you sent all input, you must half-close or abort the request stream.
  366. message StreamingDetectIntentRequest {
  367. // Required. The name of the session the query is sent to.
  368. // Format of the session name:
  369. // `projects/<Project ID>/agent/sessions/<Session ID>`, or
  370. // `projects/<Project ID>/agent/environments/<Environment ID>/users/<User
  371. // ID>/sessions/<Session ID>`. If `Environment ID` is not specified, we assume
  372. // default 'draft' environment. If `User ID` is not specified, we are using
  373. // "-". It's up to the API caller to choose an appropriate `Session ID` and
  374. // `User Id`. They can be a random number or some type of user and session
  375. // identifiers (preferably hashed). The length of the `Session ID` and
  376. // `User ID` must not exceed 36 characters.
  377. //
  378. // For more information, see the [API interactions
  379. // guide](https://cloud.google.com/dialogflow/docs/api-overview).
  380. //
  381. // Note: Always use agent versions for production traffic.
  382. // See [Versions and
  383. // environments](https://cloud.google.com/dialogflow/es/docs/agents-versions).
  384. string session = 1 [
  385. (google.api.field_behavior) = REQUIRED,
  386. (google.api.resource_reference) = {
  387. type: "dialogflow.googleapis.com/Session"
  388. }
  389. ];
  390. // The parameters of this query.
  391. QueryParameters query_params = 2;
  392. // Required. The input specification. It can be set to:
  393. //
  394. // 1. an audio config which instructs the speech recognizer how to process
  395. // the speech audio,
  396. //
  397. // 2. a conversational query in the form of text, or
  398. //
  399. // 3. an event that specifies which intent to trigger.
  400. QueryInput query_input = 3 [(google.api.field_behavior) = REQUIRED];
  401. // Please use [InputAudioConfig.single_utterance][google.cloud.dialogflow.v2.InputAudioConfig.single_utterance] instead.
  402. // If `false` (default), recognition does not cease until
  403. // the client closes the stream. If `true`, the recognizer will detect a
  404. // single spoken utterance in input audio. Recognition ceases when it detects
  405. // the audio's voice has stopped or paused. In this case, once a detected
  406. // intent is received, the client should close the stream and start a new
  407. // request with a new stream as needed.
  408. // This setting is ignored when `query_input` is a piece of text or an event.
  409. bool single_utterance = 4 [deprecated = true];
  410. // Instructs the speech synthesizer how to generate the output
  411. // audio. If this field is not set and agent-level speech synthesizer is not
  412. // configured, no output audio is generated.
  413. OutputAudioConfig output_audio_config = 5;
  414. // Mask for [output_audio_config][google.cloud.dialogflow.v2.StreamingDetectIntentRequest.output_audio_config] indicating which settings in this
  415. // request-level config should override speech synthesizer settings defined at
  416. // agent-level.
  417. //
  418. // If unspecified or empty, [output_audio_config][google.cloud.dialogflow.v2.StreamingDetectIntentRequest.output_audio_config] replaces the agent-level
  419. // config in its entirety.
  420. google.protobuf.FieldMask output_audio_config_mask = 7;
  421. // The input audio content to be recognized. Must be sent if
  422. // `query_input` was set to a streaming input audio config. The complete audio
  423. // over all streaming messages must not exceed 1 minute.
  424. bytes input_audio = 6;
  425. }
  426. // The top-level message returned from the
  427. // `StreamingDetectIntent` method.
  428. //
  429. // Multiple response messages can be returned in order:
  430. //
  431. // 1. If the `StreamingDetectIntentRequest.input_audio` field was
  432. // set, the `recognition_result` field is populated for one
  433. // or more messages.
  434. // See the [StreamingRecognitionResult][google.cloud.dialogflow.v2.StreamingRecognitionResult] message for details
  435. // about the result message sequence.
  436. //
  437. // 2. The next message contains `response_id`, `query_result`
  438. // and optionally `webhook_status` if a WebHook was called.
  439. message StreamingDetectIntentResponse {
  440. // The unique identifier of the response. It can be used to
  441. // locate a response in the training example set or for reporting issues.
  442. string response_id = 1;
  443. // The result of speech recognition.
  444. StreamingRecognitionResult recognition_result = 2;
  445. // The result of the conversational query or event processing.
  446. QueryResult query_result = 3;
  447. // Specifies the status of the webhook request.
  448. google.rpc.Status webhook_status = 4;
  449. // The audio data bytes encoded as specified in the request.
  450. // Note: The output audio is generated based on the values of default platform
  451. // text responses found in the `query_result.fulfillment_messages` field. If
  452. // multiple default text responses exist, they will be concatenated when
  453. // generating audio. If no default platform text responses exist, the
  454. // generated audio content will be empty.
  455. //
  456. // In some scenarios, multiple output audio fields may be present in the
  457. // response structure. In these cases, only the top-most-level audio output
  458. // has content.
  459. bytes output_audio = 5;
  460. // The config used by the speech synthesizer to generate the output audio.
  461. OutputAudioConfig output_audio_config = 6;
  462. }
  463. // Contains a speech recognition result corresponding to a portion of the audio
  464. // that is currently being processed or an indication that this is the end
  465. // of the single requested utterance.
  466. //
  467. // While end-user audio is being processed, Dialogflow sends a series of
  468. // results. Each result may contain a `transcript` value. A transcript
  469. // represents a portion of the utterance. While the recognizer is processing
  470. // audio, transcript values may be interim values or finalized values.
  471. // Once a transcript is finalized, the `is_final` value is set to true and
  472. // processing continues for the next transcript.
  473. //
  474. // If `StreamingDetectIntentRequest.query_input.audio_config.single_utterance`
  475. // was true, and the recognizer has completed processing audio,
  476. // the `message_type` value is set to `END_OF_SINGLE_UTTERANCE and the
  477. // following (last) result contains the last finalized transcript.
  478. //
  479. // The complete end-user utterance is determined by concatenating the
  480. // finalized transcript values received for the series of results.
  481. //
  482. // In the following example, single utterance is enabled. In the case where
  483. // single utterance is not enabled, result 7 would not occur.
  484. //
  485. // ```
  486. // Num | transcript | message_type | is_final
  487. // --- | ----------------------- | ----------------------- | --------
  488. // 1 | "tube" | TRANSCRIPT | false
  489. // 2 | "to be a" | TRANSCRIPT | false
  490. // 3 | "to be" | TRANSCRIPT | false
  491. // 4 | "to be or not to be" | TRANSCRIPT | true
  492. // 5 | "that's" | TRANSCRIPT | false
  493. // 6 | "that is | TRANSCRIPT | false
  494. // 7 | unset | END_OF_SINGLE_UTTERANCE | unset
  495. // 8 | " that is the question" | TRANSCRIPT | true
  496. // ```
  497. //
  498. // Concatenating the finalized transcripts with `is_final` set to true,
  499. // the complete utterance becomes "to be or not to be that is the question".
  500. message StreamingRecognitionResult {
  501. // Type of the response message.
  502. enum MessageType {
  503. // Not specified. Should never be used.
  504. MESSAGE_TYPE_UNSPECIFIED = 0;
  505. // Message contains a (possibly partial) transcript.
  506. TRANSCRIPT = 1;
  507. // Event indicates that the server has detected the end of the user's speech
  508. // utterance and expects no additional inputs.
  509. // Therefore, the server will not process additional audio (although it may subsequently return additional results). The
  510. // client should stop sending additional audio data, half-close the gRPC
  511. // connection, and wait for any additional results until the server closes
  512. // the gRPC connection. This message is only sent if `single_utterance` was
  513. // set to `true`, and is not used otherwise.
  514. END_OF_SINGLE_UTTERANCE = 2;
  515. }
  516. // Type of the result message.
  517. MessageType message_type = 1;
  518. // Transcript text representing the words that the user spoke.
  519. // Populated if and only if `message_type` = `TRANSCRIPT`.
  520. string transcript = 2;
  521. // If `false`, the `StreamingRecognitionResult` represents an
  522. // interim result that may change. If `true`, the recognizer will not return
  523. // any further hypotheses about this piece of the audio. May only be populated
  524. // for `message_type` = `TRANSCRIPT`.
  525. bool is_final = 3;
  526. // The Speech confidence between 0.0 and 1.0 for the current portion of audio.
  527. // A higher number indicates an estimated greater likelihood that the
  528. // recognized words are correct. The default of 0.0 is a sentinel value
  529. // indicating that confidence was not set.
  530. //
  531. // This field is typically only provided if `is_final` is true and you should
  532. // not rely on it being accurate or even set.
  533. float confidence = 4;
  534. // Word-specific information for the words recognized by Speech in
  535. // [transcript][google.cloud.dialogflow.v2.StreamingRecognitionResult.transcript]. Populated if and only if `message_type` = `TRANSCRIPT` and
  536. // [InputAudioConfig.enable_word_info] is set.
  537. repeated SpeechWordInfo speech_word_info = 7;
  538. // Time offset of the end of this Speech recognition result relative to the
  539. // beginning of the audio. Only populated for `message_type` = `TRANSCRIPT`.
  540. google.protobuf.Duration speech_end_offset = 8;
  541. // Detected language code for the transcript.
  542. string language_code = 10;
  543. }
  544. // ============================================================================
  545. // Auxiliary proto messages.
  546. //
  547. // Represents the natural language text to be processed.
  548. message TextInput {
  549. // Required. The UTF-8 encoded natural language text to be processed.
  550. // Text length must not exceed 256 characters for virtual agent interactions.
  551. string text = 1 [(google.api.field_behavior) = REQUIRED];
  552. // Required. The language of this conversational query. See [Language
  553. // Support](https://cloud.google.com/dialogflow/docs/reference/language)
  554. // for a list of the currently supported language codes. Note that queries in
  555. // the same session do not necessarily need to specify the same language.
  556. string language_code = 2 [(google.api.field_behavior) = REQUIRED];
  557. }
  558. // Events allow for matching intents by event name instead of the natural
  559. // language input. For instance, input `<event: { name: "welcome_event",
  560. // parameters: { name: "Sam" } }>` can trigger a personalized welcome response.
  561. // The parameter `name` may be used by the agent in the response:
  562. // `"Hello #welcome_event.name! What can I do for you today?"`.
  563. message EventInput {
  564. // Required. The unique identifier of the event.
  565. string name = 1 [(google.api.field_behavior) = REQUIRED];
  566. // The collection of parameters associated with the event.
  567. //
  568. // Depending on your protocol or client library language, this is a
  569. // map, associative array, symbol table, dictionary, or JSON object
  570. // composed of a collection of (MapKey, MapValue) pairs:
  571. //
  572. // - MapKey type: string
  573. // - MapKey value: parameter name
  574. // - MapValue type:
  575. // - If parameter's entity type is a composite entity: map
  576. // - Else: depending on parameter value type, could be one of string,
  577. // number, boolean, null, list or map
  578. // - MapValue value:
  579. // - If parameter's entity type is a composite entity:
  580. // map from composite entity property names to property values
  581. // - Else: parameter value
  582. google.protobuf.Struct parameters = 2;
  583. // Required. The language of this query. See [Language
  584. // Support](https://cloud.google.com/dialogflow/docs/reference/language)
  585. // for a list of the currently supported language codes. Note that queries in
  586. // the same session do not necessarily need to specify the same language.
  587. //
  588. // This field is ignored when used in the context of a
  589. // [WebhookResponse.followup_event_input][google.cloud.dialogflow.v2.WebhookResponse.followup_event_input] field,
  590. // because the language was already defined in the originating detect
  591. // intent request.
  592. string language_code = 3 [(google.api.field_behavior) = REQUIRED];
  593. }
  594. // Configures the types of sentiment analysis to perform.
  595. message SentimentAnalysisRequestConfig {
  596. // Instructs the service to perform sentiment analysis on
  597. // `query_text`. If not provided, sentiment analysis is not performed on
  598. // `query_text`.
  599. bool analyze_query_text_sentiment = 1;
  600. }
  601. // The result of sentiment analysis. Sentiment analysis inspects user input
  602. // and identifies the prevailing subjective opinion, especially to determine a
  603. // user's attitude as positive, negative, or neutral.
  604. // For [Participants.DetectIntent][], it needs to be configured in
  605. // [DetectIntentRequest.query_params][google.cloud.dialogflow.v2.DetectIntentRequest.query_params]. For
  606. // [Participants.StreamingDetectIntent][], it needs to be configured in
  607. // [StreamingDetectIntentRequest.query_params][google.cloud.dialogflow.v2.StreamingDetectIntentRequest.query_params].
  608. // And for [Participants.AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent] and
  609. // [Participants.StreamingAnalyzeContent][google.cloud.dialogflow.v2.Participants.StreamingAnalyzeContent], it needs to be configured in
  610. // [ConversationProfile.human_agent_assistant_config][google.cloud.dialogflow.v2.ConversationProfile.human_agent_assistant_config]
  611. message SentimentAnalysisResult {
  612. // The sentiment analysis result for `query_text`.
  613. Sentiment query_text_sentiment = 1;
  614. }
  615. // The sentiment, such as positive/negative feeling or association, for a unit
  616. // of analysis, such as the query text. See:
  617. // https://cloud.google.com/natural-language/docs/basics#interpreting_sentiment_analysis_values
  618. // for how to interpret the result.
  619. message Sentiment {
  620. // Sentiment score between -1.0 (negative sentiment) and 1.0 (positive
  621. // sentiment).
  622. float score = 1;
  623. // A non-negative number in the [0, +inf) range, which represents the absolute
  624. // magnitude of sentiment, regardless of score (positive or negative).
  625. float magnitude = 2;
  626. }