session.proto 38 KB

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