You are viewing the documentation for an older major version of the AWS SDK for JavaScript.
The modular AWS SDK for JavaScript (v3), the latest major version of AWS SDK for JavaScript, is now stable and recommended for general use. For more information, see the Migration Guide and API Reference.

Class: AWS.LexRuntimeV2

Inherits:
AWS.Service show all
Identifier:
lexruntimev2
API Version:
2020-08-07
Defined in:
(unknown)

Overview

Constructs a service interface object. Each API operation is exposed as a function on service.

Service Description

Sending a Request Using LexRuntimeV2

var lexruntimev2 = new AWS.LexRuntimeV2();
lexruntimev2.deleteSession(params, function (err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Locking the API Version

In order to ensure that the LexRuntimeV2 object uses this specific API, you can construct the object by passing the apiVersion option to the constructor:

var lexruntimev2 = new AWS.LexRuntimeV2({apiVersion: '2020-08-07'});

You can also set the API version globally in AWS.config.apiVersions using the lexruntimev2 service identifier:

AWS.config.apiVersions = {
  lexruntimev2: '2020-08-07',
  // other service API versions
};

var lexruntimev2 = new AWS.LexRuntimeV2();

Version:

  • 2020-08-07

Constructor Summary collapse

Property Summary collapse

Properties inherited from AWS.Service

apiVersions

Method Summary collapse

Methods inherited from AWS.Service

makeRequest, makeUnauthenticatedRequest, waitFor, setupRequestListeners, defineService

Constructor Details

new AWS.LexRuntimeV2(options = {}) ⇒ Object

Constructs a service object. This object has one method for each API operation.

Examples:

Constructing a LexRuntimeV2 object

var lexruntimev2 = new AWS.LexRuntimeV2({apiVersion: '2020-08-07'});

Options Hash (options):

  • params (map)

    An optional map of parameters to bind to every request sent by this service object. For more information on bound parameters, see "Working with Services" in the Getting Started Guide.

  • endpoint (String|AWS.Endpoint)

    The endpoint URI to send requests to. The default endpoint is built from the configured region. The endpoint should be a string like 'https://{service}.{region}.amazonaws.com' or an Endpoint object.

  • accessKeyId (String)

    your AWS access key ID.

  • secretAccessKey (String)

    your AWS secret access key.

  • sessionToken (AWS.Credentials)

    the optional AWS session token to sign requests with.

  • credentials (AWS.Credentials)

    the AWS credentials to sign requests with. You can either specify this object, or specify the accessKeyId and secretAccessKey options directly.

  • credentialProvider (AWS.CredentialProviderChain)

    the provider chain used to resolve credentials if no static credentials property is set.

  • region (String)

    the region to send service requests to. See AWS.LexRuntimeV2.region for more information.

  • maxRetries (Integer)

    the maximum amount of retries to attempt with a request. See AWS.LexRuntimeV2.maxRetries for more information.

  • maxRedirects (Integer)

    the maximum amount of redirects to follow with a request. See AWS.LexRuntimeV2.maxRedirects for more information.

  • sslEnabled (Boolean)

    whether to enable SSL for requests.

  • paramValidation (Boolean|map)

    whether input parameters should be validated against the operation description before sending the request. Defaults to true. Pass a map to enable any of the following specific validation features:

    • min [Boolean] — Validates that a value meets the min constraint. This is enabled by default when paramValidation is set to true.
    • max [Boolean] — Validates that a value meets the max constraint.
    • pattern [Boolean] — Validates that a string value matches a regular expression.
    • enum [Boolean] — Validates that a string value matches one of the allowable enum values.
  • computeChecksums (Boolean)

    whether to compute checksums for payload bodies when the service accepts it (currently supported in S3 only)

  • convertResponseTypes (Boolean)

    whether types are converted when parsing response data. Currently only supported for JSON based services. Turning this off may improve performance on large response payloads. Defaults to true.

  • correctClockSkew (Boolean)

    whether to apply a clock skew correction and retry requests that fail because of an skewed client clock. Defaults to false.

  • s3ForcePathStyle (Boolean)

    whether to force path style URLs for S3 objects.

  • s3BucketEndpoint (Boolean)

    whether the provided endpoint addresses an individual bucket (false if it addresses the root API endpoint). Note that setting this configuration option requires an endpoint to be provided explicitly to the service constructor.

  • s3DisableBodySigning (Boolean)

    whether S3 body signing should be disabled when using signature version v4. Body signing can only be disabled when using https. Defaults to true.

  • s3UsEast1RegionalEndpoint ('legacy'|'regional')

    when region is set to 'us-east-1', whether to send s3 request to global endpoints or 'us-east-1' regional endpoints. This config is only applicable to S3 client. Defaults to legacy

  • s3UseArnRegion (Boolean)

    whether to override the request region with the region inferred from requested resource's ARN. Only available for S3 buckets Defaults to true

  • retryDelayOptions (map)

    A set of options to configure the retry delay on retryable errors. Currently supported options are:

    • base [Integer] — The base number of milliseconds to use in the exponential backoff for operation retries. Defaults to 100 ms for all services except DynamoDB, where it defaults to 50ms.
    • customBackoff [function] — A custom function that accepts a retry count and error and returns the amount of time to delay in milliseconds. If the result is a non-zero negative value, no further retry attempts will be made. The base option will be ignored if this option is supplied. The function is only called for retryable errors.
  • httpOptions (map)

    A set of options to pass to the low-level HTTP request. Currently supported options are:

    • proxy [String] — the URL to proxy requests through
    • agent [http.Agent, https.Agent] — the Agent object to perform HTTP requests with. Used for connection pooling. Defaults to the global agent (http.globalAgent) for non-SSL connections. Note that for SSL connections, a special Agent object is used in order to enable peer certificate verification. This feature is only available in the Node.js environment.
    • connectTimeout [Integer] — Sets the socket to timeout after failing to establish a connection with the server after connectTimeout milliseconds. This timeout has no effect once a socket connection has been established.
    • timeout [Integer] — Sets the socket to timeout after timeout milliseconds of inactivity on the socket. Defaults to two minutes (120000).
    • xhrAsync [Boolean] — Whether the SDK will send asynchronous HTTP requests. Used in the browser environment only. Set to false to send requests synchronously. Defaults to true (async on).
    • xhrWithCredentials [Boolean] — Sets the "withCredentials" property of an XMLHttpRequest object. Used in the browser environment only. Defaults to false.
  • apiVersion (String, Date)

    a String in YYYY-MM-DD format (or a date) that represents the latest possible API version that can be used in all services (unless overridden by apiVersions). Specify 'latest' to use the latest possible version.

  • apiVersions (map<String, String|Date>)

    a map of service identifiers (the lowercase service class name) with the API version to use when instantiating a service. Specify 'latest' for each individual that can use the latest available version.

  • logger (#write, #log)

    an object that responds to .write() (like a stream) or .log() (like the console object) in order to log information about requests

  • systemClockOffset (Number)

    an offset value in milliseconds to apply to all signing times. Use this to compensate for clock skew when your system may be out of sync with the service time. Note that this configuration option can only be applied to the global AWS.config object and cannot be overridden in service-specific configuration. Defaults to 0 milliseconds.

  • signatureVersion (String)

    the signature version to sign requests with (overriding the API configuration). Possible values are: 'v2', 'v3', 'v4'.

  • signatureCache (Boolean)

    whether the signature to sign requests with (overriding the API configuration) is cached. Only applies to the signature version 'v4'. Defaults to true.

  • dynamoDbCrc32 (Boolean)

    whether to validate the CRC32 checksum of HTTP response bodies returned by DynamoDB. Default: true.

  • useAccelerateEndpoint (Boolean)

    Whether to use the S3 Transfer Acceleration endpoint with the S3 service. Default: false.

  • clientSideMonitoring (Boolean)

    whether to collect and publish this client's performance metrics of all its API requests.

  • endpointDiscoveryEnabled (Boolean|undefined)

    whether to call operations with endpoints given by service dynamically. Setting this

  • endpointCacheSize (Number)

    the size of the global cache storing endpoints from endpoint discovery operations. Once endpoint cache is created, updating this setting cannot change existing cache size. Defaults to 1000

  • hostPrefixEnabled (Boolean)

    whether to marshal request parameters to the prefix of hostname. Defaults to true.

  • stsRegionalEndpoints ('legacy'|'regional')

    whether to send sts request to global endpoints or regional endpoints. Defaults to 'legacy'.

Property Details

endpointAWS.Endpoint (readwrite)

Returns an Endpoint object representing the endpoint URL for service requests.

Returns:

  • (AWS.Endpoint)

    an Endpoint object representing the endpoint URL for service requests.

Method Details

deleteSession(params = {}, callback) ⇒ AWS.Request

Removes session information for a specified bot, alias, and user ID.

You can use this operation to restart a conversation with a bot. When you remove a session, the entire history of the session is removed so that you can start again.

You don't need to delete a session. Sessions have a time limit and will expire. Set the session time limit when you create the bot. The default is 5 minutes, but you can specify anything between 1 minute and 24 hours.

If you specify a bot or alias ID that doesn't exist, you receive a BadRequestException.

If the locale doesn't exist in the bot, or if the locale hasn't been enables for the alias, you receive a BadRequestException.

Service Reference:

Examples:

Calling the deleteSession operation

var params = {
  botAliasId: 'STRING_VALUE', /* required */
  botId: 'STRING_VALUE', /* required */
  localeId: 'STRING_VALUE', /* required */
  sessionId: 'STRING_VALUE' /* required */
};
lexruntimev2.deleteSession(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • botId — (String)

      The identifier of the bot that contains the session data.

    • botAliasId — (String)

      The alias identifier in use for the bot that contains the session data.

    • localeId — (String)

      The locale where the session is in use.

    • sessionId — (String)

      The identifier of the session to delete.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • botId — (String)

        The identifier of the bot that contained the session data.

      • botAliasId — (String)

        The alias identifier in use for the bot that contained the session data.

      • localeId — (String)

        The locale where the session was used.

      • sessionId — (String)

        The identifier of the deleted session.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

getSession(params = {}, callback) ⇒ AWS.Request

Returns session information for a specified bot, alias, and user.

For example, you can use this operation to retrieve session information for a user that has left a long-running session in use.

If the bot, alias, or session identifier doesn't exist, Amazon Lex V2 returns a BadRequestException. If the locale doesn't exist or is not enabled for the alias, you receive a BadRequestException.

Service Reference:

Examples:

Calling the getSession operation

var params = {
  botAliasId: 'STRING_VALUE', /* required */
  botId: 'STRING_VALUE', /* required */
  localeId: 'STRING_VALUE', /* required */
  sessionId: 'STRING_VALUE' /* required */
};
lexruntimev2.getSession(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • botId — (String)

      The identifier of the bot that contains the session data.

    • botAliasId — (String)

      The alias identifier in use for the bot that contains the session data.

    • localeId — (String)

      The locale where the session is in use.

    • sessionId — (String)

      The identifier of the session to return.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • sessionId — (String)

        The identifier of the returned session.

      • messages — (Array<map>)

        A list of messages that were last sent to the user. The messages are ordered based on the order that your returned the messages from your Lambda function or the order that messages are defined in the bot.

        • content — (String)

          The text of the message.

        • contentTyperequired — (String)

          Indicates the type of response.

          Possible values include:
          • "CustomPayload"
          • "ImageResponseCard"
          • "PlainText"
          • "SSML"
        • imageResponseCard — (map)

          A card that is shown to the user by a messaging platform. You define the contents of the card, the card is displayed by the platform.

          When you use a response card, the response from the user is constrained to the text associated with a button on the card.

          • titlerequired — (String)

            The title to display on the response card. The format of the title is determined by the platform displaying the response card.

          • subtitle — (String)

            The subtitle to display on the response card. The format of the subtitle is determined by the platform displaying the response card.

          • imageUrl — (String)

            The URL of an image to display on the response card. The image URL must be publicly available so that the platform displaying the response card has access to the image.

          • buttons — (Array<map>)

            A list of buttons that should be displayed on the response card. The arrangement of the buttons is determined by the platform that displays the button.

            • textrequired — (String)

              The text that is displayed on the button.

            • valuerequired — (String)

              The value returned to Amazon Lex V2 when a user chooses the button.

      • interpretations — (Array<map>)

        A list of intents that Amazon Lex V2 determined might satisfy the user's utterance.

        Each interpretation includes the intent, a score that indicates how confident Amazon Lex V2 is that the interpretation is the correct one, and an optional sentiment response that indicates the sentiment expressed in the utterance.

        • nluConfidence — (map)

          Determines the threshold where Amazon Lex V2 will insert the AMAZON.FallbackIntent, AMAZON.KendraSearchIntent, or both when returning alternative intents in a response. AMAZON.FallbackIntent and AMAZON.KendraSearchIntent are only inserted if they are configured for the bot.

          • score — (Float)

            A score that indicates how confident Amazon Lex V2 is that an intent satisfies the user's intent. Ranges between 0.00 and 1.00. Higher scores indicate higher confidence.

        • sentimentResponse — (map)

          The sentiment expressed in an utterance.

          When the bot is configured to send utterances to Amazon Comprehend for sentiment analysis, this field contains the result of the analysis.

          • sentiment — (String)

            The overall sentiment expressed in the user's response. This is the sentiment most likely expressed by the user based on the analysis by Amazon Comprehend.

            Possible values include:
            • "MIXED"
            • "NEGATIVE"
            • "NEUTRAL"
            • "POSITIVE"
          • sentimentScore — (map)

            The individual sentiment responses for the utterance.

            • positive — (Float)

              The level of confidence that Amazon Comprehend has in the accuracy of its detection of the POSITIVE sentiment.

            • negative — (Float)

              The level of confidence that Amazon Comprehend has in the accuracy of its detection of the NEGATIVE sentiment.

            • neutral — (Float)

              The level of confidence that Amazon Comprehend has in the accuracy of its detection of the NEUTRAL sentiment.

            • mixed — (Float)

              The level of confidence that Amazon Comprehend has in the accuracy of its detection of the MIXED sentiment.

        • intent — (map)

          A list of intents that might satisfy the user's utterance. The intents are ordered by the confidence score.

          • namerequired — (String)

            The name of the intent.

          • slots — (map<map>)

            A map of all of the slots for the intent. The name of the slot maps to the value of the slot. If a slot has not been filled, the value is null.

            • value — (map)

              The current value of the slot.

              • originalValue — (String)

                The text of the utterance from the user that was entered for the slot.

              • interpretedValuerequired — (String)

                The value that Amazon Lex V2 determines for the slot. The actual value depends on the setting of the value selection strategy for the bot. You can choose to use the value entered by the user, or you can have Amazon Lex V2 choose the first value in the resolvedValues list.

              • resolvedValues — (Array<String>)

                A list of additional values that have been recognized for the slot.

            • shape — (String)

              When the shape value is List, it indicates that the values field contains a list of slot values. When the value is Scalar, it indicates that the value field contains a single value.

              Possible values include:
              • "Scalar"
              • "List"
            • values — (Array<map>)

              A list of one or more values that the user provided for the slot. For example, if a for a slot that elicits pizza toppings, the values might be "pepperoni" and "pineapple."

          • state — (String)

            Contains fulfillment information for the intent.

            Possible values include:
            • "Failed"
            • "Fulfilled"
            • "InProgress"
            • "ReadyForFulfillment"
            • "Waiting"
            • "FulfillmentInProgress"
          • confirmationState — (String)

            Contains information about whether fulfillment of the intent has been confirmed.

            Possible values include:
            • "Confirmed"
            • "Denied"
            • "None"
      • sessionState — (map)

        Represents the current state of the dialog between the user and the bot.

        You can use this to determine the progress of the conversation and what the next action might be.

        • dialogAction — (map)

          The next step that Amazon Lex V2 should take in the conversation with a user.

          • typerequired — (String)

            The next action that the bot should take in its interaction with the user. The possible values are:

            • Close - Indicates that there will not be a response from the user. For example, the statement "Your order has been placed" does not require a response.

            • ConfirmIntent - The next action is asking the user if the intent is complete and ready to be fulfilled. This is a yes/no question such as "Place the order?"

            • Delegate - The next action is determined by Amazon Lex V2.

            • ElicitSlot - The next action is to elicit a slot value from the user.

            Possible values include:
            • "Close"
            • "ConfirmIntent"
            • "Delegate"
            • "ElicitIntent"
            • "ElicitSlot"
            • "None"
          • slotToElicit — (String)

            The name of the slot that should be elicited from the user.

        • intent — (map)

          The active intent that Amazon Lex V2 is processing.

          • namerequired — (String)

            The name of the intent.

          • slots — (map<map>)

            A map of all of the slots for the intent. The name of the slot maps to the value of the slot. If a slot has not been filled, the value is null.

            • value — (map)

              The current value of the slot.

              • originalValue — (String)

                The text of the utterance from the user that was entered for the slot.

              • interpretedValuerequired — (String)

                The value that Amazon Lex V2 determines for the slot. The actual value depends on the setting of the value selection strategy for the bot. You can choose to use the value entered by the user, or you can have Amazon Lex V2 choose the first value in the resolvedValues list.

              • resolvedValues — (Array<String>)

                A list of additional values that have been recognized for the slot.

            • shape — (String)

              When the shape value is List, it indicates that the values field contains a list of slot values. When the value is Scalar, it indicates that the value field contains a single value.

              Possible values include:
              • "Scalar"
              • "List"
            • values — (Array<map>)

              A list of one or more values that the user provided for the slot. For example, if a for a slot that elicits pizza toppings, the values might be "pepperoni" and "pineapple."

          • state — (String)

            Contains fulfillment information for the intent.

            Possible values include:
            • "Failed"
            • "Fulfilled"
            • "InProgress"
            • "ReadyForFulfillment"
            • "Waiting"
            • "FulfillmentInProgress"
          • confirmationState — (String)

            Contains information about whether fulfillment of the intent has been confirmed.

            Possible values include:
            • "Confirmed"
            • "Denied"
            • "None"
        • activeContexts — (Array<map>)

          One or more contexts that indicate to Amazon Lex V2 the context of a request. When a context is active, Amazon Lex V2 considers intents with the matching context as a trigger as the next intent in a session.

          • namerequired — (String)

            The name of the context.

          • timeToLiverequired — (map)

            Indicates the number of turns or seconds that the context is active. Once the time to live expires, the context is no longer returned in a response.

            • timeToLiveInSecondsrequired — (Integer)

              The number of seconds that the context is active. You can specify between 5 and 86400 seconds (24 hours).

            • turnsToLiverequired — (Integer)

              The number of turns that the context is active. You can specify up to 20 turns. Each request and response from the bot is a turn.

          • contextAttributesrequired — (map<String>)

            A list of contexts active for the request. A context can be activated when a previous intent is fulfilled, or by including the context in the request.

            If you don't specify a list of contexts, Amazon Lex V2 will use the current list of contexts for the session. If you specify an empty list, all contexts for the session are cleared.

        • sessionAttributes — (map<String>)

          Map of key/value pairs representing session-specific context information. It contains application information passed between Amazon Lex V2 and a client application.

        • originatingRequestId — (String)

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

putSession(params = {}, callback) ⇒ AWS.Request

Creates a new session or modifies an existing session with an Amazon Lex V2 bot. Use this operation to enable your application to set the state of the bot.

Service Reference:

Examples:

Calling the putSession operation

var params = {
  botAliasId: 'STRING_VALUE', /* required */
  botId: 'STRING_VALUE', /* required */
  localeId: 'STRING_VALUE', /* required */
  sessionId: 'STRING_VALUE', /* required */
  sessionState: { /* required */
    activeContexts: [
      {
        contextAttributes: { /* required */
          '<ParameterName>': 'STRING_VALUE',
          /* '<ParameterName>': ... */
        },
        name: 'STRING_VALUE', /* required */
        timeToLive: { /* required */
          timeToLiveInSeconds: 'NUMBER_VALUE', /* required */
          turnsToLive: 'NUMBER_VALUE' /* required */
        }
      },
      /* more items */
    ],
    dialogAction: {
      type: Close | ConfirmIntent | Delegate | ElicitIntent | ElicitSlot | None, /* required */
      slotToElicit: 'STRING_VALUE'
    },
    intent: {
      name: 'STRING_VALUE', /* required */
      confirmationState: Confirmed | Denied | None,
      slots: {
        '<NonEmptyString>': { /* Slot */
          shape: Scalar | List,
          value: {
            interpretedValue: 'STRING_VALUE', /* required */
            originalValue: 'STRING_VALUE',
            resolvedValues: [
              'STRING_VALUE',
              /* more items */
            ]
          },
          values: [
            /* recursive Slot */,
            /* more items */
          ]
        },
        /* '<NonEmptyString>': ... */
      },
      state: Failed | Fulfilled | InProgress | ReadyForFulfillment | Waiting | FulfillmentInProgress
    },
    originatingRequestId: 'STRING_VALUE',
    sessionAttributes: {
      '<NonEmptyString>': 'STRING_VALUE',
      /* '<NonEmptyString>': ... */
    }
  },
  messages: [
    {
      contentType: CustomPayload | ImageResponseCard | PlainText | SSML, /* required */
      content: 'STRING_VALUE',
      imageResponseCard: {
        title: 'STRING_VALUE', /* required */
        buttons: [
          {
            text: 'STRING_VALUE', /* required */
            value: 'STRING_VALUE' /* required */
          },
          /* more items */
        ],
        imageUrl: 'STRING_VALUE',
        subtitle: 'STRING_VALUE'
      }
    },
    /* more items */
  ],
  requestAttributes: {
    '<NonEmptyString>': 'STRING_VALUE',
    /* '<NonEmptyString>': ... */
  },
  responseContentType: 'STRING_VALUE'
};
lexruntimev2.putSession(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • botId — (String)

      The identifier of the bot that receives the session data.

    • botAliasId — (String)

      The alias identifier of the bot that receives the session data.

    • localeId — (String)

      The locale where the session is in use.

    • sessionId — (String)

      The identifier of the session that receives the session data.

    • messages — (Array<map>)

      A list of messages to send to the user. Messages are sent in the order that they are defined in the list.

      • content — (String)

        The text of the message.

      • contentTyperequired — (String)

        Indicates the type of response.

        Possible values include:
        • "CustomPayload"
        • "ImageResponseCard"
        • "PlainText"
        • "SSML"
      • imageResponseCard — (map)

        A card that is shown to the user by a messaging platform. You define the contents of the card, the card is displayed by the platform.

        When you use a response card, the response from the user is constrained to the text associated with a button on the card.

        • titlerequired — (String)

          The title to display on the response card. The format of the title is determined by the platform displaying the response card.

        • subtitle — (String)

          The subtitle to display on the response card. The format of the subtitle is determined by the platform displaying the response card.

        • imageUrl — (String)

          The URL of an image to display on the response card. The image URL must be publicly available so that the platform displaying the response card has access to the image.

        • buttons — (Array<map>)

          A list of buttons that should be displayed on the response card. The arrangement of the buttons is determined by the platform that displays the button.

          • textrequired — (String)

            The text that is displayed on the button.

          • valuerequired — (String)

            The value returned to Amazon Lex V2 when a user chooses the button.

    • sessionState — (map)

      Sets the state of the session with the user. You can use this to set the current intent, attributes, context, and dialog action. Use the dialog action to determine the next step that Amazon Lex V2 should use in the conversation with the user.

      • dialogAction — (map)

        The next step that Amazon Lex V2 should take in the conversation with a user.

        • typerequired — (String)

          The next action that the bot should take in its interaction with the user. The possible values are:

          • Close - Indicates that there will not be a response from the user. For example, the statement "Your order has been placed" does not require a response.

          • ConfirmIntent - The next action is asking the user if the intent is complete and ready to be fulfilled. This is a yes/no question such as "Place the order?"

          • Delegate - The next action is determined by Amazon Lex V2.

          • ElicitSlot - The next action is to elicit a slot value from the user.

          Possible values include:
          • "Close"
          • "ConfirmIntent"
          • "Delegate"
          • "ElicitIntent"
          • "ElicitSlot"
          • "None"
        • slotToElicit — (String)

          The name of the slot that should be elicited from the user.

      • intent — (map)

        The active intent that Amazon Lex V2 is processing.

        • namerequired — (String)

          The name of the intent.

        • slots — (map<map>)

          A map of all of the slots for the intent. The name of the slot maps to the value of the slot. If a slot has not been filled, the value is null.

          • value — (map)

            The current value of the slot.

            • originalValue — (String)

              The text of the utterance from the user that was entered for the slot.

            • interpretedValuerequired — (String)

              The value that Amazon Lex V2 determines for the slot. The actual value depends on the setting of the value selection strategy for the bot. You can choose to use the value entered by the user, or you can have Amazon Lex V2 choose the first value in the resolvedValues list.

            • resolvedValues — (Array<String>)

              A list of additional values that have been recognized for the slot.

          • shape — (String)

            When the shape value is List, it indicates that the values field contains a list of slot values. When the value is Scalar, it indicates that the value field contains a single value.

            Possible values include:
            • "Scalar"
            • "List"
          • values — (Array<map>)

            A list of one or more values that the user provided for the slot. For example, if a for a slot that elicits pizza toppings, the values might be "pepperoni" and "pineapple."

        • state — (String)

          Contains fulfillment information for the intent.

          Possible values include:
          • "Failed"
          • "Fulfilled"
          • "InProgress"
          • "ReadyForFulfillment"
          • "Waiting"
          • "FulfillmentInProgress"
        • confirmationState — (String)

          Contains information about whether fulfillment of the intent has been confirmed.

          Possible values include:
          • "Confirmed"
          • "Denied"
          • "None"
      • activeContexts — (Array<map>)

        One or more contexts that indicate to Amazon Lex V2 the context of a request. When a context is active, Amazon Lex V2 considers intents with the matching context as a trigger as the next intent in a session.

        • namerequired — (String)

          The name of the context.

        • timeToLiverequired — (map)

          Indicates the number of turns or seconds that the context is active. Once the time to live expires, the context is no longer returned in a response.

          • timeToLiveInSecondsrequired — (Integer)

            The number of seconds that the context is active. You can specify between 5 and 86400 seconds (24 hours).

          • turnsToLiverequired — (Integer)

            The number of turns that the context is active. You can specify up to 20 turns. Each request and response from the bot is a turn.

        • contextAttributesrequired — (map<String>)

          A list of contexts active for the request. A context can be activated when a previous intent is fulfilled, or by including the context in the request.

          If you don't specify a list of contexts, Amazon Lex V2 will use the current list of contexts for the session. If you specify an empty list, all contexts for the session are cleared.

      • sessionAttributes — (map<String>)

        Map of key/value pairs representing session-specific context information. It contains application information passed between Amazon Lex V2 and a client application.

      • originatingRequestId — (String)

    • requestAttributes — (map<String>)

      Request-specific information passed between Amazon Lex V2 and the client application.

      The namespace x-amz-lex: is reserved for special attributes. Don't create any request attributes with the prefix x-amz-lex:.

    • responseContentType — (String)

      The message that Amazon Lex V2 returns in the response can be either text or speech depending on the value of this parameter.

      • If the value is text/plain; charset=utf-8, Amazon Lex V2 returns text in the response.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • contentType — (String)

        The type of response. Same as the type specified in the responseContentType field in the request.

      • messages — (String)

        A list of messages that were last sent to the user. The messages are ordered based on how you return the messages from you Lambda function or the order that the messages are defined in the bot.

      • sessionState — (String)

        Represents the current state of the dialog between the user and the bot.

        Use this to determine the progress of the conversation and what the next action may be.

      • requestAttributes — (String)

        Request-specific information passed between the client application and Amazon Lex V2. These are the same as the requestAttribute parameter in the call to the PutSession operation.

      • sessionId — (String)

        The identifier of the session that received the data.

      • audioStream — (Buffer(Node.js), Typed Array(Browser), ReadableStream)

        If the requested content type was audio, the audio version of the message to convey to the user.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

recognizeText(params = {}, callback) ⇒ AWS.Request

Sends user input to Amazon Lex V2. Client applications use this API to send requests to Amazon Lex V2 at runtime. Amazon Lex V2 then interprets the user input using the machine learning model that it build for the bot.

In response, Amazon Lex V2 returns the next message to convey to the user and an optional response card to display.

If the optional post-fulfillment response is specified, the messages are returned as follows. For more information, see PostFulfillmentStatusSpecification.

  • Success message - Returned if the Lambda function completes successfully and the intent state is fulfilled or ready fulfillment if the message is present.

  • Failed message - The failed message is returned if the Lambda function throws an exception or if the Lambda function returns a failed intent state without a message.

  • Timeout message - If you don't configure a timeout message and a timeout, and the Lambda function doesn't return within 30 seconds, the timeout message is returned. If you configure a timeout, the timeout message is returned when the period times out.

For more information, see Completion message.

Service Reference:

Examples:

Calling the recognizeText operation

var params = {
  botAliasId: 'STRING_VALUE', /* required */
  botId: 'STRING_VALUE', /* required */
  localeId: 'STRING_VALUE', /* required */
  sessionId: 'STRING_VALUE', /* required */
  text: 'STRING_VALUE', /* required */
  requestAttributes: {
    '<NonEmptyString>': 'STRING_VALUE',
    /* '<NonEmptyString>': ... */
  },
  sessionState: {
    activeContexts: [
      {
        contextAttributes: { /* required */
          '<ParameterName>': 'STRING_VALUE',
          /* '<ParameterName>': ... */
        },
        name: 'STRING_VALUE', /* required */
        timeToLive: { /* required */
          timeToLiveInSeconds: 'NUMBER_VALUE', /* required */
          turnsToLive: 'NUMBER_VALUE' /* required */
        }
      },
      /* more items */
    ],
    dialogAction: {
      type: Close | ConfirmIntent | Delegate | ElicitIntent | ElicitSlot | None, /* required */
      slotToElicit: 'STRING_VALUE'
    },
    intent: {
      name: 'STRING_VALUE', /* required */
      confirmationState: Confirmed | Denied | None,
      slots: {
        '<NonEmptyString>': { /* Slot */
          shape: Scalar | List,
          value: {
            interpretedValue: 'STRING_VALUE', /* required */
            originalValue: 'STRING_VALUE',
            resolvedValues: [
              'STRING_VALUE',
              /* more items */
            ]
          },
          values: [
            /* recursive Slot */,
            /* more items */
          ]
        },
        /* '<NonEmptyString>': ... */
      },
      state: Failed | Fulfilled | InProgress | ReadyForFulfillment | Waiting | FulfillmentInProgress
    },
    originatingRequestId: 'STRING_VALUE',
    sessionAttributes: {
      '<NonEmptyString>': 'STRING_VALUE',
      /* '<NonEmptyString>': ... */
    }
  }
};
lexruntimev2.recognizeText(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • botId — (String)

      The identifier of the bot that processes the request.

    • botAliasId — (String)

      The alias identifier in use for the bot that processes the request.

    • localeId — (String)

      The locale where the session is in use.

    • sessionId — (String)

      The identifier of the user session that is having the conversation.

    • text — (String)

      The text that the user entered. Amazon Lex V2 interprets this text.

    • sessionState — (map)

      The current state of the dialog between the user and the bot.

      • dialogAction — (map)

        The next step that Amazon Lex V2 should take in the conversation with a user.

        • typerequired — (String)

          The next action that the bot should take in its interaction with the user. The possible values are:

          • Close - Indicates that there will not be a response from the user. For example, the statement "Your order has been placed" does not require a response.

          • ConfirmIntent - The next action is asking the user if the intent is complete and ready to be fulfilled. This is a yes/no question such as "Place the order?"

          • Delegate - The next action is determined by Amazon Lex V2.

          • ElicitSlot - The next action is to elicit a slot value from the user.

          Possible values include:
          • "Close"
          • "ConfirmIntent"
          • "Delegate"
          • "ElicitIntent"
          • "ElicitSlot"
          • "None"
        • slotToElicit — (String)

          The name of the slot that should be elicited from the user.

      • intent — (map)

        The active intent that Amazon Lex V2 is processing.

        • namerequired — (String)

          The name of the intent.

        • slots — (map<map>)

          A map of all of the slots for the intent. The name of the slot maps to the value of the slot. If a slot has not been filled, the value is null.

          • value — (map)

            The current value of the slot.

            • originalValue — (String)

              The text of the utterance from the user that was entered for the slot.

            • interpretedValuerequired — (String)

              The value that Amazon Lex V2 determines for the slot. The actual value depends on the setting of the value selection strategy for the bot. You can choose to use the value entered by the user, or you can have Amazon Lex V2 choose the first value in the resolvedValues list.

            • resolvedValues — (Array<String>)

              A list of additional values that have been recognized for the slot.

          • shape — (String)

            When the shape value is List, it indicates that the values field contains a list of slot values. When the value is Scalar, it indicates that the value field contains a single value.

            Possible values include:
            • "Scalar"
            • "List"
          • values — (Array<map>)

            A list of one or more values that the user provided for the slot. For example, if a for a slot that elicits pizza toppings, the values might be "pepperoni" and "pineapple."

        • state — (String)

          Contains fulfillment information for the intent.

          Possible values include:
          • "Failed"
          • "Fulfilled"
          • "InProgress"
          • "ReadyForFulfillment"
          • "Waiting"
          • "FulfillmentInProgress"
        • confirmationState — (String)

          Contains information about whether fulfillment of the intent has been confirmed.

          Possible values include:
          • "Confirmed"
          • "Denied"
          • "None"
      • activeContexts — (Array<map>)

        One or more contexts that indicate to Amazon Lex V2 the context of a request. When a context is active, Amazon Lex V2 considers intents with the matching context as a trigger as the next intent in a session.

        • namerequired — (String)

          The name of the context.

        • timeToLiverequired — (map)

          Indicates the number of turns or seconds that the context is active. Once the time to live expires, the context is no longer returned in a response.

          • timeToLiveInSecondsrequired — (Integer)

            The number of seconds that the context is active. You can specify between 5 and 86400 seconds (24 hours).

          • turnsToLiverequired — (Integer)

            The number of turns that the context is active. You can specify up to 20 turns. Each request and response from the bot is a turn.

        • contextAttributesrequired — (map<String>)

          A list of contexts active for the request. A context can be activated when a previous intent is fulfilled, or by including the context in the request.

          If you don't specify a list of contexts, Amazon Lex V2 will use the current list of contexts for the session. If you specify an empty list, all contexts for the session are cleared.

      • sessionAttributes — (map<String>)

        Map of key/value pairs representing session-specific context information. It contains application information passed between Amazon Lex V2 and a client application.

      • originatingRequestId — (String)

    • requestAttributes — (map<String>)

      Request-specific information passed between the client application and Amazon Lex V2

      The namespace x-amz-lex: is reserved for special attributes. Don't create any request attributes with the prefix x-amz-lex:.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • messages — (Array<map>)

        A list of messages last sent to the user. The messages are ordered based on the order that you returned the messages from your Lambda function or the order that the messages are defined in the bot.

        • content — (String)

          The text of the message.

        • contentTyperequired — (String)

          Indicates the type of response.

          Possible values include:
          • "CustomPayload"
          • "ImageResponseCard"
          • "PlainText"
          • "SSML"
        • imageResponseCard — (map)

          A card that is shown to the user by a messaging platform. You define the contents of the card, the card is displayed by the platform.

          When you use a response card, the response from the user is constrained to the text associated with a button on the card.

          • titlerequired — (String)

            The title to display on the response card. The format of the title is determined by the platform displaying the response card.

          • subtitle — (String)

            The subtitle to display on the response card. The format of the subtitle is determined by the platform displaying the response card.

          • imageUrl — (String)

            The URL of an image to display on the response card. The image URL must be publicly available so that the platform displaying the response card has access to the image.

          • buttons — (Array<map>)

            A list of buttons that should be displayed on the response card. The arrangement of the buttons is determined by the platform that displays the button.

            • textrequired — (String)

              The text that is displayed on the button.

            • valuerequired — (String)

              The value returned to Amazon Lex V2 when a user chooses the button.

      • sessionState — (map)

        Represents the current state of the dialog between the user and the bot.

        Use this to determine the progress of the conversation and what the next action may be.

        • dialogAction — (map)

          The next step that Amazon Lex V2 should take in the conversation with a user.

          • typerequired — (String)

            The next action that the bot should take in its interaction with the user. The possible values are:

            • Close - Indicates that there will not be a response from the user. For example, the statement "Your order has been placed" does not require a response.

            • ConfirmIntent - The next action is asking the user if the intent is complete and ready to be fulfilled. This is a yes/no question such as "Place the order?"

            • Delegate - The next action is determined by Amazon Lex V2.

            • ElicitSlot - The next action is to elicit a slot value from the user.

            Possible values include:
            • "Close"
            • "ConfirmIntent"
            • "Delegate"
            • "ElicitIntent"
            • "ElicitSlot"
            • "None"
          • slotToElicit — (String)

            The name of the slot that should be elicited from the user.

        • intent — (map)

          The active intent that Amazon Lex V2 is processing.

          • namerequired — (String)

            The name of the intent.

          • slots — (map<map>)

            A map of all of the slots for the intent. The name of the slot maps to the value of the slot. If a slot has not been filled, the value is null.

            • value — (map)

              The current value of the slot.

              • originalValue — (String)

                The text of the utterance from the user that was entered for the slot.

              • interpretedValuerequired — (String)

                The value that Amazon Lex V2 determines for the slot. The actual value depends on the setting of the value selection strategy for the bot. You can choose to use the value entered by the user, or you can have Amazon Lex V2 choose the first value in the resolvedValues list.

              • resolvedValues — (Array<String>)

                A list of additional values that have been recognized for the slot.

            • shape — (String)

              When the shape value is List, it indicates that the values field contains a list of slot values. When the value is Scalar, it indicates that the value field contains a single value.

              Possible values include:
              • "Scalar"
              • "List"
            • values — (Array<map>)

              A list of one or more values that the user provided for the slot. For example, if a for a slot that elicits pizza toppings, the values might be "pepperoni" and "pineapple."

          • state — (String)

            Contains fulfillment information for the intent.

            Possible values include:
            • "Failed"
            • "Fulfilled"
            • "InProgress"
            • "ReadyForFulfillment"
            • "Waiting"
            • "FulfillmentInProgress"
          • confirmationState — (String)

            Contains information about whether fulfillment of the intent has been confirmed.

            Possible values include:
            • "Confirmed"
            • "Denied"
            • "None"
        • activeContexts — (Array<map>)

          One or more contexts that indicate to Amazon Lex V2 the context of a request. When a context is active, Amazon Lex V2 considers intents with the matching context as a trigger as the next intent in a session.

          • namerequired — (String)

            The name of the context.

          • timeToLiverequired — (map)

            Indicates the number of turns or seconds that the context is active. Once the time to live expires, the context is no longer returned in a response.

            • timeToLiveInSecondsrequired — (Integer)

              The number of seconds that the context is active. You can specify between 5 and 86400 seconds (24 hours).

            • turnsToLiverequired — (Integer)

              The number of turns that the context is active. You can specify up to 20 turns. Each request and response from the bot is a turn.

          • contextAttributesrequired — (map<String>)

            A list of contexts active for the request. A context can be activated when a previous intent is fulfilled, or by including the context in the request.

            If you don't specify a list of contexts, Amazon Lex V2 will use the current list of contexts for the session. If you specify an empty list, all contexts for the session are cleared.

        • sessionAttributes — (map<String>)

          Map of key/value pairs representing session-specific context information. It contains application information passed between Amazon Lex V2 and a client application.

        • originatingRequestId — (String)

      • interpretations — (Array<map>)

        A list of intents that Amazon Lex V2 determined might satisfy the user's utterance.

        Each interpretation includes the intent, a score that indicates now confident Amazon Lex V2 is that the interpretation is the correct one, and an optional sentiment response that indicates the sentiment expressed in the utterance.

        • nluConfidence — (map)

          Determines the threshold where Amazon Lex V2 will insert the AMAZON.FallbackIntent, AMAZON.KendraSearchIntent, or both when returning alternative intents in a response. AMAZON.FallbackIntent and AMAZON.KendraSearchIntent are only inserted if they are configured for the bot.

          • score — (Float)

            A score that indicates how confident Amazon Lex V2 is that an intent satisfies the user's intent. Ranges between 0.00 and 1.00. Higher scores indicate higher confidence.

        • sentimentResponse — (map)

          The sentiment expressed in an utterance.

          When the bot is configured to send utterances to Amazon Comprehend for sentiment analysis, this field contains the result of the analysis.

          • sentiment — (String)

            The overall sentiment expressed in the user's response. This is the sentiment most likely expressed by the user based on the analysis by Amazon Comprehend.

            Possible values include:
            • "MIXED"
            • "NEGATIVE"
            • "NEUTRAL"
            • "POSITIVE"
          • sentimentScore — (map)

            The individual sentiment responses for the utterance.

            • positive — (Float)

              The level of confidence that Amazon Comprehend has in the accuracy of its detection of the POSITIVE sentiment.

            • negative — (Float)

              The level of confidence that Amazon Comprehend has in the accuracy of its detection of the NEGATIVE sentiment.

            • neutral — (Float)

              The level of confidence that Amazon Comprehend has in the accuracy of its detection of the NEUTRAL sentiment.

            • mixed — (Float)

              The level of confidence that Amazon Comprehend has in the accuracy of its detection of the MIXED sentiment.

        • intent — (map)

          A list of intents that might satisfy the user's utterance. The intents are ordered by the confidence score.

          • namerequired — (String)

            The name of the intent.

          • slots — (map<map>)

            A map of all of the slots for the intent. The name of the slot maps to the value of the slot. If a slot has not been filled, the value is null.

            • value — (map)

              The current value of the slot.

              • originalValue — (String)

                The text of the utterance from the user that was entered for the slot.

              • interpretedValuerequired — (String)

                The value that Amazon Lex V2 determines for the slot. The actual value depends on the setting of the value selection strategy for the bot. You can choose to use the value entered by the user, or you can have Amazon Lex V2 choose the first value in the resolvedValues list.

              • resolvedValues — (Array<String>)

                A list of additional values that have been recognized for the slot.

            • shape — (String)

              When the shape value is List, it indicates that the values field contains a list of slot values. When the value is Scalar, it indicates that the value field contains a single value.

              Possible values include:
              • "Scalar"
              • "List"
            • values — (Array<map>)

              A list of one or more values that the user provided for the slot. For example, if a for a slot that elicits pizza toppings, the values might be "pepperoni" and "pineapple."

          • state — (String)

            Contains fulfillment information for the intent.

            Possible values include:
            • "Failed"
            • "Fulfilled"
            • "InProgress"
            • "ReadyForFulfillment"
            • "Waiting"
            • "FulfillmentInProgress"
          • confirmationState — (String)

            Contains information about whether fulfillment of the intent has been confirmed.

            Possible values include:
            • "Confirmed"
            • "Denied"
            • "None"
      • requestAttributes — (map<String>)

        The attributes sent in the request.

      • sessionId — (String)

        The identifier of the session in use.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

recognizeUtterance(params = {}, callback) ⇒ AWS.Request

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

The following request fields must be compressed with gzip and then base64 encoded before you send them to Amazon Lex V2.

  • requestAttributes

  • sessionState

The following response fields are compressed using gzip and then base64 encoded by Amazon Lex V2. Before you can use these fields, you must decode and decompress them.

  • inputTranscript

  • interpretations

  • messages

  • requestAttributes

  • sessionState

The example contains a Java application that compresses and encodes a Java object to send to Amazon Lex V2, and a second that decodes and decompresses a response from Amazon Lex V2.

If the optional post-fulfillment response is specified, the messages are returned as follows. For more information, see PostFulfillmentStatusSpecification.

  • Success message - Returned if the Lambda function completes successfully and the intent state is fulfilled or ready fulfillment if the message is present.

  • Failed message - The failed message is returned if the Lambda function throws an exception or if the Lambda function returns a failed intent state without a message.

  • Timeout message - If you don't configure a timeout message and a timeout, and the Lambda function doesn't return within 30 seconds, the timeout message is returned. If you configure a timeout, the timeout message is returned when the period times out.

For more information, see Completion message.

Service Reference:

Examples:

Calling the recognizeUtterance operation

var params = {
  botAliasId: 'STRING_VALUE', /* required */
  botId: 'STRING_VALUE', /* required */
  localeId: 'STRING_VALUE', /* required */
  requestContentType: 'STRING_VALUE', /* required */
  sessionId: 'STRING_VALUE', /* required */
  inputStream: Buffer.from('...') || 'STRING_VALUE' || streamObject,
  requestAttributes: 'STRING_VALUE',
  responseContentType: 'STRING_VALUE',
  sessionState: 'STRING_VALUE'
};
lexruntimev2.recognizeUtterance(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • botId — (String)

      The identifier of the bot that should receive the request.

    • botAliasId — (String)

      The alias identifier in use for the bot that should receive the request.

    • localeId — (String)

      The locale where the session is in use.

    • sessionId — (String)

      The identifier of the session in use.

    • sessionState — (String)

      Sets the state of the session with the user. You can use this to set the current intent, attributes, context, and dialog action. Use the dialog action to determine the next step that Amazon Lex V2 should use in the conversation with the user.

      The sessionState field must be compressed using gzip and then base64 encoded before sending to Amazon Lex V2.

    • requestAttributes — (String)

      Request-specific information passed between the client application and Amazon Lex V2

      The namespace x-amz-lex: is reserved for special attributes. Don't create any request attributes for prefix x-amz-lex:.

      The requestAttributes field must be compressed using gzip and then base64 encoded before sending to Amazon Lex V2.

    • requestContentType — (String)

      Indicates the format for audio input or that the content is text. The header must start with one of the following prefixes:

      • PCM format, audio data must be in little-endian byte order.

        • audio/l16; rate=16000; channels=1

        • audio/x-l16; sample-rate=16000; channel-count=1

        • audio/lpcm; sample-rate=8000; sample-size-bits=16; channel-count=1; is-big-endian=false

      • Opus format

        • audio/x-cbr-opus-with-preamble;preamble-size=0;bit-rate=256000;frame-size-milliseconds=4

      • Text format

        • text/plain; charset=utf-8

    • responseContentType — (String)

      The message that Amazon Lex V2 returns in the response can be either text or speech based on the responseContentType value.

      • If the value is text/plain;charset=utf-8, Amazon Lex V2 returns text in the response.

      • If the value begins with audio/, Amazon Lex V2 returns speech in the response. Amazon Lex V2 uses Amazon Polly to generate the speech using the configuration that you specified in the requestContentType parameter. For example, if you specify audio/mpeg as the value, Amazon Lex V2 returns speech in the MPEG format.

      • If the value is audio/pcm, the speech returned is audio/pcm at 16 KHz in 16-bit, little-endian format.

      • The following are the accepted values:

        • audio/mpeg

        • audio/ogg

        • audio/pcm (16 KHz)

        • audio/* (defaults to mpeg)

        • text/plain; charset=utf-8

    • inputStream — (Buffer, Typed Array, Blob, String, ReadableStream)

      User input in PCM or Opus audio format or text format as described in the requestContentType parameter.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • inputMode — (String)

        Indicates whether the input mode to the operation was text or speech.

      • contentType — (String)

        Content type as specified in the responseContentType in the request.

      • messages — (String)

        A list of messages that were last sent to the user. The messages are ordered based on the order that you returned the messages from your Lambda function or the order that the messages are defined in the bot.

        The messages field is compressed with gzip and then base64 encoded. Before you can use the contents of the field, you must decode and decompress the contents. See the example for a simple function to decode and decompress the contents.

      • interpretations — (String)

        A list of intents that Amazon Lex V2 determined might satisfy the user's utterance.

        Each interpretation includes the intent, a score that indicates how confident Amazon Lex V2 is that the interpretation is the correct one, and an optional sentiment response that indicates the sentiment expressed in the utterance.

        The interpretations field is compressed with gzip and then base64 encoded. Before you can use the contents of the field, you must decode and decompress the contents. See the example for a simple function to decode and decompress the contents.

      • sessionState — (String)

        Represents the current state of the dialog between the user and the bot.

        Use this to determine the progress of the conversation and what the next action might be.

        The sessionState field is compressed with gzip and then base64 encoded. Before you can use the contents of the field, you must decode and decompress the contents. See the example for a simple function to decode and decompress the contents.

      • requestAttributes — (String)

        The attributes sent in the request.

        The requestAttributes field is compressed with gzip and then base64 encoded. Before you can use the contents of the field, you must decode and decompress the contents.

      • sessionId — (String)

        The identifier of the session in use.

      • inputTranscript — (String)

        The text used to process the request.

        If the input was an audio stream, the inputTranscript field contains the text extracted from the audio stream. This is the text that is actually processed to recognize intents and slot values. You can use this information to determine if Amazon Lex V2 is correctly processing the audio that you send.

        The inputTranscript field is compressed with gzip and then base64 encoded. Before you can use the contents of the field, you must decode and decompress the contents. See the example for a simple function to decode and decompress the contents.

      • audioStream — (Buffer(Node.js), Typed Array(Browser), ReadableStream)

        The prompt or statement to send to the user. This is based on the bot configuration and context. For example, if Amazon Lex V2 did not understand the user intent, it sends the clarificationPrompt configured for the bot. If the intent requires confirmation before taking the fulfillment action, it sends the confirmationPrompt. Another example: Suppose that the Lambda function successfully fulfilled the intent, and sent a message to convey to the user. Then Amazon Lex V2 sends that message in the response.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.