# showMessage

### Parameters

1. messageOptions- This is a json object with the message parameters:
   * content - this is the message Text
   * title - (optional) id of the record to load in the new app
   * timeout - (optional) a timeout in milliseconds. The message will disappear after this timeout. No timeout by default.
   * "mode" - (optional) will start in a modal overlay window (default),
     * "big" - (default) a small box in the lowerright corner of the page
     * "small" - a small box in the upper right corner of the page
   * icon - (optional) a icon class string (default: "fa fa-bell swing animated")
   * sound - (optional) play a sound (true) or no (false = default)
   * type - (optional) PReset color scheme. You can use all the button types (danger, success, warning...)
   * buttons - (optional, only for mode "big") You can add buttons to the message. Just provide a list with each button in square brackets (e.g. "\[Yes]\[No]\[Cancel]"). For more details please check the examples.
   * callback - (optional, only for mode "big") If u provide more than one button the callback option is needed to distinguish which action needs to be taken for a button. For more details please check the examples.

### Example Usages

Most simple message

```javascript
   brixxApi.showMessage({content: "Message Text" });
```

using additional options

```javascript
   brixxApi.showMessage({
            title: "My Title",
            content: "My Text",
            type: "danger",
            sound: true,
            timeout: 2000,
            icon: "fa fa-bell swing animated"
           });
```

message with buttons

```javascript
   //If u provide more then one button the callback option is needed to distinguish wich action needs to be taken for a button.

   function msgCallBack (reasonForCallBack){
      // possible values for reason:
      // "click" : the message was closed with the X-button
      // "timeout" : the timeout elapsed
      // "btn1", "btn2", ...  : each button gets an id number (starting from 1). e.g. if the second button was pressed -> "btn2"

      console.log("reasonForCallBack:" + reasonForCallBack);
   }

   brixxApi.showMessage({
            title: "My Title",
            content: "My Text",
            type: "info",
            sound: true,
            icon: "fa fa-bell swing animated",
			buttons: "[Yes][No][Cancel]",
			callback: msgCallBack,
           });
```

message with buttons, timeout and changing the layout of the message after it was created

```javascript
   function msgCallBack (reasonForCallBack){
      console.log("reasonForCallBack:" + reasonForCallBack);
   }

   let msgId = brixxApi.showMessage({
            title: "My Title",
            content: "My Text",
            type: "info",
            sound: true,
            timeout: 20000,
            icon: "fa fa-bell swing animated",
            //when using the timeout option the running timer value can be shown on one button. This 
            //will visualize the default action taken after the timeout elapsed. Just add "{timer}" to a button text.
            buttons: "[ <i class='fas fa-check'></i>  Yes {timer}][ <i class='fas fa-do-not-enter'></i>  No]",
            callback: msgCallBack,
           });

    //each message will get an unique id number. This can be used to add/change the message layout further.
    document.getElementById('bigBoxBtn1-Msg' + msgId).classList.add("btn-success");		
    document.getElementById('bigBoxBtn2-Msg' + msgId).classList.add("btn-danger");
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://brixxbox.gitbook.io/brixxbox-documentation/client-api-reference/functions/showmessage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
