public final class IntentResult
- Object
- IntentResult
What an intent handler hands back.
A result carries up to four independent things, and every consumer takes the parts it understands and ignores the rest:
- a value, which the Shortcuts app pipes into the next action
- a spoken line, which an assistant reads aloud
- a snippet, a small layout shown alongside the answer
- an open route, which continues the interaction inside the app
Nothing is mandatory. IntentResult.ok() is a complete, valid answer meaning
“done, nothing to report”.
return IntentResult.value(orderId)
.withDialog("Your coffee is on the way")
.withSnippet(orderCard);
The snippet is a surface, not a Form
A snippet is rendered by the platform while your app may not be on screen, so
it uses the com.codename1.surfaces node catalog and obeys the same
dead-process rule: it serializes to data at the moment you return it. That is
also why there is no way to hand back a Form – a live component tree has
nowhere to live once the handler returns.
Methods
Inherited methods
Method details
ok
public static IntentResult ok()value
public static IntentResult value(Object value)Parameters
valueObject- a String, Number, Boolean or Date
spoken
public static IntentResult spoken(String spoken)ok().withDialog(spoken).Parameters
spokenString- the line to speak
entity
public static IntentResult entity(AppEntity e)Parameters
eAppEntity- the entity produced
opens
public static IntentResult opens(String routeUrl)A result that opens the app at a route rather than answering in place.
The URL is resolved through the same com.codename1.annotations.Route
table that handles deep links, so an intent and a link to the same screen
stay in agreement by construction.
Parameters
routeUrlString- the route to navigate to, e.g.
/orders/42
failed
public static IntentResult failed(String userVisibleMessage)Parameters
userVisibleMessageString- what went wrong, in the user’s terms
withDialog
public IntentResult withDialog(String spoken)Parameters
spokenString- the line to speak
Returns
withSnippet
public IntentResult withSnippet(SurfaceNode node)Parameters
nodeSurfaceNode- the surface node tree to render
Returns
withOpenUrl
public IntentResult withOpenUrl(String routeUrl)Parameters
routeUrlString- the route to navigate to
Returns
isFailed
public boolean isFailed()getErrorMessage
public String getErrorMessage()getValue
public Object getValue()getDialog
public String getDialog()getSnippet
public SurfaceNode getSnippet()getOpenUrl
public String getOpenUrl()getEntity
public AppEntity getEntity()toString
public String toString()