コード例 #1
0
        /// <summary>
        /// Sends user input (text-only) to Amazon Lex. Client applications can use this API to
        /// send requests to Amazon Lex at runtime. Amazon Lex then interprets the user input
        /// using the machine learning model it built for the bot.
        ///
        ///
        /// <para>
        ///  In response, Amazon Lex returns the next <code>message</code> to convey to the user
        /// an optional <code>responseCard</code> to display. Consider the following example messages:
        ///
        /// </para>
        ///  <ul> <li>
        /// <para>
        ///  For a user input "I would like a pizza", Amazon Lex might return a response with
        /// a message eliciting slot data (for example, PizzaSize): "What size pizza would you
        /// like?"
        /// </para>
        ///  </li> <li>
        /// <para>
        ///  After the user provides all of the pizza order information, Amazon Lex might return
        /// a response with a message to obtain user confirmation "Proceed with the pizza order?".
        ///
        /// </para>
        ///  </li> <li>
        /// <para>
        ///  After the user replies to a confirmation prompt with a "yes", Amazon Lex might return
        /// a conclusion statement: "Thank you, your cheese pizza has been ordered.".
        /// </para>
        ///  </li> </ul>
        /// <para>
        ///  Not all Amazon Lex messages require a user response. For example, a conclusion statement
        /// does not require a response. Some messages require only a "yes" or "no" user response.
        /// In addition to the <code>message</code>, Amazon Lex provides additional context about
        /// the message in the response that you might use to enhance client behavior, for example,
        /// to display the appropriate client user interface. These are the <code>slotToElicit</code>,
        /// <code>dialogState</code>, <code>intentName</code>, and <code>slots</code> fields in
        /// the response. Consider the following examples:
        /// </para>
        ///  <ul> <li>
        /// <para>
        /// If the message is to elicit slot data, Amazon Lex returns the following context information:
        /// </para>
        ///  <ul> <li>
        /// <para>
        ///  <code>dialogState</code> set to ElicitSlot
        /// </para>
        ///  </li> <li>
        /// <para>
        ///  <code>intentName</code> set to the intent name in the current context
        /// </para>
        ///  </li> <li>
        /// <para>
        ///  <code>slotToElicit</code> set to the slot name for which the <code>message</code>
        /// is eliciting information
        /// </para>
        ///  </li> <li>
        /// <para>
        ///  <code>slots</code> set to a map of slots, configured for the intent, with currently
        /// known values
        /// </para>
        ///  </li> </ul> </li> <li>
        /// <para>
        ///  If the message is a confirmation prompt, the <code>dialogState</code> is set to ConfirmIntent
        /// and <code>SlotToElicit</code> is set to null.
        /// </para>
        ///  </li> <li>
        /// <para>
        /// If the message is a clarification prompt (configured for the intent) that indicates
        /// that user intent is not understood, the <code>dialogState</code> is set to ElicitIntent
        /// and <code>slotToElicit</code> is set to null.
        /// </para>
        ///  </li> </ul>
        /// <para>
        ///  In addition, Amazon Lex also returns your application-specific <code>sessionAttributes</code>.
        /// For more information, see <a href="http://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html">Managing
        /// Conversation Context</a>.
        /// </para>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the PostText service method.</param>
        ///
        /// <returns>The response from the PostText service method, as returned by Lex.</returns>
        /// <exception cref="Amazon.Lex.Model.BadGatewayException">
        /// Either the Amazon Lex bot is still building, or one of the dependent services (Amazon
        /// Polly, AWS Lambda) failed with an internal service error.
        /// </exception>
        /// <exception cref="Amazon.Lex.Model.BadRequestException">
        /// Request validation failed, there is no usable message in the context, or the bot
        /// build failed, is still in progress, or contains unbuilt changes.
        /// </exception>
        /// <exception cref="Amazon.Lex.Model.ConflictException">
        /// Two clients are using the same AWS account, Amazon Lex bot, and user ID.
        /// </exception>
        /// <exception cref="Amazon.Lex.Model.DependencyFailedException">
        /// One of the dependencies, such as AWS Lambda or Amazon Polly, threw an exception.
        /// For example,
        ///
        ///  <ul> <li>
        /// <para>
        /// If Amazon Lex does not have sufficient permissions to call a Lambda function.
        /// </para>
        ///  </li> <li>
        /// <para>
        /// If a Lambda function takes longer than 30 seconds to execute.
        /// </para>
        ///  </li> <li>
        /// <para>
        /// If a fulfillment Lambda function returns a <code>Delegate</code> dialog action without
        /// removing any slot values.
        /// </para>
        ///  </li> </ul>
        /// </exception>
        /// <exception cref="Amazon.Lex.Model.InternalFailureException">
        /// Internal service error. Retry the call.
        /// </exception>
        /// <exception cref="Amazon.Lex.Model.LimitExceededException">
        /// Exceeded a limit.
        /// </exception>
        /// <exception cref="Amazon.Lex.Model.LoopDetectedException">
        /// This exception is not used.
        /// </exception>
        /// <exception cref="Amazon.Lex.Model.NotFoundException">
        /// The resource (such as the Amazon Lex bot or an alias) that is referred to is not found.
        /// </exception>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/runtime.lex-2016-11-28/PostText">REST API Reference for PostText Operation</seealso>
        public virtual PostTextResponse PostText(PostTextRequest request)
        {
            var marshaller   = new PostTextRequestMarshaller();
            var unmarshaller = PostTextResponseUnmarshaller.Instance;

            return(Invoke <PostTextRequest, PostTextResponse>(request, marshaller, unmarshaller));
        }
コード例 #2
0
        public void PostTextMarshallTest()
        {
            var operation = service_model.FindOperation("PostText");

            var request    = InstantiateClassGenerator.Execute <PostTextRequest>();
            var marshaller = new PostTextRequestMarshaller();

            var internalRequest = marshaller.Marshall(request);

            TestTools.RequestValidator.Validate("PostText", request, internalRequest, service_model);

            var webResponse = new WebResponseData
            {
                Headers =
                {
                    { "x-amzn-RequestId", Guid.NewGuid().ToString() },
                    { "x-amz-crc32",      "0"                       }
                }
            };

            var payloadResponse = new JsonSampleGenerator(service_model, operation.ResponseStructure).Execute();

            webResponse.Headers["Content-Length"] = UTF8Encoding.UTF8.GetBytes(payloadResponse).Length.ToString();
            var context = new JsonUnmarshallerContext(Utils.CreateStreamFromString(payloadResponse), false, webResponse);
            ResponseUnmarshaller unmarshaller = PostTextResponseUnmarshaller.Instance;
            var response = unmarshaller.Unmarshall(context)
                           as PostTextResponse;

            InstantiateClassGenerator.ValidateObjectFullyInstantiated(response);
        }
コード例 #3
0
        /// <summary>
        /// Initiates the asynchronous execution of the PostText operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the PostText operation on AmazonLexClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        ///
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndPostText
        ///         operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/runtime.lex-2016-11-28/PostText">REST API Reference for PostText Operation</seealso>
        public virtual IAsyncResult BeginPostText(PostTextRequest request, AsyncCallback callback, object state)
        {
            var marshaller   = new PostTextRequestMarshaller();
            var unmarshaller = PostTextResponseUnmarshaller.Instance;

            return(BeginInvoke <PostTextRequest>(request, marshaller, unmarshaller,
                                                 callback, state));
        }
コード例 #4
0
        /// <summary>
        /// Initiates the asynchronous execution of the PostText operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the PostText operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/runtime.lex-2016-11-28/PostText">REST API Reference for PostText Operation</seealso>
        public Task <PostTextResponse> PostTextAsync(PostTextRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new PostTextRequestMarshaller();
            var unmarshaller = PostTextResponseUnmarshaller.Instance;

            return(InvokeAsync <PostTextRequest, PostTextResponse>(request, marshaller,
                                                                   unmarshaller, cancellationToken));
        }