> 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

# SendMessage

# Package: inbox

# Namespace: MessagesService

# Method link: https://dev.wix.com/docs/api-reference/crm/communication/inbox/messages/send-message.md

## Permission Scopes:
Manage Inbox Messages: SCOPE.DC-INBOX.MANAGE-MSGS

## Introduction

Sends a message to the business or participant.

Specify the message type in `message.content`
by including the appropriate object: `basic`, `template`, `minimal`, or `form`.
For more information on message types
and how each type renders in Inbox and the Chat widget,
see [Message Types](#message-types).

---

## REST API

### Schema

```
 Method: sendMessage
 Description: Sends a message to the business or participant.  Specify the message type in `message.content` by including the appropriate object: `basic`, `template`, `minimal`, or `form`. For more information on message types and how each type renders in Inbox and the Chat widget, see [Message Types](#message-types).
 URL: https://www.wixapis.com/inbox/v2/messages
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  conversationId, message, message.content
 Method parameters: 
   param name: conversationId | type: conversationId | description: GUID of the conversation to add the message to. | required: true | validation: format GUID
   param name: message | type: Message   | required: true 
        - name: content | type: MessageContent | description: Structured message content. | required: true 
           - ONE-OF: 
              - name: basic | type: BasicMessagePayload | description: Plain text, file, or image message.  
                 - name: items | type: array<BasicMessageData> | description: List of plain text messages, images, and/or files. List items are displayed as separate messages in Inbox and the site's chat widget.  | validation: minItems 1
                    - ONE-OF: 
                       - name: text | type: string | description: Text message.  | validation: minLength 1, maxLength 16384
                       - name: image | type: ImageMessage | description: Image message. Can contain an image from Wix Media or from an external provider.  
                          - name: id | type: string | description: Wix Media GUID.  | validation: maxLength 2000
                          - name: url | type: string | description: URL where the image is hosted. This URL is valid for 10 hours from the time the message is sent.  | validation: maxLength 2000
                          - name: filename | type: string | description: File name of the original file.  | validation: maxLength 255
                          - name: width | type: integer | description: Original image width, in pixels.  | validation: minimum 0
                          - name: height | type: integer | description: Original image height, in pixels.  | validation: minimum 0
                       - name: file | type: FileMessage | description: File attachment. Can contain a file from Wix Media or an external provider.  
                          - name: id | type: string | description: Wix Media GUID.  | validation: maxLength 2000
                          - name: url | type: string | description: URL where the image is hosted. This URL is valid for 10 hours from the time the message is sent.  | validation: maxLength 2000
                          - name: filename | type: string | description: File name of the original file.  | validation: maxLength 255
                          - name: mimeType | type: string | description: File [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types).  | validation: maxLength 100
              - name: template | type: TemplateMessagePayload | description: Template containing an image, title, text, and/or up to 10 call-to-action buttons.  
                 - name: title | type: string | description: Title displayed in the message.  
                 - name: buttons | type: array<Button> | description: List of buttons to display with the message. Buttons can either open a URL or pass interaction details to the Button Interacted event.  Maximum: 10 buttons.  | validation: maxItems 10
                    - name: label | type: string | description: Button label text.  | validation: minLength 1, maxLength 16384
                    - name: launchUrl | type: string | description: If included, the button launches the specified URL.  | validation: maxLength 16384, format WEB_URL
                    - name: postbackProperties | type: PostbackProperties | description: Properties to pass to the Button Interacted event when the button is clicked.  
                       - name: interactionId | type: string | description: GUID you define for the interaction, to be handled by your server.  | validation: minLength 1, maxLength 256
                 - name: orientation | type: Orientation | description: Controls whether the message is displayed in portrait or landscape layout.  Default: `PORTRAIT`.  
                         - enum:
                         -     UNKNOWN_ORIENTATION: Unknown orientation.
                         -     PORTRAIT: Portrait layout.
                         -     LANDSCAPE: Landscape layout.
                 - name: textLines | type: array<string> | description: List of lines of text. Each item in the array is displayed on a new line.  Max: 10 lines (up to 512 characters per line).  | validation: maxItems 10
                 - name: imageUrl | type: string | description: URL where the icon is hosted.  | validation: maxLength 2000, format WEB_URL
              - name: minimal | type: MinimalMessagePayload | description: Minimal message containing a single line of text and an optional icon. Often reports an activity that took place.  
                 - name: text | type: string | description: Message text.  | validation: minLength 1, maxLength 16384
                 - name: iconUrl | type: string | description: URL where the icon is hosted.  | validation: maxLength 2000, format WEB_URL
                 - name: url | type: string | description: If included, URL the user is redirected to when clicking the message.  | validation: maxLength 2000, format WEB_URL
              - name: form | type: FormMessagePayload | description: Message containing submitted form data. Typically sent with a `direction` of `PARTICIPANT_TO_BUSINESS` and message `visibility` of `BUSINESS`.  
                 - name: title | type: string | description: Form title displayed in the message.  | validation: minLength 1, maxLength 256
                 - name: description | type: string | description: Form description displayed below the title.  | validation: minLength 1, maxLength 16384
                 - name: fields | type: array<FormField> | description: List of form fields and values.  | validation: minItems 1, maxItems 30
                    - name: name | type: string | description: Form field display name.  | validation: maxLength 8192
                    - name: value | type: string | description: Submitted value.  | validation: maxLength 8192
                 - name: media | type: array<MediaItem> | description: List of files and/or images attached to the form.  List items are displayed as separate messages in Inbox and the site's chat widget.  | validation: maxItems 15
                    - ONE-OF: 
                       - name: image | type: ImageMessage | description: Image message. Can contain an image from Wix Media or from an external provider.  
                       - name: file | type: FileMessage | description: File attachment. Can contain a file from Wix Media or an external provider.  
              - name: system | type: SystemMessagePayload | description: System message. For internal use.  
                 - name: text | type: string | description: Text message. `\n` renders as a line break.  | validation: maxLength 16384
                 - name: buttons | type: array<Button> | description: List of buttons to display with the message. Buttons can either open a URL or pass interaction details to the Button Interacted event.  Maximum: 10 buttons.  | validation: maxItems 10
                 - name: imageUrl | type: string | description: URL where the icon is hosted.  | validation: maxLength 2000, format WEB_URL
           - name: previewText | type: string | description: Summary of message contents. Displayed in Inbox in the [Message List](https://support.wix.com/en/article/wix-inbox-an-overview).  | validation: maxLength 256
           - name: title | type: string | description: Message title.  
        - name: badges | type: array<Badge> | description: Optional icon and short text providing additional details about the message, such as the app from which the message was sent, or whether the message was an automated response.  Currently only 1 badge is supported.  | validation: maxItems 1
           - name: text | type: string | description: Display text.  
           - name: iconUrl | type: string | description: URL where the icon is hosted.  | validation: format WEB_URL
           - name: badgeVisibility | type: BadgeVisibility | description: Controls whether the badge is visible to the participant. Currently not supported in the Chat widget.  
                 - enum:
                 -     UNKNOWN_BADGE_VISIBILITY: Unkown visibility.
                 -     BUSINESS_AND_PARTICIPANT: Visible to the participant and site collaborators.
                 -     BUSINESS: Visible to site collaborators only.
        - name: visibility | type: MessageVisibility | description: __Required.__ Controls who can see the message.  
             - enum:
             -     UNKNOWN_VISIBILITY: Unknown message visibility.
             -     BUSINESS_AND_PARTICIPANT: Visible to the participant and site collaborators.
             -     BUSINESS: Visible to site collaborators only.
        - name: direction | type: MessageDirection | description: __Required.__ Message direction.  
             - enum:
             -     UNKNOWN_DIRECTION: Unknown message direction.
             -     BUSINESS_TO_PARTICIPANT: The message was sent from the business to the participant.
             -     PARTICIPANT_TO_BUSINESS: The message was sent from the participant to the business.
        - name: createdDate | type: string | description: Date and time the message was sent.  | validation: format date-time
        - name: targetChannelIds | type: array<string> | description: Target channel GUIDs to send the message to.  | validation: maxItems 100, maxLength 100
        - name: sourceChannelId | type: string | description: The channel GUID from which the message was sent.  | validation: maxLength 100
        - name: silent | type: boolean | description: Controls whether the unread count and conversation summary are updated in the [Message List](https://support.wix.com/en/article/wix-inbox-an-overview).  If `true`, unread count and conversation summary are not updated.  Default: `false`  
   param name: sendAs | type: OverrideSenderOptions    
      - enum:
           CALLER - Uses the identity included in the request header.
           PARTICIPANT - Uses the `anonymousVisitorId`, `contactId`, or `memberId` of the conversation's participant.
           BUSINESS_USER - For internal use. Uses the `wixUserId` of the person sending messages on behalf of the business.
   param name: sendNotifications | type: sendNotifications | description: Controls whether the message triggers notifications when it's received.  Default: `false`  
   param name: silent | type: silent | description: Controls whether the unread count and conversation summary are updated in the [Message List](https://support.wix.com/en/article/wix-inbox-an-overview).  If `true`, unread count and conversation summary are not updated. Deprecated: Use `Message.silent` instead.  Default: `false`  
 Return type: SendMessageResponse
  - name: message | type: Message | description: Sent message.  
     - name: id | type: string | description: Message GUID.  | read-only: true 
     - name: content | type: MessageContent | description: Structured message content.  
        - ONE-OF: 
           - name: basic | type: BasicMessagePayload | description: Plain text, file, or image message.  
              - name: items | type: array<BasicMessageData> | description: List of plain text messages, images, and/or files. List items are displayed as separate messages in Inbox and the site's chat widget.  | validation: minItems 1
                 - ONE-OF: 
                    - name: text | type: string | description: Text message.  | validation: minLength 1, maxLength 16384
                    - name: image | type: ImageMessage | description: Image message. Can contain an image from Wix Media or from an external provider.  
                       - name: id | type: string | description: Wix Media GUID.  | validation: maxLength 2000
                       - name: url | type: string | description: URL where the image is hosted. This URL is valid for 10 hours from the time the message is sent.  | validation: maxLength 2000
                       - name: filename | type: string | description: File name of the original file.  | validation: maxLength 255
                       - name: width | type: integer | description: Original image width, in pixels.  | validation: minimum 0
                       - name: height | type: integer | description: Original image height, in pixels.  | validation: minimum 0
                       - name: urlExpiration | type: string | description: Expiration date and time of the URL in `YYYY-MM-DDThh:mm:ss.sssZ` format.  | read-only: true | validation: format date-time
                    - name: file | type: FileMessage | description: File attachment. Can contain a file from Wix Media or an external provider.  
                       - name: id | type: string | description: Wix Media GUID.  | validation: maxLength 2000
                       - name: url | type: string | description: URL where the image is hosted. This URL is valid for 10 hours from the time the message is sent.  | validation: maxLength 2000
                       - name: filename | type: string | description: File name of the original file.  | validation: maxLength 255
                       - name: mimeType | type: string | description: File [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types).  | validation: maxLength 100
                       - name: urlExpiration | type: string | description: Expiration date and time of the URL in `YYYY-MM-DDThh:mm:ss.sssZ` format.  | read-only: true | validation: format date-time
           - name: template | type: TemplateMessagePayload | description: Template containing an image, title, text, and/or up to 10 call-to-action buttons.  
              - name: title | type: string | description: Title displayed in the message.  
              - name: buttons | type: array<Button> | description: List of buttons to display with the message. Buttons can either open a URL or pass interaction details to the Button Interacted event.  Maximum: 10 buttons.  | validation: maxItems 10
                 - name: label | type: string | description: Button label text.  | validation: minLength 1, maxLength 16384
                 - name: launchUrl | type: string | description: If included, the button launches the specified URL.  | validation: maxLength 16384, format WEB_URL
                 - name: postbackProperties | type: PostbackProperties | description: Properties to pass to the Button Interacted event when the button is clicked.  
                    - name: appId | type: string | description: App GUID.  | read-only: true | validation: format GUID
                    - name: interactionId | type: string | description: GUID you define for the interaction, to be handled by your server.  | validation: minLength 1, maxLength 256
              - name: orientation | type: Orientation | description: Controls whether the message is displayed in portrait or landscape layout.  Default: `PORTRAIT`.  
                     - enum:
                     -     UNKNOWN_ORIENTATION: Unknown orientation.
                     -     PORTRAIT: Portrait layout.
                     -     LANDSCAPE: Landscape layout.
              - name: textLines | type: array<string> | description: List of lines of text. Each item in the array is displayed on a new line.  Max: 10 lines (up to 512 characters per line).  | validation: maxItems 10
              - name: imageUrl | type: string | description: URL where the icon is hosted.  | validation: maxLength 2000, format WEB_URL
           - name: minimal | type: MinimalMessagePayload | description: Minimal message containing a single line of text and an optional icon. Often reports an activity that took place.  
              - name: text | type: string | description: Message text.  | validation: minLength 1, maxLength 16384
              - name: iconUrl | type: string | description: URL where the icon is hosted.  | validation: maxLength 2000, format WEB_URL
              - name: url | type: string | description: If included, URL the user is redirected to when clicking the message.  | validation: maxLength 2000, format WEB_URL
           - name: form | type: FormMessagePayload | description: Message containing submitted form data. Typically sent with a `direction` of `PARTICIPANT_TO_BUSINESS` and message `visibility` of `BUSINESS`.  
              - name: title | type: string | description: Form title displayed in the message.  | validation: minLength 1, maxLength 256
              - name: description | type: string | description: Form description displayed below the title.  | validation: minLength 1, maxLength 16384
              - name: fields | type: array<FormField> | description: List of form fields and values.  | validation: minItems 1, maxItems 30
                 - name: name | type: string | description: Form field display name.  | validation: maxLength 8192
                 - name: value | type: string | description: Submitted value.  | validation: maxLength 8192
              - name: media | type: array<MediaItem> | description: List of files and/or images attached to the form.  List items are displayed as separate messages in Inbox and the site's chat widget.  | validation: maxItems 15
                 - ONE-OF: 
                    - name: image | type: ImageMessage | description: Image message. Can contain an image from Wix Media or from an external provider.  
                    - name: file | type: FileMessage | description: File attachment. Can contain a file from Wix Media or an external provider.  
           - name: system | type: SystemMessagePayload | description: System message. For internal use.  
              - name: text | type: string | description: Text message. `\n` renders as a line break.  | validation: maxLength 16384
              - name: buttons | type: array<Button> | description: List of buttons to display with the message. Buttons can either open a URL or pass interaction details to the Button Interacted event.  Maximum: 10 buttons.  | validation: maxItems 10
              - name: imageUrl | type: string | description: URL where the icon is hosted.  | validation: maxLength 2000, format WEB_URL
        - name: previewText | type: string | description: Summary of message contents. Displayed in Inbox in the [Message List](https://support.wix.com/en/article/wix-inbox-an-overview).  | validation: maxLength 256
        - name: title | type: string | description: Message title.  
     - name: sender | type: IdentificationData | description: GUID of the message sender.  Defaults to the caller's GUID using the property that matches their identity type. For 3rd-party apps, defaults to using the app's `appId`.  You can override the default behavior when calling the Send Message method by using the `sendAs` parameter.  | read-only: true 
        - ONE-OF: 
           - name: anonymousVisitorId | type: string | description: Anonymous site visitor GUID.  | validation: format GUID
           - name: memberId | type: string | description: Member GUID. See the Members API for more information.  | validation: format GUID
           - name: wixUserId | type: string | description: GUID of the Wix user.  | validation: format GUID
           - name: appId | type: string | description: App GUID.  | validation: format GUID
        - name: contactId | type: string | description: Contact GUID. See the Contacts API for more information.  | read-only: true | validation: format GUID
     - name: badges | type: array<Badge> | description: Optional icon and short text providing additional details about the message, such as the app from which the message was sent, or whether the message was an automated response.  Currently only 1 badge is supported.  | validation: maxItems 1
        - name: text | type: string | description: Display text.  
        - name: iconUrl | type: string | description: URL where the icon is hosted.  | validation: format WEB_URL
        - name: badgeVisibility | type: BadgeVisibility | description: Controls whether the badge is visible to the participant. Currently not supported in the Chat widget.  
             - enum:
             -     UNKNOWN_BADGE_VISIBILITY: Unkown visibility.
             -     BUSINESS_AND_PARTICIPANT: Visible to the participant and site collaborators.
             -     BUSINESS: Visible to site collaborators only.
     - name: appId | type: string | description: GUID of the app that sent the message.  Omitted if the message was sent with the Chat widget.  | read-only: true | validation: format GUID
     - name: visibility | type: MessageVisibility | description: __Required.__ Controls who can see the message.  
         - enum:
         -     UNKNOWN_VISIBILITY: Unknown message visibility.
         -     BUSINESS_AND_PARTICIPANT: Visible to the participant and site collaborators.
         -     BUSINESS: Visible to site collaborators only.
     - name: sequence | type: string | description: Sequential ordering of the message.  Ensures more accurate sorting than `createdDate` if two messages are sent at the same time.  | read-only: true | validation: format int64
     - name: direction | type: MessageDirection | description: __Required.__ Message direction.  
         - enum:
         -     UNKNOWN_DIRECTION: Unknown message direction.
         -     BUSINESS_TO_PARTICIPANT: The message was sent from the business to the participant.
         -     PARTICIPANT_TO_BUSINESS: The message was sent from the participant to the business.
     - name: createdDate | type: string | description: Date and time the message was sent.  | validation: format date-time
     - name: targetChannelIds | type: array<string> | description: Target channel GUIDs to send the message to.  | validation: maxItems 100, maxLength 100
     - name: sourceChannelId | type: string | description: The channel GUID from which the message was sent.  | validation: maxLength 100
     - name: silent | type: boolean | description: Controls whether the unread count and conversation summary are updated in the [Message List](https://support.wix.com/en/article/wix-inbox-an-overview).  If `true`, unread count and conversation summary are not updated.  Default: `false`  
     - name: edited | type: boolean | description: Whether the message was edited on the channel it came from.  | read-only: true 
     - name: editedDate | type: string | description: Date and time the message was last edited on the channel it came from. Omitted if it was never edited.  | read-only: true | validation: format date-time

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_MEDIA_URL | Description: Invalid media URL.
   HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: IDENTITY_DOES_NOT_MATCH | Description: Identity doesn't match.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: INBOX_INSTANCE_NOT_FOUND | Description: Inbox instance not found.


```

### Examples

### Send Message Basic As Participant
```curl
curl -X POST \
'https://www.wixapis.com/inbox/v2/messages' \
-H 'Authorization: <AUTH>' \
-d '{
  "conversationId": "6202c3bb-f263-3c16-8c90-d6387d9ed420",
  "sendNotifications": true,
  "silent": false,
  "sendAs": "PARTICIPANT",
  "message": {
    "badges": [
      {
        "text": "Chat",
        "badgeVisibility": "BUSINESS",
        "iconUrl": "https://wixmp-9127dea18607b759d29e6784.wixmp.com/badges/chat2Small.png"
      }
    ],
    "targetChannels": [
      "CHAT"
    ],
    "content": {
      "previewText": "A Template message!",
      "basic": {
        "items": [
          {
            "text": "A text message"
          }
        ]
      }
    },
    "sourceChannel": "CHAT",
    "visibility": "BUSINESS_AND_PARTICIPANT",
    "direction": "PARTICIPANT_TO_BUSINESS"
  }
}'
```

### Send Message Template
```curl
curl -X POST \
'https://www.wixapis.com/inbox/v2/messages' \
-H 'Authorization: <AUTH>' \
-d '{
  "conversationId": "6202c3bb-f263-3c16-8c90-d6387d9ed420",
  "sendNotifications": true,
  "silent": false,
  "sendAs": "CALLER",
  "message": {
    "badges": [
      {
        "text": "Chat",
        "badgeVisibility": "BUSINESS",
        "iconUrl": "https://wixmp-9127dea18607b759d29e6784.wixmp.com/badges/chat2Small.png"
      }
    ],
    "targetChannels": [
      "CHAT"
    ],
    "content": {
      "previewText": "A Template message!",
      "template": {
        "buttons": [
          {
            "label": "click me",
            "postbackProperties": {
              "interactionId": "inter_id_1"
            }
          }
        ],
        "textLines": ["oh","cool"],
        "title": "A Template Message",
        "imageUrl": "https://static.wixstatic.com/media//0df0927d01d641338d1e0c59bbbabfde.jpg/v1/fill/w_315,h_315,q_80/0df0927d01d641338d1e0c59bbbabfde.jpg"
      }
    },
    "sourceChannel": "CHAT",
    "visibility": "BUSINESS_AND_PARTICIPANT",
    "direction": "BUSINESS_TO_PARTICIPANT"
  }
}'
```

### Send Message Basic
```curl
curl -X POST \
'https://www.wixapis.com/inbox/v2/messages' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "conversationId": "6202c3bb-f263-3c16-8c90-d6387d9ed420",
  "sendNotifications": true,
  "silent": false,
  "sendAs": "CALLER",
  "message": {
    "badges": [
      {
        "text": "Email",
        "badgeVisibility": "BUSINESS",
        "iconUrl": "https://wixmp-9127dea18607b759d29e6784.wixmp.com/badges/mailSmallFlat.png"
      }
    ],
    "targetChannels": [
      "EMAIL"
    ],
    "content": {
      "previewText": "Hey!",
      "basic": {
        "items": [
          {
            "text": "Hey!"
          }
        ]
      }
    },
    "sourceChannel": "CHAT",
    "visibility": "BUSINESS_AND_PARTICIPANT",
    "direction": "BUSINESS_TO_PARTICIPANT"
  }
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.inbox.messages.sendMessage(conversationId, message, options)
 Description: Sends a message to the business or participant.  Specify the message type in `message.content` by including the appropriate object: `basic`, `template`, `minimal`, or `form`. For more information on message types and how each type renders in Inbox and the Chat widget, see [Message Types](#message-types).
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  conversationId, message, message.content
 Method parameters: 
   param name: conversationId | type: string | description: GUID of the conversation to add the message to. | required: true | validation: format GUID
   param name: message | type: SendMessage   | required: true 
        - name: content | type: MessageContent | description: Structured message content. | required: true 
           - ONE-OF: 
              - name: basic | type: BasicMessagePayload | description: Plain text, file, or image message.  
                 - name: items | type: array<BasicMessageData> | description: List of plain text messages, images, and/or files. List items are displayed as separate messages in Inbox and the site's chat widget.  | validation: minItems 1
                    - ONE-OF: 
                       - name: text | type: string | description: Text message.  | validation: minLength 1, maxLength 16384
                       - name: image | type: ImageMessage | description: Image message. Can contain an image from Wix Media or from an external provider.  
                          - name: _id | type: string | description: Wix Media GUID.  | validation: maxLength 2000
                          - name: url | type: string | description: URL where the image is hosted. This URL is valid for 10 hours from the time the message is sent.  | validation: maxLength 2000
                          - name: filename | type: string | description: File name of the original file.  | validation: maxLength 255
                          - name: width | type: integer | description: Original image width, in pixels.  | validation: minimum 0
                          - name: height | type: integer | description: Original image height, in pixels.  | validation: minimum 0
                       - name: file | type: FileMessage | description: File attachment. Can contain a file from Wix Media or an external provider.  
                          - name: _id | type: string | description: Wix Media GUID.  | validation: maxLength 2000
                          - name: url | type: string | description: URL where the image is hosted. This URL is valid for 10 hours from the time the message is sent.  | validation: maxLength 2000
                          - name: filename | type: string | description: File name of the original file.  | validation: maxLength 255
                          - name: mimeType | type: string | description: File [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types).  | validation: maxLength 100
              - name: template | type: TemplateMessagePayload | description: Template containing an image, title, text, and/or up to 10 call-to-action buttons.  
                 - name: title | type: string | description: Title displayed in the message.  
                 - name: buttons | type: array<Button> | description: List of buttons to display with the message. Buttons can either open a URL or pass interaction details to the Button Interacted event.  Maximum: 10 buttons.  | validation: maxItems 10
                    - name: label | type: string | description: Button label text.  | validation: minLength 1, maxLength 16384
                    - name: launchUrl | type: string | description: If included, the button launches the specified URL.  | validation: maxLength 16384, format WEB_URL
                    - name: postbackProperties | type: PostbackProperties | description: Properties to pass to the Button Interacted event when the button is clicked.  
                       - name: interactionId | type: string | description: GUID you define for the interaction, to be handled by your server.  | validation: minLength 1, maxLength 256
                 - name: orientation | type: Orientation | description: Controls whether the message is displayed in portrait or landscape layout.  Default: `PORTRAIT`.  
                         - enum:
                         -     UNKNOWN_ORIENTATION: Unknown orientation.
                         -     PORTRAIT: Portrait layout.
                         -     LANDSCAPE: Landscape layout.
                 - name: textLines | type: array<string> | description: List of lines of text. Each item in the array is displayed on a new line.  Max: 10 lines (up to 512 characters per line).  | validation: maxItems 10
                 - name: imageUrl | type: string | description: URL where the icon is hosted.  | validation: maxLength 2000, format WEB_URL
              - name: minimal | type: MinimalMessagePayload | description: Minimal message containing a single line of text and an optional icon. Often reports an activity that took place.  
                 - name: text | type: string | description: Message text.  | validation: minLength 1, maxLength 16384
                 - name: iconUrl | type: string | description: URL where the icon is hosted.  | validation: maxLength 2000, format WEB_URL
                 - name: url | type: string | description: If included, URL the user is redirected to when clicking the message.  | validation: maxLength 2000, format WEB_URL
              - name: form | type: FormMessagePayload | description: Message containing submitted form data. Typically sent with a `direction` of `PARTICIPANT_TO_BUSINESS` and message `visibility` of `BUSINESS`.  
                 - name: title | type: string | description: Form title displayed in the message.  | validation: minLength 1, maxLength 256
                 - name: description | type: string | description: Form description displayed below the title.  | validation: minLength 1, maxLength 16384
                 - name: fields | type: array<FormField> | description: List of form fields and values.  | validation: minItems 1, maxItems 30
                    - name: name | type: string | description: Form field display name.  | validation: maxLength 8192
                    - name: value | type: string | description: Submitted value.  | validation: maxLength 8192
                 - name: media | type: array<MediaItem> | description: List of files and/or images attached to the form.  List items are displayed as separate messages in Inbox and the site's chat widget.  | validation: maxItems 15
                    - ONE-OF: 
                       - name: image | type: ImageMessage | description: Image message. Can contain an image from Wix Media or from an external provider.  
                       - name: file | type: FileMessage | description: File attachment. Can contain a file from Wix Media or an external provider.  
              - name: system | type: SystemMessagePayload | description: System message. For internal use.  
                 - name: text | type: string | description: Text message. `\n` renders as a line break.  | validation: maxLength 16384
                 - name: buttons | type: array<Button> | description: List of buttons to display with the message. Buttons can either open a URL or pass interaction details to the Button Interacted event.  Maximum: 10 buttons.  | validation: maxItems 10
                 - name: imageUrl | type: string | description: URL where the icon is hosted.  | validation: maxLength 2000, format WEB_URL
           - name: previewText | type: string | description: Summary of message contents. Displayed in Inbox in the [Message List](https://support.wix.com/en/article/wix-inbox-an-overview).  | validation: maxLength 256
           - name: title | type: string | description: Message title.  
        - name: badges | type: array<Badge> | description: Optional icon and short text providing additional details about the message, such as the app from which the message was sent, or whether the message was an automated response.  Currently only 1 badge is supported.  | validation: maxItems 1
           - name: text | type: string | description: Display text.  
           - name: iconUrl | type: string | description: URL where the icon is hosted.  | validation: format WEB_URL
           - name: badgeVisibility | type: BadgeVisibility | description: Controls whether the badge is visible to the participant. Currently not supported in the Chat widget.  
                 - enum:
                 -     UNKNOWN_BADGE_VISIBILITY: Unkown visibility.
                 -     BUSINESS_AND_PARTICIPANT: Visible to the participant and site collaborators.
                 -     BUSINESS: Visible to site collaborators only.
        - name: visibility | type: MessageVisibility | description: __Required.__ Controls who can see the message.  
             - enum:
             -     UNKNOWN_VISIBILITY: Unknown message visibility.
             -     BUSINESS_AND_PARTICIPANT: Visible to the participant and site collaborators.
             -     BUSINESS: Visible to site collaborators only.
        - name: direction | type: MessageDirection | description: __Required.__ Message direction.  
             - enum:
             -     UNKNOWN_DIRECTION: Unknown message direction.
             -     BUSINESS_TO_PARTICIPANT: The message was sent from the business to the participant.
             -     PARTICIPANT_TO_BUSINESS: The message was sent from the participant to the business.
        - name: _createdDate | type: Date | description: Date and time the message was sent.  
        - name: targetChannelIds | type: array<string> | description: Target channel GUIDs to send the message to.  | validation: maxItems 100, maxLength 100
        - name: sourceChannelId | type: string | description: The channel GUID from which the message was sent.  | validation: maxLength 100
        - name: silent | type: boolean | description: Controls whether the unread count and conversation summary are updated in the [Message List](https://support.wix.com/en/article/wix-inbox-an-overview).  If `true`, unread count and conversation summary are not updated.  Default: `false`  
   param name: options | type: SendMessageOptions  none  
        - name: sendNotifications | type: boolean | description: Controls whether the message triggers notifications when it's received.  Default: `false`  
        - name: sendAs | type: OverrideSenderOptions | description: Controls which identity to use in the message's `sender` property. Default: `CALLER` For 3rd-party apps, the app is the caller.  
             - enum:
             -     CALLER: Uses the identity included in the request header.
             -     PARTICIPANT: Uses the `anonymousVisitorId`, `contactId`, or `memberId` of the conversation's participant.
             -     BUSINESS_USER: For internal use. Uses the `wixUserId` of the person sending messages on behalf of the business.
 Return type: PROMISE<SendMessageResponse>
  - name: message | type: Message | description: Sent message.  
     - name: _id | type: string | description: Message GUID.  | read-only: true 
     - name: content | type: MessageContent | description: Structured message content.  
        - ONE-OF: 
           - name: basic | type: BasicMessagePayload | description: Plain text, file, or image message.  
              - name: items | type: array<BasicMessageData> | description: List of plain text messages, images, and/or files. List items are displayed as separate messages in Inbox and the site's chat widget.  | validation: minItems 1
                 - ONE-OF: 
                    - name: text | type: string | description: Text message.  | validation: minLength 1, maxLength 16384
                    - name: image | type: ImageMessage | description: Image message. Can contain an image from Wix Media or from an external provider.  
                       - name: _id | type: string | description: Wix Media GUID.  | validation: maxLength 2000
                       - name: url | type: string | description: URL where the image is hosted. This URL is valid for 10 hours from the time the message is sent.  | validation: maxLength 2000
                       - name: filename | type: string | description: File name of the original file.  | validation: maxLength 255
                       - name: width | type: integer | description: Original image width, in pixels.  | validation: minimum 0
                       - name: height | type: integer | description: Original image height, in pixels.  | validation: minimum 0
                       - name: urlExpiration | type: Date | description: Expiration date and time of the URL in `YYYY-MM-DDThh:mm:ss.sssZ` format.  | read-only: true 
                    - name: file | type: FileMessage | description: File attachment. Can contain a file from Wix Media or an external provider.  
                       - name: _id | type: string | description: Wix Media GUID.  | validation: maxLength 2000
                       - name: url | type: string | description: URL where the image is hosted. This URL is valid for 10 hours from the time the message is sent.  | validation: maxLength 2000
                       - name: filename | type: string | description: File name of the original file.  | validation: maxLength 255
                       - name: mimeType | type: string | description: File [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types).  | validation: maxLength 100
                       - name: urlExpiration | type: Date | description: Expiration date and time of the URL in `YYYY-MM-DDThh:mm:ss.sssZ` format.  | read-only: true 
           - name: template | type: TemplateMessagePayload | description: Template containing an image, title, text, and/or up to 10 call-to-action buttons.  
              - name: title | type: string | description: Title displayed in the message.  
              - name: buttons | type: array<Button> | description: List of buttons to display with the message. Buttons can either open a URL or pass interaction details to the Button Interacted event.  Maximum: 10 buttons.  | validation: maxItems 10
                 - name: label | type: string | description: Button label text.  | validation: minLength 1, maxLength 16384
                 - name: launchUrl | type: string | description: If included, the button launches the specified URL.  | validation: maxLength 16384, format WEB_URL
                 - name: postbackProperties | type: PostbackProperties | description: Properties to pass to the Button Interacted event when the button is clicked.  
                    - name: appId | type: string | description: App GUID.  | read-only: true | validation: format GUID
                    - name: interactionId | type: string | description: GUID you define for the interaction, to be handled by your server.  | validation: minLength 1, maxLength 256
              - name: orientation | type: Orientation | description: Controls whether the message is displayed in portrait or landscape layout.  Default: `PORTRAIT`.  
                     - enum:
                     -     UNKNOWN_ORIENTATION: Unknown orientation.
                     -     PORTRAIT: Portrait layout.
                     -     LANDSCAPE: Landscape layout.
              - name: textLines | type: array<string> | description: List of lines of text. Each item in the array is displayed on a new line.  Max: 10 lines (up to 512 characters per line).  | validation: maxItems 10
              - name: imageUrl | type: string | description: URL where the icon is hosted.  | validation: maxLength 2000, format WEB_URL
           - name: minimal | type: MinimalMessagePayload | description: Minimal message containing a single line of text and an optional icon. Often reports an activity that took place.  
              - name: text | type: string | description: Message text.  | validation: minLength 1, maxLength 16384
              - name: iconUrl | type: string | description: URL where the icon is hosted.  | validation: maxLength 2000, format WEB_URL
              - name: url | type: string | description: If included, URL the user is redirected to when clicking the message.  | validation: maxLength 2000, format WEB_URL
           - name: form | type: FormMessagePayload | description: Message containing submitted form data. Typically sent with a `direction` of `PARTICIPANT_TO_BUSINESS` and message `visibility` of `BUSINESS`.  
              - name: title | type: string | description: Form title displayed in the message.  | validation: minLength 1, maxLength 256
              - name: description | type: string | description: Form description displayed below the title.  | validation: minLength 1, maxLength 16384
              - name: fields | type: array<FormField> | description: List of form fields and values.  | validation: minItems 1, maxItems 30
                 - name: name | type: string | description: Form field display name.  | validation: maxLength 8192
                 - name: value | type: string | description: Submitted value.  | validation: maxLength 8192
              - name: media | type: array<MediaItem> | description: List of files and/or images attached to the form.  List items are displayed as separate messages in Inbox and the site's chat widget.  | validation: maxItems 15
                 - ONE-OF: 
                    - name: image | type: ImageMessage | description: Image message. Can contain an image from Wix Media or from an external provider.  
                    - name: file | type: FileMessage | description: File attachment. Can contain a file from Wix Media or an external provider.  
           - name: system | type: SystemMessagePayload | description: System message. For internal use.  
              - name: text | type: string | description: Text message. `\n` renders as a line break.  | validation: maxLength 16384
              - name: buttons | type: array<Button> | description: List of buttons to display with the message. Buttons can either open a URL or pass interaction details to the Button Interacted event.  Maximum: 10 buttons.  | validation: maxItems 10
              - name: imageUrl | type: string | description: URL where the icon is hosted.  | validation: maxLength 2000, format WEB_URL
        - name: previewText | type: string | description: Summary of message contents. Displayed in Inbox in the [Message List](https://support.wix.com/en/article/wix-inbox-an-overview).  | validation: maxLength 256
        - name: title | type: string | description: Message title.  
     - name: sender | type: IdentificationData | description: GUID of the message sender.  Defaults to the caller's GUID using the property that matches their identity type. For 3rd-party apps, defaults to using the app's `appId`.  You can override the default behavior when calling the Send Message method by using the `sendAs` parameter.  | read-only: true 
        - ONE-OF: 
           - name: anonymousVisitorId | type: string | description: Anonymous site visitor GUID.  | validation: format GUID
           - name: memberId | type: string | description: Member GUID. See the Members API for more information.  | validation: format GUID
           - name: wixUserId | type: string | description: GUID of the Wix user.  | validation: format GUID
           - name: appId | type: string | description: App GUID.  | validation: format GUID
        - name: contactId | type: string | description: Contact GUID. See the Contacts API for more information.  | read-only: true | validation: format GUID
     - name: badges | type: array<Badge> | description: Optional icon and short text providing additional details about the message, such as the app from which the message was sent, or whether the message was an automated response.  Currently only 1 badge is supported.  | validation: maxItems 1
        - name: text | type: string | description: Display text.  
        - name: iconUrl | type: string | description: URL where the icon is hosted.  | validation: format WEB_URL
        - name: badgeVisibility | type: BadgeVisibility | description: Controls whether the badge is visible to the participant. Currently not supported in the Chat widget.  
             - enum:
             -     UNKNOWN_BADGE_VISIBILITY: Unkown visibility.
             -     BUSINESS_AND_PARTICIPANT: Visible to the participant and site collaborators.
             -     BUSINESS: Visible to site collaborators only.
     - name: appId | type: string | description: GUID of the app that sent the message.  Omitted if the message was sent with the Chat widget.  | read-only: true | validation: format GUID
     - name: visibility | type: MessageVisibility | description: __Required.__ Controls who can see the message.  
         - enum:
         -     UNKNOWN_VISIBILITY: Unknown message visibility.
         -     BUSINESS_AND_PARTICIPANT: Visible to the participant and site collaborators.
         -     BUSINESS: Visible to site collaborators only.
     - name: sequence | type: string | description: Sequential ordering of the message.  Ensures more accurate sorting than `createdDate` if two messages are sent at the same time.  | read-only: true | validation: format int64
     - name: direction | type: MessageDirection | description: __Required.__ Message direction.  
         - enum:
         -     UNKNOWN_DIRECTION: Unknown message direction.
         -     BUSINESS_TO_PARTICIPANT: The message was sent from the business to the participant.
         -     PARTICIPANT_TO_BUSINESS: The message was sent from the participant to the business.
     - name: _createdDate | type: Date | description: Date and time the message was sent.  
     - name: targetChannelIds | type: array<string> | description: Target channel GUIDs to send the message to.  | validation: maxItems 100, maxLength 100
     - name: sourceChannelId | type: string | description: The channel GUID from which the message was sent.  | validation: maxLength 100
     - name: silent | type: boolean | description: Controls whether the unread count and conversation summary are updated in the [Message List](https://support.wix.com/en/article/wix-inbox-an-overview).  If `true`, unread count and conversation summary are not updated.  Default: `false`  
     - name: edited | type: boolean | description: Whether the message was edited on the channel it came from.  | read-only: true 
     - name: editedDate | type: Date | description: Date and time the message was last edited on the channel it came from. Omitted if it was never edited.  | read-only: true 

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_MEDIA_URL | Description: Invalid media URL.
   HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: IDENTITY_DOES_NOT_MATCH | Description: Identity doesn't match.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: INBOX_INSTANCE_NOT_FOUND | Description: Inbox instance not found.


```

### Examples

### Send a template message
```javascript
import { messages } from '@wix/inbox';

/* Sample conversationId value: '74aa9ee1-8e36-3028-b441-57dacfbd841e'
 * 
 * Sample message value: 
 * {
 *     direction: 'BUSINESS_TO_PARTICIPANT',
 *     visibility: 'BUSINESS_AND_PARTICIPANT',
 *     content: {
 *       previewText: "JoJo, you're getting a spa day!",
 *       template: {
 *         title: "JoJo, you're getting a spa day!",
 *         imageUrl: 'https://static.wixstatic.com/media/f93e3d633e79921f14330f1911fc1139.jpg/v1/fill/w_1200,h_798,al_c,q_85,usm_0.66_1.00_0.01/f93e3d633e79921f14330f1911fc1139.webp',
 *         textLines: [
 *           "Thanks for booking with us!",
 *           "You're booked for a massage, mud bath, and facial on May 9, 2021."
 *         ],
 *         buttons: [{
 *           label: 'View My Invoice',
 *           launchUrl: 'https://static.wixstatic.com/media/f93e3d633e79921f14330f1911fc1139.jpg/v1/fill/w_1200,h_798,al_c,q_85,usm_0.66_1.00_0.01/f93e3d633e79921f14330f1911fc1139.webp'
 *         },
 *         {
 *           label: 'Change My Appointment',
 *         postbackProperties: {
 *           interactionId: 'spa_day_54321__change_appointment'
 *           }
 *         }
 *         ]
 *       }
 *     },
 *     sourceChannel: "CHAT",
 *     targetChannels: ['CHAT']
 *   }
 */

export async function mySendMessageFunction(conversationId, message) {
  try {
    const templateMessage = await messages.sendMessage(conversationId, message);

    return templateMessage;
  } catch (error) {
    console.log(error);
    //Handle the error
  }
}

/* Promise resolves to:
 * {
 *   "_createdDate": "2023-11-29T10:40:52.822Z",
 *     "_id": "1701254452822623",
 *     "appId": "151e476a-715e-ec33-db9a-a7ff4d51f70a",
 *     "badges": [],
 *      "message": {
 *        "content": {
 *          "previewText": "JoJo, you're getting a spa day!",
 *          "template": {
 *            "buttons": 
 *            [
 *              {
 *                "label": "View My Invoice",
 *                "launchUrl": "https://static.wixstatic.com/media/f93e3d633e79921f14330f1911fc1139.jpg/v1/fill/w_1200,h_798,al_c,q_85,usm_0.6 6_1.00_0.01/f93e3d633e79921f14330f1911fc1139.webp"
 *              },
 *              {
 *                "label": "Change My Appointment",
 *                "postbackProperties": 
 *                {
 *                  "appId": "151e476a-715e-ec33-db9a-a7ff4d51f70a",
 *                  "interactionId": "spa_day_54321__change_appointment"
 *                }
 *              }
 *            ],
 *          "imageUrl": "https://static.wixstatic.com/media/f93e3d633e79921f14330f1911fc1139.jpg/v1/fill/w_1200,h_798,al_c,q_85,usm_0.66_1.0 0_0.01/f93e3d633e79921f14330f1911fc1139.webp"
 *          "orientation": "PORTRAIT",
 *          "textLines": 
 *          [
 *            "Thanks for booking with us!",
 *            "You're booked for a massage, mud bath, and facial on May 9, 2021."
 *          ],
 *          "title": "JoJo, you're getting a spa day!"
 *       },
 *     },
 *     "direction": "BUSINESS_TO_PARTICIPANT",
 *       "sender": {
 *       "appId": "151e476a-715e-ec33-db9a-a7ff4d51f70a"
 *     },
 *     "sequence": "1701254452822623",
 *     "sourceChannel": "CHAT",
 *     "targetChannels": [],
 *      "visibility": "BUSINESS_AND_PARTICIPANT",
 *     }
 * }
 */
```

### Send a basic message (with elevated permissions)
```javascript
import { messages } from '@wix/inbox';
import { auth } from '@wix/essentials';

const elevatedSendMessage = auth.elevate(messages.sendMessage);

/* Sample conversationId value: 'e56ed8f7-4bbf-3d99-b2f9-962e555264c3'
 *
 * Sample messsage value:
 * {
 *     content: {
 *       previewText: "Welcome",
 *       basic: {
 *         items: [
 *           {
 *             text: "Welcome to Amy's Shoes!"
 *           }
 *         ]
 *       }
 *     },
 *     visibility: 'BUSINESS_AND_PARTICIPANT',
 *     direction: 'BUSINESS_TO_PARTICIPANT',
 *     sourceChannel: 'CHAT',
 *     targetChannels: ['CHAT']
 * }
 */

export async function mySendMessageFunction(conversationId, message) {
  try {
    const basicMessage = await elevatedSendMessage(conversationId, message);
    const messageId = basicMessage.message._id;
    const sender = basicMessage.message.sender;
    const visibility = basicMessage.message.visibility;

    return basicMessage;
  } catch (error) {
    console.error(error);
    //Handle the error
  }

}

/* Promise resolves to:
 * {
 *   "_createdDate": "2023-11-27T16:51:58.040Z"
 *   "_id": "1701103918040190",
 *   "appId": "151e476a-715e-ec33-db9a-a7ff4d51f70a",
 *   "badges": [],
 *   "content": {
 *     "previewText": "Welcome",
 *     "contentType": "BASIC"
 *     "basic": {
 *       "items": [
 *         {
 *           "text": "Welcome to Amy's Shoes!"
 *         }
 *       ]
 *     },
 *   },
 *   "direction": "BUSINESS_TO_PARTICIPANT",
 *   "sender": {
 *     "appId": "151e476a-715e-ec33-db9a-a7ff4d51f70a"
 *   },
 *   "sequence": "1701103918040190",
 *   "sourceChannel": "CHAT",
 *   "targetChannels": [
 *     "CHAT"
 *   ],
 *   "visibility": "BUSINESS_AND_PARTICIPANT",
 * }
 */
```

### Send a basic message
```javascript
import { messages } from '@wix/inbox';

/* Sample conversationId value: 'e56ed8f7-4bbf-3d99-b2f9-962e555264c3'
 *
 * Sample messsage value:
 * {
 *     content: {
 *       previewText: "Welcome",
 *       basic: {
 *         items: [
 *           {
 *             text: "Welcome to Amy's Shoes!"
 *           }
 *         ]
 *       }
 *     },
 *     visibility: 'BUSINESS_AND_PARTICIPANT',
 *     direction: 'BUSINESS_TO_PARTICIPANT',
 *     sourceChannel: 'CHAT',
 *     targetChannels: ['CHAT']
 * }
 */

export async function mySendMessageFunction(conversationId, message) {
  try {
    const basicMessage = await messages.sendMessage(conversationId, message);
    const messageId = basicMessage.message._id;
    const sender = basicMessage.message.sender;
    const visibility = basicMessage.message.visibility;

    return basicMessage;
  } catch (error) {
    console.error(error);
    //Handle the error
  }

}

/* Promise resolves to:
 * {
 *   "_createdDate": "2023-11-27T16:51:58.040Z"
 *   "_id": "1701103918040190",
 *   "appId": "151e476a-715e-ec33-db9a-a7ff4d51f70a",
 *   "badges": [],
 *   "content": {
 *     "previewText": "Welcome",
 *     "contentType": "BASIC"
 *     "basic": {
 *       "items": [
 *         {
 *           "text": "Welcome to Amy's Shoes!"
 *         }
 *       ]
 *     },
 *   },
 *   "direction": "BUSINESS_TO_PARTICIPANT",
 *   "sender": {
 *     "appId": "151e476a-715e-ec33-db9a-a7ff4d51f70a"
 *   },
 *   "sequence": "1701103918040190",
 *   "sourceChannel": "CHAT",
 *   "targetChannels": [
 *     "CHAT"
 *   ],
 *   "visibility": "BUSINESS_AND_PARTICIPANT",
 * }
 */
```

### Send a template message (with elevated permissions)
```javascript
import { messages } from '@wix/inbox';
import { auth } from '@wix/essentials';

/* Sample conversationId value: '74aa9ee1-8e36-3028-b441-57dacfbd841e'
 * 
 * Sample message value: 
 * {
 *     direction: 'BUSINESS_TO_PARTICIPANT',
 *     visibility: 'BUSINESS_AND_PARTICIPANT',
 *     content: {
 *       previewText: "JoJo, you're getting a spa day!",
 *       template: {
 *         title: "JoJo, you're getting a spa day!",
 *         imageUrl: 'https://static.wixstatic.com/media/f93e3d633e79921f14330f1911fc1139.jpg/v1/fill/w_1200,h_798,al_c,q_85,usm_0.66_1.00_0.01/f93e3d633e79921f14330f1911fc1139.webp',
 *         textLines: [
 *           "Thanks for booking with us!",
 *           "You're booked for a massage, mud bath, and facial on May 9, 2021."
 *         ],
 *         buttons: [{
 *           label: 'View My Invoice',
 *           launchUrl: 'https://static.wixstatic.com/media/f93e3d633e79921f14330f1911fc1139.jpg/v1/fill/w_1200,h_798,al_c,q_85,usm_0.66_1.00_0.01/f93e3d633e79921f14330f1911fc1139.webp'
 *         },
 *         {
 *           label: 'Change My Appointment',
 *         postbackProperties: {
 *           interactionId: 'spa_day_54321__change_appointment'
 *           }
 *         }
 *         ]
 *       }
 *     },
 *     sourceChannel: "CHAT",
 *     targetChannels: ['CHAT']
 *   }
 */

export async function mySendMessageFunction(conversationId, message) {
  const elevatedSendMessage = auth.elevate(messages.sendMessage);

  try {
    const templateMessage = await elevatedSendMessage(conversationId, message);

    return templateMessage;
  } catch (error) {
    console.log(error);
    //Handle the error
  }
}

/* Promise resolves to:
 * {
 *   "_createdDate": "2023-11-29T10:40:52.822Z",
 *     "_id": "1701254452822623",
 *     "appId": "151e476a-715e-ec33-db9a-a7ff4d51f70a",
 *     "badges": [],
 *      "message": {
 *        "content": {
 *          "previewText": "JoJo, you're getting a spa day!",
 *          "template": {
 *            "buttons": 
 *            [
 *              {
 *                "label": "View My Invoice",
 *                "launchUrl": "https://static.wixstatic.com/media/f93e3d633e79921f14330f1911fc1139.jpg/v1/fill/w_1200,h_798,al_c,q_85,usm_0.6 6_1.00_0.01/f93e3d633e79921f14330f1911fc1139.webp"
 *              },
 *              {
 *                "label": "Change My Appointment",
 *                "postbackProperties": 
 *                {
 *                  "appId": "151e476a-715e-ec33-db9a-a7ff4d51f70a",
 *                  "interactionId": "spa_day_54321__change_appointment"
 *                }
 *              }
 *            ],
 *          "imageUrl": "https://static.wixstatic.com/media/f93e3d633e79921f14330f1911fc1139.jpg/v1/fill/w_1200,h_798,al_c,q_85,usm_0.66_1.0 0_0.01/f93e3d633e79921f14330f1911fc1139.webp"
 *          "orientation": "PORTRAIT",
 *          "textLines": 
 *          [
 *            "Thanks for booking with us!",
 *            "You're booked for a massage, mud bath, and facial on May 9, 2021."
 *          ],
 *          "title": "JoJo, you're getting a spa day!"
 *       },
 *     },
 *     "direction": "BUSINESS_TO_PARTICIPANT",
 *       "sender": {
 *       "appId": "151e476a-715e-ec33-db9a-a7ff4d51f70a"
 *     },
 *     "sequence": "1701254452822623",
 *     "sourceChannel": "CHAT",
 *     "targetChannels": [],
 *      "visibility": "BUSINESS_AND_PARTICIPANT",
 *     }
 * }
 */
```

### sendMessage (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { messages } from '@wix/inbox';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { messages },
  // Include the auth strategy and host as relevant
});


async function sendMessage(conversationId,message,options) {
  const response = await myWixClient.messages.sendMessage(conversationId,message,options);
};
```

---