> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: openModal()

## Article: openModal()

## Article Link: https://dev.wix.com/docs/sdk/host-modules/dashboard/open-modal.md

## Article Content:

# openModal()

Opens a [dashboard modal extension](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/dashboard-extensions/dashboard-modals/about-dashboard-modals.md) on your app's dashboard page.

![Open modal](https://wixmp-833713b177cebf373f611808.wixmp.com/images/d250ca55bff0e5575608f47a92d74346.gif)

> **Notes:** 
> - This method doesn't work when [extending sites](https://dev.wix.com/docs/develop-websites.md) or [building apps with Blocks](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/wix-blocks/about-wix-blocks.md).
> - Before you call this method, you need a dashboard modal extension. Learn more about implementing dashboard modal extensions with the [Wix CLI](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/wix-cli/supported-extensions/dashboard-extensions/dashboard-modals/add-dashboard-modal-extensions-with-the-cli.md) and in [self-managed apps](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/self-hosting/supported-extensions/dashboard-extensions/add-self-hosted-dashboard-modal-extensions.md).

## Method declaration
```ts
(modalInfo: ModalInfo) => { modalClosed: Promise<Serializable> }
```

## Parameters

| Name        | Type        | Description                                                |
|:------------|:------------|:-----------------------------------------------------------|
| `modalInfo` | `ModalInfo` | Information about the dashboard modal to open. |

> **Note:** `openModal()` used to accept 2 parameters: `modalId` and `params`. These parameters have been wrapped inside a `modalInfo` object. Using 2 parameters is deprecated but still supported.

#### `ModalInfo` object

| Name      | Type                  | Description                                                                |
|:----------|:----------------------|:---------------------------------------------------------------------------|
| `modalId` | `string`              | ID of the dashboard modal extension to open. You can find this ID in your app's dashboard, in the modal extension's settings. |
| `params`  | `Record<string, any>` | Optional. Custom data to pass into the dashboard modal extension. The extension can access this data using [`observeState()`](https://dev.wix.com/docs/sdk/host-modules/dashboard/observe-state.md). |


## Returns

```
{ modalClosed: Promise<Serializable> }
```

> **Note:** Don't use relative CSS height units such as `vh` in the extensions opened by this method. The host adjusts extension heights automatically. If your extension uses relative height units by default, make sure to turn them off.

## Examples
> **Note:** To call this method in [self-managed apps](https://dev.wix.com/docs/api-reference/articles/platform-overview/about-self-managed-apps.md), you need to create a [client](https://dev.wix.com/docs/sdk/articles/set-up-a-client/about-the-wix-client.md). See the [setup](https://dev.wix.com/docs/sdk/host-modules/dashboard/introduction.md) guide for more details.

### Open a modal

```js
import { dashboard } from '@wix/dashboard';

dashboard.openModal({ modalId: '1d52d058-0392-44fa-bd64-ed09275a6fcc' });
```

### Pass extra data to a modal

```ts
import { dashboard } from '@wix/dashboard';

dashboard.openModal({ 
  modalId: '1d52d058-0392-44fa-bd64-ed09275a6fcc', 
  params: { firstName: 'Name' } 
});
```
You can access the data passed to `openModal()` in your extension code using [`observeState()`](https://dev.wix.com/docs/sdk/host-modules/dashboard/observe-state.md).

### Get notified when the modal is closed
```js
import { dashboard } from '@wix/dashboard';

const { modalClosed } = dashboard.openModal({ modalId: '1d52d058-0392-44fa-bd64-ed09275a6fcc' });

modalClosed.then(result => {
  if(result) {
    console.log('The modal was closed and returned the value:', result);
  } else {
    console.log('The modal was closed without any data.'); 
  }
})
```