About Prompt Templates

A prompt template is a prompt represented as an expression and evaluated at the time it is queued up for playback.

There is added support for a new type of prompt file to the user and system prompts already available. This new file has the filename extension .tpl and can be referenced in a script just like the other .wav prompt files could.

In addition, not related to the expression, there is added support for two new prompt file extensions: .tts and .ssml . Files ending with these extensions are expected to be text files containing the text to be rendered as audio using a configured TTS server.

Since Cisco CRS 3.0, when referencing a user or system prompt, the extension of the file was optional. If the extension .wav,.tpl,.tts or .ssml is specified, Cisco CRS searches for only this specific prompt. If no extension is specified, the search starts with a .wav file, and if none is found, then a file with an .ssml extension is searched, and then .tts extension, and finally.tpl extension is searched.

If no extension is located for the first language in the language context, then the search moves to its parent language or the next one in the context. This search is similar to the one that existed in Cisco CRS 3.0 for user and system grammars where files with the extension.gsl and .digit are supported.

When a user or system prompt with the.tpl extension is located, it is loaded as a text file and parsed by the Expression Language manager and the result must be a prompt object, or an object of a data type that can be converted to a Prompt as described in. The expression specified in the text file does not have access to script variables. However, if defined using a complex block expression, the block can be parameterized like a method declaration, allowing for the scripts to customize the evaluation of the expression.

For example, say we have the following user prompt in the user repository defined as currency.tpl:

(float amount, boolean colloquial = true) {
int dollars = (int)amount;
int cents = ((int)(amount * 100.0F)) - dollars * 100;
Prompt result = N[dollars];
if (!colloquial) {
result += P[us.wav];
}
result += P[dollars.wav] + P[and] + N[cents] + P[cents.wav];
return result;
}

You could take advantage of this user prompt within a script to create a very simple currency generator of the US currency. This prompt defines two arguments that can be customized inside the script: amount, which is mandatory, as it has no default value, represents the amount to be played back; and colloquial, which defaults to true, can be used to customized the playback of the US currency as eitherUS dollars or simply dollars. The result is a prompt concatenation that can be queued for playback directly. Inside the script, this prompt is referenced in the following ways:

P["currency.tpl", 3.23F]
P["currency.tpl", BankAmount, false]
- where BankAmount is a script variable
P["currency.tpl", BankAmount, Colloquial]
P["currency.tpl", 10.0F + BankAmount]

If referenced without supplying the mandatory arguments, an ExpressionNotInitializedException exception is thrown back. If the arguments passed in are of an invalid type, an ExpressionClassCastException exception is thrown back. If more arguments than declared are passed in, they are simply ignored.

See Table for other examples of prompt template files.

More Prompt Template File Examples

1

P[prompt.wav]

2

P[prompt.wav] + P[prompt2]

3

TTS[John Doe] @ L[en_US] ||| S[John Doe]

4

P[P1] @ TUE || P[P2] @ MON

Example 3 in the preceding table represents a substitute prompt where first an attempt is made to generate the string “John Doe” localized as US English using the system configured TTS provider, and if that fails for any reason, the system falls back to the second prompt which spells back the string “John Doe”. Example 4 represents a TimeOfDay prompt where no prompts are played on Sundays, the user prompt P2 is played on Mondays, and the P1 prompt is played on all other days.