---
schema_version: "1"
id: d4173fa4a06560e9a8f93a6aeb565826b89e8e457361fb3cd9856fa68c066b89
title: Send a Message as the End User
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/service-cloud/messaging-web/guides/send-message-lwc.md
canonical_url: https://developer.salesforce.com/docs/service/messaging-web/guide/send-message-lwc.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0cd117fdf877f6a494f351bb41c562ee6272a1e4111063cc6eb7193e9f316187
products:
  - Enhanced Web Chat
  - Service Cloud Developer Content
---
# Send a Message as the End User

Send a text message, like search queries, user actions, or any text, as the end user from a custom component using the [Send Message API](https://developer.salesforce.com/docs/service/messaging-web/guide/send-message.md).

The following example illustrates how you can send a text message when a menu option is clicked from a custom chat header.

```javascript
import { LightningElement, api, track } from "lwc";

export default class CustomChatHeader extends LightningElement {

	...

	sendTextMessage() {
		this.configuration.util.sendTextMessage("Text");
		.then(() => {
			// Success handler used to perform actions when the message is sent successfully.
			// For example, create a method that logs the message was successfull.
			logMessageSuccessfullySent();
		}).catch(() => {
			// Error handler used to perform actions if the message fails to send.
			// For example, log the failure.
			logMessageFailed();
		}).finally(() => {
			// Finally handler used to perform any clean-up actions
			// regardless of whether the message was successfully sent or not.
			// For example, create a method that logs attempt to send message.
			logMessageAttempt();
		});
	}
}
```

```html
<template>
    ...

    <!-- Header menu -->
    <section class={menuClass}>
        <template if:true={showMenuButton}>
            <!-- Menu button -->
            <button class="headerButton menuButton" onclick={onMenuButtonClick}>
                <lightning-icon icon-name="utility:threedots_vertical" variant="inverse" size="x-small"></lightning-icon>
            </button>
        </template>

        <!-- Menu options-->
        <section class="optionsMenu slds-dropdown slds-dropdown_left slds-nubbin_top-left">
            <ul class="slds-dropdown__list">
                ...

                <!-- Send text message -->
                <li class="slds-dropdown__item">
                    <button class="chatbotMenuOption"
                            onclick={sendTextMessage}>
                        <span class="slds-text-color_error">Send text</span>
                    </button>
                </li>

            ...
            </ul>
        </section>
    </section>
   ...
</template>
```

See the [Customize Header](https://developer.salesforce.com/docs/service/messaging-web/guide/customize-header.md) page to know more about custom chat headers.
