session.proto 35 KB

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