SpeechTilesAndamento Docs
Get started
SDK Reference · Method

setUserIntent

Sets the current application-supplied user intent.

Declaration

public func setUserIntent(
    _ intent: String
) -> STResult

Overview

Requires initialization.

User intent is an application-controlled Conversation input used by declarative transition logic. It is different from a speech-recognition hypothesis: the application supplies the intent value, while the Conversation definition determines how that value participates in routing.

_ = conversation.setUserIntent("start")

Synchronous intent handling

During speech-recognition callbacks, an application may set an intent based on a partial or complete hypothesis. Set the intent synchronously before returning from the callback when immediate recognition interruption and intent routing are required. The intent string must match the Conversation configuration.

Parameters

  • intent — String The application-defined intent identifier used for conversation transitions.

Usage example

In the application’s conversationReceivedSpeechRecognition callback, interpret the recognized hypothesis and set the intent before returning if the conversation should react immediately. mapHypothesisToIntent is an application-defined helper, not a framework method.

func conversationReceivedSpeechRecognition(
    moduleID: String,
    data: STConversation.STSRData
) {
    guard moduleID == "node.ask" else { return }

    let hypothesis = (data.recognitionData?.hypothesis ?? "")
        .trimmingCharacters(in: .whitespacesAndNewlines)
    guard !hypothesis.isEmpty else { return }

    if let intent = mapHypothesisToIntent(hypothesis) {
        _ = conversation.setUserIntent(intent)
    } else {
        data.clientRejectedHypothesis = true
    }
}

Result handling

This method returns an STResult. Check the returned value for success or failure.

See Also