AWS SDK for Go (PILOT)
API Reference

PREVIEW DOCUMENTATION - This is a preview of a new format for the AWS SDK for Go API Reference documentation. For the current AWS SDK for Go API Reference, see https://docs.aws.amazon.com/sdk-for-go/api/.

We welcome your feedback on this new version of the documentation. Send your comments to aws-sdkdocs-feedback@amazon.com.

LexRuntimeService

import "github.com/aws/aws-sdk-go/service/lexruntimeservice"

type LexRuntimeService struct { *client.Client }

LexRuntimeService provides the API operation methods for making requests to Amazon Lex Runtime Service. See this package's package overview docs for details on the service.

LexRuntimeService methods are safe to use concurrently. It is not safe to modify mutate any of the struct's properties though.

Client

Type: *client.Client

Method

PostContent

func (c *LexRuntimeService) PostContent(input *PostContentInput) (*PostContentOutput, error)

PostContent API operation for Amazon Lex Runtime Service.

Sends user input (text or speech) to Amazon Lex. Clients use this API to send text and audio requests to Amazon Lex at runtime. Amazon Lex interprets the user input using the machine learning model that it built for the bot.

The PostContent operation supports audio input at 8kHz and 16kHz. You can use 8kHz audio to achieve higher speech recognition accuracy in telephone audio applications.

In response, Amazon Lex returns the next message to convey to the user. Consider the following example messages:

  • 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?".
  • After the user provides all of the pizza order information, Amazon Lex might return a response with a message to get user confirmation: "Order the pizza?".

  • After the user replies "Yes" to the confirmation prompt, Amazon Lex might return a conclusion statement: "Thank you, your cheese pizza has been ordered.".

Not all Amazon Lex messages require a response from the user. For example, conclusion statements do not require a response. Some messages require only a yes or no response. In addition to the message, Amazon Lex provides additional context about the message in the response that you can use to enhance client behavior, such as displaying the appropriate client user interface. Consider the following examples:

  • If the message is to elicit slot data, Amazon Lex returns the following context information:

x-amz-lex-dialog-state header set to ElicitSlot

x-amz-lex-intent-name header set to the intent name in the current context

x-amz-lex-slot-to-elicit header set to the slot name for which the message

is eliciting information

x-amz-lex-slots header set to a map of slots configured for the intent with

their current values
  • If the message is a confirmation prompt, the x-amz-lex-dialog-state header is set to Confirmation and the x-amz-lex-slot-to-elicit header is omitted.

  • If the message is a clarification prompt configured for the intent, indicating that the user intent is not understood, the x-amz-dialog-state header is set to ElicitIntent and the x-amz-slot-to-elicit header is omitted.

In addition, Amazon Lex also returns your application-specific sessionAttributes. For more information, see Managing Conversation Context (https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html).

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon Lex Runtime Service's API operation PostContent for usage and error information.

Returned Error Codes:

  • ErrCodeNotFoundException "NotFoundException" The resource (such as the Amazon Lex bot or an alias) that is referred to is not found.

  • ErrCodeBadRequestException "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.

  • ErrCodeLimitExceededException "LimitExceededException" Exceeded a limit.

  • ErrCodeInternalFailureException "InternalFailureException" Internal service error. Retry the call.

  • ErrCodeConflictException "ConflictException" Two clients are using the same AWS account, Amazon Lex bot, and user ID.

  • ErrCodeUnsupportedMediaTypeException "UnsupportedMediaTypeException" The Content-Type header (PostContent API) has an invalid value.

  • ErrCodeNotAcceptableException "NotAcceptableException" The accept header in the request does not have a valid value.

  • ErrCodeRequestTimeoutException "RequestTimeoutException" The input speech is too long.

  • ErrCodeDependencyFailedException "DependencyFailedException" One of the dependencies, such as AWS Lambda or Amazon Polly, threw an exception. For example,

  • If Amazon Lex does not have sufficient permissions to call a Lambda function.

  • If a Lambda function takes longer than 30 seconds to execute.

  • If a fulfillment Lambda function returns a Delegate dialog action without removing any slot values.

  • ErrCodeBadGatewayException "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.
  • ErrCodeLoopDetectedException "LoopDetectedException" This exception is not used.

See also, https://docs.aws.amazon.com/goto/WebAPI/runtime.lex-2016-11-28/PostContent

PostContentRequest

func (c *LexRuntimeService) PostContentRequest(input *PostContentInput) (req *request.Request, output *PostContentOutput)

PostContentRequest generates a "aws/request.Request" representing the client's request for the PostContent operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See PostContent for more information on using the PostContent API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the PostContentRequest method. req, resp := client.PostContentRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/runtime.lex-2016-11-28/PostContent

PostContentWithContext

func (c *LexRuntimeService) PostContentWithContext(ctx aws.Context, input *PostContentInput, opts ...request.Option) (*PostContentOutput, error)

PostContentWithContext is the same as PostContent with the addition of the ability to pass a context and additional request options.

See PostContent for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

PostText

func (c *LexRuntimeService) PostText(input *PostTextInput) (*PostTextOutput, error)

PostText API operation for Amazon Lex Runtime Service.

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.

In response, Amazon Lex returns the next message to convey to the user an optional responseCard to display. Consider the following example messages:

  • 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?"
  • 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?".
  • 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.".

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 message, 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 slotToElicit, dialogState, intentName, and slots fields in the response. Consider the following examples:

  • If the message is to elicit slot data, Amazon Lex returns the following context information:

dialogState set to ElicitSlot

intentName set to the intent name in the current context

slotToElicit set to the slot name for which the message is eliciting information

slots set to a map of slots, configured for the intent, with currently known

values
  • If the message is a confirmation prompt, the dialogState is set to ConfirmIntent and SlotToElicit is set to null.

  • If the message is a clarification prompt (configured for the intent) that indicates that user intent is not understood, the dialogState is set to ElicitIntent and slotToElicit is set to null.

In addition, Amazon Lex also returns your application-specific sessionAttributes. For more information, see Managing Conversation Context (https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html).

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon Lex Runtime Service's API operation PostText for usage and error information.

Returned Error Codes:

  • ErrCodeNotFoundException "NotFoundException" The resource (such as the Amazon Lex bot or an alias) that is referred to is not found.

  • ErrCodeBadRequestException "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.

  • ErrCodeLimitExceededException "LimitExceededException" Exceeded a limit.

  • ErrCodeInternalFailureException "InternalFailureException" Internal service error. Retry the call.

  • ErrCodeConflictException "ConflictException" Two clients are using the same AWS account, Amazon Lex bot, and user ID.

  • ErrCodeDependencyFailedException "DependencyFailedException" One of the dependencies, such as AWS Lambda or Amazon Polly, threw an exception. For example,

  • If Amazon Lex does not have sufficient permissions to call a Lambda function.

  • If a Lambda function takes longer than 30 seconds to execute.

  • If a fulfillment Lambda function returns a Delegate dialog action without removing any slot values.

  • ErrCodeBadGatewayException "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.
  • ErrCodeLoopDetectedException "LoopDetectedException" This exception is not used.

See also, https://docs.aws.amazon.com/goto/WebAPI/runtime.lex-2016-11-28/PostText

PostTextRequest

func (c *LexRuntimeService) PostTextRequest(input *PostTextInput) (req *request.Request, output *PostTextOutput)

PostTextRequest generates a "aws/request.Request" representing the client's request for the PostText operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See PostText for more information on using the PostText API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the PostTextRequest method. req, resp := client.PostTextRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/runtime.lex-2016-11-28/PostText

PostTextWithContext

func (c *LexRuntimeService) PostTextWithContext(ctx aws.Context, input *PostTextInput, opts ...request.Option) (*PostTextOutput, error)

PostTextWithContext is the same as PostText with the addition of the ability to pass a context and additional request options.

See PostText for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

On this page: