--- title: "system.perspective.sendMessage" description: "Send a message to a message handler within the same session." --- # system.perspective.sendMessage > Send a message to a message handler within the same session. This function is used in **Python Scripting**. ## Description Send a message to a [component message handler](../../../ignition-modules/perspective/scripting-in-perspective/component-message-handlers.md) within the same session. This function cannot interact with Session Message Handlers configured in Session Events, even if the `scope` of session is specified. :::note Message Handlers Execution Invoked Message Handlers [execute asynchronously](../../../ignition-modules/perspective/scripting-in-perspective/component-message-handlers.md#messages-execute-asynchronously) to the calling script. ::: ### The Scope Parameter It is important to be mindful of the `scope` parameter when calling this function. The `scope` argument corresponds to the listening scope of the component message handlers on any Perspective component. It is possible to have multiple instances of a view open in a single page, thus invoking the function with a value of page for the `scope` parameter (or omitting the parameter) will invoke the message handlers on all valid message types. This advice is also applicable when the `scope` parameter value is passed as session, as all instances of the matching message type in the whole session will be called. ## Syntax `system.perspective.sendMessage(messageType, payload, [scope], [sessionId], [pageId])` ### Parameters Type | Parameter | Description ------- | ------- | ------ String | `messageType` | The message type that will be invoked. Message handlers configured within the project are listening for messages of a specific messageType. Dictionary[String, String] | `payload` | A Python dictionary representing any parameters that will be passed to the message handler. String | `scope` | The scope that the message should be delivered to. Valid values are "session", "page", or "view". If omitted, "page" will be used. [optional] String | `sessionId` | Identifier of the Session to target. If omitted, the current Session will be used automatically. When targeting a different session, then the pageId parameter must be included in the call. [optional] String | `pageId` | Identifier of the page to target. If omitted, the current page will be used. [optional] ### Returns Nothing ### Scope Gateway, Perspective Session :::note This function will only work in the Gateway scope if both `sessionId` and `pageId` are supplied to the call. ::: ## Code Examples ```python title="Code Snippet" # Sends a message to all Message Handlers configured on the current view, indicating that a new item has been added to a list. system.perspective.sendMessage("NewItem", payload = {"itemName":"banana","itemQuantity":6}, scope = "view") ```