/AWS1/IF_LR1=>POSTCONTENT()¶
About PostContent¶
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-stateheader set toElicitSlot - 
x-amz-lex-intent-nameheader set to the intent name in the current context - 
x-amz-lex-slot-to-elicitheader set to the slot name for which themessageis eliciting information - 
x-amz-lex-slotsheader 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-stateheader is set toConfirmationand thex-amz-lex-slot-to-elicitheader 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-stateheader is set toElicitIntentand thex-amz-slot-to-elicitheader is omitted. 
 In addition, Amazon Lex also returns your application-specific
sessionAttributes. For more information, see Managing
Conversation Context. 
Method Signature¶
METHODS /AWS1/IF_LR1~POSTCONTENT
  IMPORTING
    !IV_BOTNAME TYPE /AWS1/LR1BOTNAME OPTIONAL
    !IV_BOTALIAS TYPE /AWS1/LR1BOTALIAS OPTIONAL
    !IV_USERID TYPE /AWS1/LR1USERID OPTIONAL
    !IV_SESSIONATTRIBUTES TYPE /AWS1/LR1SYNTHEDJSONATTRSSTR OPTIONAL
    !IV_REQUESTATTRIBUTES TYPE /AWS1/LR1SYNTHEDJSONATTRSSTR OPTIONAL
    !IV_CONTENTTYPE TYPE /AWS1/LR1HTTPCONTENTTYPE OPTIONAL
    !IV_ACCEPT TYPE /AWS1/LR1ACCEPT OPTIONAL
    !IV_INPUTSTREAM TYPE /AWS1/LR1BLOBSTREAM OPTIONAL
    !IV_ACTIVECONTEXTS TYPE /AWS1/LR1SYNTHEDJSONACTCTXSSTR OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_lr1postcontentrsp
  RAISING
    /AWS1/CX_LR1BADGATEWAYEX
    /AWS1/CX_LR1BADREQUESTEX
    /AWS1/CX_LR1CONFLICTEXCEPTION
    /AWS1/CX_LR1DEPENDENCYFAILEDEX
    /AWS1/CX_LR1INTERNALFAILUREEX
    /AWS1/CX_LR1LIMITEXCEEDEDEX
    /AWS1/CX_LR1LOOPDETECTEDEX
    /AWS1/CX_LR1NOTACCEPTABLEEX
    /AWS1/CX_LR1NOTFOUNDEXCEPTION
    /AWS1/CX_LR1REQUESTTIMEOUTEX
    /AWS1/CX_LR1UNSUPPEDMEDIATYP00
    /AWS1/CX_LR1CLIENTEXC
    /AWS1/CX_LR1SERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.
IMPORTING¶
Required arguments:¶
iv_botname TYPE /AWS1/LR1BOTNAME /AWS1/LR1BOTNAME¶
Name of the Amazon Lex bot.
iv_botalias TYPE /AWS1/LR1BOTALIAS /AWS1/LR1BOTALIAS¶
Alias of the Amazon Lex bot.
iv_userid TYPE /AWS1/LR1USERID /AWS1/LR1USERID¶
The ID of the client application user. Amazon Lex uses this to identify a user's conversation with your bot. At runtime, each request must contain the
userIDfield.To decide the user ID to use for your application, consider the following factors.
The
userIDfield must not contain any personally identifiable information of the user, for example, name, personal identification numbers, or other end user personal information.If you want a user to start a conversation on one device and continue on another device, use a user-specific identifier.
If you want the same user to be able to have two independent conversations on two different devices, choose a device-specific identifier.
A user can't have two independent conversations with two different versions of the same bot. For example, a user can't have a conversation with the PROD and BETA versions of the same bot. If you anticipate that a user will need to have conversation with two different versions, for example, while testing, include the bot alias in the user ID to separate the two conversations.
iv_contenttype TYPE /AWS1/LR1HTTPCONTENTTYPE /AWS1/LR1HTTPCONTENTTYPE¶
You pass this value as the
Content-TypeHTTP header.Indicates the audio format or text. The header value 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
iv_inputstream TYPE /AWS1/LR1BLOBSTREAM /AWS1/LR1BLOBSTREAM¶
User input in PCM or Opus audio format or text format as described in the
Content-TypeHTTP header.You can stream audio data to Amazon Lex or you can create a local buffer that captures all of the audio data before sending. In general, you get better performance if you stream audio data rather than buffering the data locally.
Optional arguments:¶
iv_sessionattributes TYPE /AWS1/LR1SYNTHEDJSONATTRSSTR /AWS1/LR1SYNTHEDJSONATTRSSTR¶
You pass this value as the
x-amz-lex-session-attributesHTTP header.Application-specific information passed between Amazon Lex and a client application. The value must be a JSON serialized and base64 encoded map with string keys and values. The total size of the
sessionAttributesandrequestAttributesheaders is limited to 12 KB.For more information, see Setting Session Attributes.
iv_requestattributes TYPE /AWS1/LR1SYNTHEDJSONATTRSSTR /AWS1/LR1SYNTHEDJSONATTRSSTR¶
You pass this value as the
x-amz-lex-request-attributesHTTP header.Request-specific information passed between Amazon Lex and a client application. The value must be a JSON serialized and base64 encoded map with string keys and values. The total size of the
requestAttributesandsessionAttributesheaders is limited to 12 KB.The namespace
x-amz-lex:is reserved for special attributes. Don't create any request attributes with the prefixx-amz-lex:.For more information, see Setting Request Attributes.
iv_accept TYPE /AWS1/LR1ACCEPT /AWS1/LR1ACCEPT¶
You pass this value as the
AcceptHTTP header.The message Amazon Lex returns in the response can be either text or speech based on the
AcceptHTTP header value in the request.
If the value is
text/plain; charset=utf-8, Amazon Lex returns text in the response.If the value begins with
audio/, Amazon Lex returns speech in the response. Amazon Lex uses Amazon Polly to generate the speech (using the configuration you specified in theAcceptheader). For example, if you specifyaudio/mpegas the value, Amazon Lex returns speech in the MPEG format.If the value is
audio/pcm, the speech returned isaudio/pcmin 16-bit, little endian format.The following are the accepted values:
audio/mpeg
audio/ogg
audio/pcm
text/plain; charset=utf-8
audio/* (defaults to mpeg)
iv_activecontexts TYPE /AWS1/LR1SYNTHEDJSONACTCTXSSTR /AWS1/LR1SYNTHEDJSONACTCTXSSTR¶
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 will use the current list of contexts for the session. If you specify an empty list, all contexts for the session are cleared.
RETURNING¶
oo_output TYPE REF TO /aws1/cl_lr1postcontentrsp /AWS1/CL_LR1POSTCONTENTRSP¶
Domain /AWS1/RT_ACCOUNT_ID Primitive Type NUMC 
Examples¶
Syntax Example¶
This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.
DATA(lo_result) = lo_client->postcontent(
  iv_accept = |string|
  iv_activecontexts = |string|
  iv_botalias = |string|
  iv_botname = |string|
  iv_contenttype = |string|
  iv_inputstream = '5347567362473873563239796247513D'
  iv_requestattributes = |string|
  iv_sessionattributes = |string|
  iv_userid = |string|
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  lv_httpcontenttype = lo_result->get_contenttype( ).
  lv_intentname = lo_result->get_intentname( ).
  lv_synthesizedjsonstring = lo_result->get_nluintentconfidence( ).
  lv_synthesizedjsonstring = lo_result->get_alternativeintents( ).
  lv_synthesizedjsonstring = lo_result->get_slots( ).
  lv_synthesizedjsonstring = lo_result->get_sessionattributes( ).
  lv_string = lo_result->get_sentimentresponse( ).
  lv_text = lo_result->get_message( ).
  lv_sensitivestring = lo_result->get_encodedmessage( ).
  lv_messageformattype = lo_result->get_messageformat( ).
  lv_dialogstate = lo_result->get_dialogstate( ).
  lv_string = lo_result->get_slottoelicit( ).
  lv_string = lo_result->get_inputtranscript( ).
  lv_sensitivestringunbounde = lo_result->get_encodedinputtranscript( ).
  lv_blobstream = lo_result->get_audiostream( ).
  lv_botversion = lo_result->get_botversion( ).
  lv_string = lo_result->get_sessionid( ).
  lv_synthesizedjsonactiveco = lo_result->get_activecontexts( ).
ENDIF.