Skip to main content

compileSlotValues

Stentor API Reference


Stentor API Reference / stentor-utils/src / compileSlotValues

Function: compileSlotValues()

Call Signature​

compileSlotValues(responseOutput, slots, replaceWhenUndefined?, macros?): string

Defined in: packages/stentor-utils/src/compilers/compileSlotValues.ts:111

Compiles a templated response with slot values from the provided slot map.

For example, when passed "What date do you want your ${flowers}?" and the slot map contains a slot with name flowers it will replace it with the value.

It will handle the different potential value types for slots such as strings, numbers, dates and durations.

By default, if the slot value does not exist, the template value is left untouched.

Parameters​

responseOutput​

string

slots​

RequestSlotMap

replaceWhenUndefined?​

boolean

When set to true, it will replace the value with 'undefined' if it doesn't exist, default behavior is to leave the template as is.

macros?​

MacroMap

Returns​

string

Deprecated​

Use class Compiler, which handles both JSONPaths & Slots

Call Signature​

compileSlotValues(responseOutput, slots, replaceWhenUndefined?, macros?): ResponseOutput

Defined in: packages/stentor-utils/src/compilers/compileSlotValues.ts:112

Compiles a templated response with slot values from the provided slot map.

For example, when passed "What date do you want your ${flowers}?" and the slot map contains a slot with name flowers it will replace it with the value.

It will handle the different potential value types for slots such as strings, numbers, dates and durations.

By default, if the slot value does not exist, the template value is left untouched.

Parameters​

responseOutput​

ResponseOutput

slots​

RequestSlotMap

replaceWhenUndefined?​

boolean

When set to true, it will replace the value with 'undefined' if it doesn't exist, default behavior is to leave the template as is.

macros?​

MacroMap

Returns​

ResponseOutput

Deprecated​

Use class Compiler, which handles both JSONPaths & Slots