userInput
The userInput
method gets the input text that the user supplied at a particular stage of the conversation.
NOTE: The history table from getTranscript
does not include the current user text. To retrieve the current user text, use the getUserText method.
Syntax
userInput()
Returns
(string) The user text for the specified stage of the conversation, or nil
for the first history stage if the user did not say anything to start the conversation.
Examples
for i = #history, 1, -1 do local usersaid = history[i]:userInput() if usersaid ~= nil then return string.format("The last thing you said was \"%s\"", usersaid) end end return string.format("You haven't said anything yet (apart from \"%s\").", taskUtils:getUserText() )
This example returns the last thing the user said, or returns You haven't said anything yet (apart from currentUserText) , where currentUserText is the text that the user provided before Answer Server called the Lua script.
for i,s in ipairs(history) do local usersaid = s:userInput() if usersaid ~= nil then return string.format("The first thing you said was \"%s\"", usersaid) end end
This example returns the first thing the user said.