---
schema_version: "1"
id: 9098e8f4c5318c7f62e9f4d2c8e2290739b214d8cdc33d9e35d1e5750b176e21
title: WebSockets Messaging Operations
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/websockets-connector/latest/websockets-connector-messaging-operations.md
canonical_url: https://docs.mulesoft.com/websockets-connector/latest/websockets-connector-messaging-operations
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 70f8a6883e0853309bd00872174435bfa38bd3fec4be9185b911f5cb7779511c
description: MuleSoft Documentation Site
release: "1.0"
latest: true
---
---
product: WebSockets Connector
version: 1.0
is-latest-version: true
---

# WebSockets Messaging Operations

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## Send Operation

The Send operation allows you to send a message through a WebSocket identified by its socket ID
after a connection is established. This operation can be used for both inbound and outbound
WebSocket instances.

```xml
    <flow name="sayHello">
      <websocket:open-outbound-socket
        path="/chat/hello"
        config-ref="ws"
        target="socketId"
        targetValue="#[attributes.socketId]"/>
      <websocket:send socketId="#[vars.socketId]" config-ref="ws">
        <websocket:content>'Good morning!'</websocket:content>
      </websocket:send>
    </flow>

    <flow name="sayHelloBack">
        <websocket:inbound-listener
            path="/chat/hello"
            config-ref="ws"
            outputMimeType="text/plain" />
        <websocket:send socketId="#[attributes.socketId]" config-ref="ws">
            <websocket:content>#['Good morning ' ++ attributes.socketId ++ '!']</websocket:content>
        </websocket:send>
    </flow>
```

## Broadcast Operation

The Broadcast operation sends a message to a group of sockets. To select the group of sockets to
which the message can be broadcast:

- Subscribe to specific groups

- Connect to a specific path

- Be of a specific type (INBOUND or OUTBOUND)

The type and group parameters work in tandem, in an additive way. They are both optional and can be
used separately, but when used together they act as two levels of filtering:

```xml
<!-- Send to all INBOUND sockets connected to the /quotes endpoint, in the MARVEL and DC groups -->
<websocket:broadcast
    doc:name="Broadcast"
    socketType="INBOUND"
    config-ref="WebSockets_Config"
    path="/quotes">
    <websocket:groups >
        <websocket:group value=" #[['MARVEL', 'DC']]" />
    </websocket:groups>
</websocket:broadcast>
```

### Output

The output of the Broadcast operation is void.

## See Also

- [Salesforce Help](https://help.salesforce.com)

- [WebSockets Connector Overview](https://docs.mulesoft.com/websockets-connector/latest/)

- [Manage Groups](https://docs.mulesoft.com/websockets-connector/latest/websockets-connector-managing-groups)

- [Connector Configuration](https://docs.mulesoft.com/websockets-connector/latest/websockets-connector-config-topics)
