setRuntimeField
Sets or replaces a named Conversation runtime field.
Declaration
public func setRuntimeField(_ name: String, value: Any) -> STResultOverview
Requires initialization. Runtime fields are application-controlled values made available to Conversation execution. They provide the bridge between application/business state and declarative Conversation behavior.
_ = conversation.setRuntimeField("CollectedName", value: "Antoine")
The method accepts Any because runtime fields can carry values beyond strings. The semantics of where a field is referenced belong to the Conversation Configuration Reference.
Conversation and Prompt Module configurations reference a runtime field using the expression $[FieldName]. For example, a field named CustomerName is referenced as $[CustomerName] in configuration text. The name inside the brackets must match the name used when setting or reading the runtime field.
Runtime field timing
Runtime fields are consumed by declarative Conversation and Prompt Module expressions. When a callback prepares a value needed immediately after it returns, update the field synchronously within that callback.
Parameters
- name — String The name identifying the field or resource.
Usage example
_ = conversation.setRuntimeField(
"pm.lasagnaRecipe.TextSegment",
value: "Add noodles to the boiling water."
)
Result handling
This method returns an STResult. Check the returned value for success or failure.