# API

**Kind**: interface | **Module**: [Intents](https://docs.interop.io/desktop/reference/javascript/intents/index.md) | **Access**: `io.intents`

**Source**: https://docs.interop.io/desktop/reference/javascript/intents/api/index.html

Intents API.

## Properties

- **`resolver`** (`Resolver`, optional)
  API for controlling the Intents Resolver UI app.

## Methods

### all

Retrieves all registered Intents.

```ts
() => Promise<Intent[]>
```

**Returns**: `Promise<Intent[]>`

### clearSavedHandlers

Removes all saved Intent handlers for previously raised Intents.

*Since: @interopio/desktop 6.7.0*

```ts
() => Promise<void>
```

**Returns**: `Promise<void>`

### filterHandlers

Filters Intent handlers by specified criteria. If there are more than one valid Intent handlers and the Intents Resolver UI is enabled, it will open and display the available handlers.

*Since: io.Connect Desktop 9.2, @interopio/desktop 6.2.0*

```ts
(handlerFilter: HandlerFilter) => Promise<FilterHandlersResult>
```

**Parameters**

- **`handlerFilter`** (`HandlerFilter`, required)
  Filter for the list of Intent handlers to return.

**Returns**: `Promise<FilterHandlersResult>`

### find

Retrieves Intents by a specified filter. If no filter is supplied, all available Intents will be retrieved.

```ts
(intentFilter?: string | IntentFilter) => Promise<Intent[]>
```

**Parameters**

- **`intentFilter`** (`string | IntentFilter`, optional)
  Filter for retrieving Intents. Can be the Intent name only, or an `IntentFilter` object supplying more criteria for filtering the Intents.

**Returns**: `Promise<Intent[]>`

### getIntents

Retrieves all Intents associated with an Intent handler.

*Since: io.Connect Desktop 9.2, @interopio/desktop 6.2.0*

```ts
(handler: IntentHandler) => Promise<GetIntentsResult>
```

**Parameters**

- **`handler`** (`IntentHandler`, required)
  Intent handler whose Intents to retrieve.

**Returns**: `Promise<GetIntentsResult>`

### onHandlerAdded

Notifies when a handler for an Intent is added. Returns an unsubscribe function.

*Since: @interopio/desktop 6.9.0*

```ts
(callback: (handler: IOConnectDesktop.Intents.IntentHandler, intentName: string) => void) => UnsubscribeFunction
```

**Parameters**

- **`callback`** (`(handler: IOConnectDesktop.Intents.IntentHandler, intentName: string) => void`, required)
  Callback function for handling the event. Receives an object describing the added Intent handler as an argument.

**Returns**: `UnsubscribeFunction`

### onHandlerRemoved

Notifies when a handler for an Intent is removed. Returns an unsubscribe function.

*Since: @interopio/desktop 6.9.0*

```ts
(callback: (handler: IOConnectDesktop.Intents.IntentHandler, intentName: string) => void) => UnsubscribeFunction
```

**Parameters**

- **`callback`** (`(handler: IOConnectDesktop.Intents.IntentHandler, intentName: string) => void`, required)
  Callback function for handling the event. Receives an object describing the removed Intent handler as an argument.

**Returns**: `UnsubscribeFunction`

### raise

Raises an intent.

```ts
(request: string | IntentRequest) => Promise<IntentResult>
```

**Parameters**

- **`request`** (`string | IntentRequest`, required)
  The name of the Intent to raise, or an `IntentRequest` object holding
  settings for targeting Intent handlers, passing context, app start options and more.

**Returns**: `Promise<IntentResult>`

### register

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.

```ts
(intent: string | AddIntentListenerRequest, handler: (context: IntentContext, caller?: IOConnectDesktop.Interop.Instance) => any) => Promise<{ unsubscribe: UnsubscribeFunction }>
```

**Parameters**

- **`intent`** (`string | AddIntentListenerRequest`, required)
  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, caller?: IOConnectDesktop.Interop.Instance) => any`, required)
  The callback that will handle a raised intent. Will be called with an IntentContext if it is provided by the raising application and caller - the Interop Instance which raised the intent

**Returns**: `Promise<{ unsubscribe: UnsubscribeFunction }>`

## Related types

- [AddIntentListenerRequest](https://docs.interop.io/desktop/reference/javascript/intents/addintentlistenerrequest/index.md)
- [FilterHandlersResult](https://docs.interop.io/desktop/reference/javascript/intents/filterhandlersresult/index.md)
- [GetIntentsResult](https://docs.interop.io/desktop/reference/javascript/intents/getintentsresult/index.md)
- [HandlerFilter](https://docs.interop.io/desktop/reference/javascript/intents/handlerfilter/index.md)
- [Instance](https://docs.interop.io/desktop/reference/javascript/interop/instance/index.md)
- [Intent](https://docs.interop.io/desktop/reference/javascript/intents/intent/index.md)
- [IntentContext](https://docs.interop.io/desktop/reference/javascript/intents/intentcontext/index.md)
- [IntentFilter](https://docs.interop.io/desktop/reference/javascript/intents/intentfilter/index.md)
- [IntentHandler](https://docs.interop.io/desktop/reference/javascript/intents/intenthandler/index.md)
- [IntentRequest](https://docs.interop.io/desktop/reference/javascript/intents/intentrequest/index.md)
- [IntentResult](https://docs.interop.io/desktop/reference/javascript/intents/intentresult/index.md)
- [Resolver](https://docs.interop.io/desktop/reference/javascript/intents/resolver/index.md)
- [UnsubscribeFunction](https://docs.interop.io/desktop/reference/javascript/search/unsubscribefunction/index.md)
