public class InMemoryConversationData extends Object implements ConversationData
Formats values for both display and synthesis using String.valueOf(Object)
.
ConversationData.Format
Constructor and Description |
---|
InMemoryConversationData()
Create a new in-memory conversation data store.
|
Modifier and Type | Method and Description |
---|---|
Object |
get(String key)
Get the raw object stored at
key . |
String |
getFormatted(String key,
ConversationData.Format mode)
Get a version of the data stored at
key suitable for inserting
into the conversation. |
void |
set(String key,
Object value)
Store an object under the specified key.
|
public InMemoryConversationData()
public void set(String key, Object value)
ConversationData
Store an object under the specified key.
Note that since this API is used by Spokestack to store data provided by
the user during voice interactions, key
should not begin with an
underscore (_
) unless intentionally overriding a key set by the
dialogue manager.
set
in interface ConversationData
key
- The key under which value
will be available.value
- Data to store for use by the conversation.public Object get(String key)
ConversationData
key
. This method is only used by
the dialogue system during DialoguePolicy.dump(ConversationData)
to retrieve original slot values for use in cross-session persistence.get
in interface ConversationData
key
- The key whose original object should be returned.key
, or null
if key
is not found in the data.public String getFormatted(String key, ConversationData.Format mode)
ConversationData
Get a version of the data stored at key
suitable for inserting
into the conversation.
Full objects are stored by the API, but the dialogue manager needs
formatted strings to use for prompts. The simplest implementation is to
call Object.toString()
on the stored object, but custom
formatting logic can be supplied as needed.
Occasionally an object (for example, a date) might require different formatting for use in a synthesized voice response than for use in a text-based interface, so a formatting mode is also required.
getFormatted
in interface ConversationData
key
- The key of the data to be retrieved.mode
- The data's destination, either text or voice.key
suitable for use in
the specified medium.Copyright © 2021. All rights reserved.