Intents
5.24.0In certain workflow scenarios, your app may need to start (or activate) a specific app. For instance, you may have an app showing client portfolios with financial instruments. When the user clicks on an instrument, you want to start an app which shows a chart for that instrument. In other cases, you may want to present the user with several options for executing an action or handling data from the current app. The Intents API makes all that possible by enabling apps to register, find and raise Intents.
The Intents API is accessible through the glue.intents
object.
APIobject
Description
Intents API
Available since version Glue42 3.9Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
resolver | Resolver | API for controlling the Intents Resolver UI app. |
Methods
allmethod
findmethod
Signature
(intentFilter?: string | IntentFilter) => Promise<Intent[]>
Description
Retrieves Intents by a specified filter. If no filter is supplied, all available Intents will be retrieved.
Parameters
Name | Type | Required | Description |
---|---|---|---|
intentFilter | string | IntentFilter | can be the intent name or a IntentFilter filtering criteria. |
raisemethod
Signature
(request: string | IntentRequest) => Promise<IntentResult>
Description
Raises an intent.
Parameters
Name | Type | Required | Description |
---|---|---|---|
request | string | IntentRequest | The name of the Intent to raise, or an |
registermethod
Signature
(intent: string | AddIntentListenerRequest, handler: (context: IntentContext) => any) => Promise<{ unsubscribe: UnsubscribeFunction; }>
Description
Registers an Intent handler. If your app is already registered as an Intent handler through its configuration, use this method to supply a handler for the specified Intent. Otherwise, you can use it to register your app as an Intent handler dynamically at runtime. Dynamically registered Intent handlers share the life span of the respective app instance.
Parameters
Name | Type | Required | Description |
---|---|---|---|
intent | string | AddIntentListenerRequest | The name of the Intent to be handled, or an object specifying the Intent name and additional settings for handling the Intent. |
|
handler | (context: IntentContext) => any | Handler function for the raised Intent. |
AddIntentListenerRequestobject
Description
Object used for defining Intents dynamically. Dynamically registered Intent handlers share the life span of the respective app instance.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
contextTypes | string[] | The types of predefined data structures with which the app can work. |
||
description | string | Description for the Intent. |
||
displayName | string | The human readable name of the Intent. Can be used in context menus or other UI elements to visualize the Intent. |
||
icon | string | Icon for the Intent to be displayed in a UI. |
||
intent | string | Name of the Intent to register. |
||
resultType | string | The type of predefined data structure which the Intent handler returns. |
Configobject
Description
Global Intent API settings.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
enableIntentsResolverUI | boolean | true | If |
|
intentsResolverAppName | string | Specify the name of your custom Intents Resolver app to be used for raised Intents. If not provided, the Intents API will use the default Intents Resolver UI app. |
||
methodResponseTimeoutMs | number | 60000 | Interval in milliseconds to wait for a response from Intents Resolver UI. |
Intentobject
Description
Describes an Intent.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
handlers | IntentHandler[] | Collection of objects describing Intent handler implementations for the Intent. |
||
name | string | Name of the Intent. |
IntentContextobject
Description
Describes the predefined data structure that will be passed to an Intent handler.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
data | { [key: string]: any; } | Data passed as an argument to the Intent handler implementation. |
||
type | string | Type of the predefined data structure. |
IntentFilterobject
Description
Filter for retrieving Intents.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
contextType | string | The type of predefined data structure with which the Intent handler works. |
||
name | string | Name of the Intent to retrieve. |
||
resultType | string | The type of predefined data structure which the Intent handler returns. |
IntentHandlerobject
Description
Describes an Intent handler implementation.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
applicationDescription | string | User-friendly description of the app, as specified in the app configuration. |
||
applicationIcon | string | Icon of the app that has registered the Intent handler, as specified in the app configuration. |
||
applicationName | string | Name of the app that has registered the Intent, as specified in the app configuration. |
||
applicationTitle | string | Title of the app that has registered the Intent, as specified in the app configuration. |
||
contextTypes | string[] | The types of predefined data structures with which the Intent handler works. |
||
displayName | string | The human readable name of the Intent, as specified in the Intent definition. |
||
instanceId | string | ID of the running app instance. |
||
instanceTitle | string | Title of the window of the running app instance. |
||
resultType | string | The type of predefined data structure which the Intent handler returns. |
||
type | "app" | "instance" | The type of the Intent handler - an app declared as an Intent handler via its configuration, or a running instance of an app. Dynamically registered Intent handlers are also counted as running instances. |
IntentRequestobject
Description
Describes a request for raising an Intent.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
context | IntentContext | Context data that will be provided to the Intent handler. |
||
handlers | IntentHandler[] | Collection of Intent handlers that can be presented to the user via an Intents Resolver UI. If there isn't an Intents Resolver app available (or if the list consists of only one handler), the first member of the collection will be used as an Intent handler. |
||
intent | string | Name of the intent to raise. |
||
options | ApplicationStartOptions |
|
||
target | "startNew" | "reuse" | { app?: string; instance?: string; } | Target for the raised Intent. Use |
||
timeout | number | 90000 | Interval in milliseconds to wait for the |
|
waitUserResponseIndefinitely | boolean | false | If |
IntentResultobject
Description
Describes the result from a raised Intent.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
handler | IntentHandler | The Intent handler implementation used for handling the Intent. |
||
request | IntentRequest | The |
||
result | any | Data returned by the Intent handler implementation. |
Resolverobject
Description
API for controlling the Intents Resolver UI app.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
intent | string | Name of the raised Intent. |
Methods
onHandlerAddedmethod
Signature
(callback: (handler: ResolverIntentHandler) => void) => UnsubscribeFunction
Description
Notifies when a handler for the current Intent is added. Replays already existing handlers.
Parameters
Name | Type | Required | Description |
---|---|---|---|
callback | (handler: ResolverIntentHandler) => void | Callback function for handling the event. |
onHandlerRemovedmethod
Signature
(callback: (removedHandler: ResolverIntentHandler) => void) => UnsubscribeFunction
Description
Notifies when a handler for the current Intent is removed.
Parameters
Name | Type | Required | Description |
---|---|---|---|
callback | (removedHandler: ResolverIntentHandler) => void | Callback function for handling the event. |
sendResponsemethod
Signature
(handler: ResolverIntentHandler) => Promise<InvocationResult<any>>
Description
Sends the chosen Intent handler to the app which raised the Intent.
Parameters
Name | Type | Required | Description |
---|---|---|---|
handler | ResolverIntentHandler |
ResolverIntentHandlerobject
Description
Object used in the Intents Resolver API for describing an Intent handler app.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
applicationIcon | string | Icon of the Intent handler app. |
||
applicationName | string | Name of the Intent handler app. |
||
instanceId | string | ID of the Intent handler app instance. |