public final class Prompt extends Object
For an example of the latter, a prompt's text might end in asking the user a
yes/no question. The meanings of "yes" and "no" are highly contextual, so
prompts that end in such questions should include a Proposal
that
includes a contextual interpretation of affirmative and negative responses.
Prompts use template placeholders so that dynamic data can be delivered to
the user at runtime. Placeholders are strings surrounded by double braces
({{variable}}
), similar to
mustache templates, but only variables are supported; no sections,
lambdas, etc.
Modifier and Type | Class and Description |
---|---|
static class |
Prompt.Builder
Prompt builder API.
|
Constructor and Description |
---|
Prompt()
No-arg constructor used by Gson deserialization.
|
Modifier and Type | Method and Description |
---|---|
boolean |
endsConversation() |
FinalizedPrompt |
finalizePrompt(ConversationData dataStore)
Finalize this prompt, filling in all placeholders with data from the
conversation's data store.
|
String |
getId() |
Proposal |
getProposal() |
Prompt[] |
getReprompts() |
String |
getText(ConversationData data)
Get a version of the prompt formatted for print.
|
String |
getVoice(ConversationData data)
Get a version of the prompt formatted for TTS synthesis.
|
String |
toString() |
public String getId()
public String getVoice(ConversationData data)
data
- The current conversation data, used to expand any template
placeholders in the prompt's text.public String getText(ConversationData data)
data
- The current conversation data, used to expand any template
placeholders in the prompt's text.public Proposal getProposal()
public Prompt[] getReprompts()
public boolean endsConversation()
true
if the conversation should end after the current
prompt is delivered; false
otherwise.public FinalizedPrompt finalizePrompt(ConversationData dataStore)
dataStore
- The current state of the conversation data to use for
filling placeholders in prompts.Copyright © 2021. All rights reserved.