# Widget API

1. **Opening the widget:** \
   `JediDesk("openWidget")` \
   \
   Use this function to open the widget window at the desired time.

***

2. **Close the widget:** \
   `JediDesk("closeWidget")` \
   \
   Use this function to close the widget window at the desired time.

***

3. **Transfer of user data:** \
   `JediDesk("customerData", {` \
   &#x20;  `"name": "test",` \
   &#x20;  `"phone": "380989888999",` \
   &#x20;  `"email": "test@test.test",` \
   &#x20;  `"note": “Description”,` \
   &#x20;  `"language": "en",` \
   &#x20;  `"custom_fields": [` \
   &#x20;     `{"id": 1, "value": "123"},` \
   &#x20;     `{"id": 2, "value": "test"},` \
   &#x20;     `{"id": 551, "value": "test321"}` \
   &#x20;  `]` \
   `})` \
   \
   Use this function to fill and transfer widget user information at the right time.

***

**Allowed fields to transfer:**

| **Parameter**  | **Type**               | **Description**                                                                                                                                                                                                                        |
| -------------- | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name           | string                 | Username                                                                                                                                                                                                                               |
| phone          | string                 | User's phone number                                                                                                                                                                                                                    |
| email          | string                 | User email                                                                                                                                                                                                                             |
| note           | string                 | Additional user description, notes                                                                                                                                                                                                     |
| language       | enum('uk', 'en', 'ru') | User language                                                                                                                                                                                                                          |
| custom\_fields | array                  | <p>Customizable fields. An array of objects. Object parameters: </p><p></p><p><strong>id</strong> - unique id of the field (assigned when creating a field in the admin panel).</p><p></p><p><strong>value</strong> - field value.</p> |
