# On Discord Private Message

`On Discord Private Message` blocks are event blocks that fire whenever a specified Discord account or Discord bot receives a private Discord message.

`On Discord Private Message` blocks only have one input: a Discord connection that must be provided by a [`Discord Connector`](/dev-tooling/blocks-messaging/discord/discord-connector.md) block. The Discord account or bot token that is provided to the `Discord Connector` we use will determine which account or bot our `On Discord Private Message` block will be listening to private messages for.

`On Discord Private Message` blocks output several pieces of data:

-A string called "From" which will be equal to the Discord username of the message sender.\
-A string called "Message" which will be equal to the contents of the private message.\
-An integer called "MessageId" which is an identifier for the message we have received. This can be used as input for any block type that requires a reference to a message, like [`On Reaction Added Message`](/dev-tooling/blocks-messaging/discord/on-reaction-added-message.md) blocks.\
-A variable called "Author", which is a reference to the Discord account that sent the private message. This is used specifically to plug into the "Author" input of [`Reply Private Discord Message`](/dev-tooling/blocks-messaging/discord/reply-private-discord-message.md) blocks, in order to indicate which Discord user it should be replying to.

In the following example, whenever our Discord bot receives a private message, we detect it with our `On Discord Private Message` block, and then send it to a [`String Branch`](/dev-tooling/blocks/base-condition/string-branch.md)block to check if the message equals "good bot". If it does, then we use a `Reply Private Discord Message` block to send a thank-you message back to the user who sent the "good bot" message.

<figure><img src="https://i.imgur.com/paNc2Lp.png" alt=""><figcaption></figcaption></figure>

Note that the "Author" output of the `On Discord Private Message` block is plugged into the [`Reply Private Discord Message`](/dev-tooling/blocks-messaging/discord/reply-private-discord-message.md) block to indicate that the reply should be made to the same user that sent the original private message.

In this example, our thank-you message is customized to include the username of the Discord user who sent the original private message. We achieve this by constructing our message with a [`Replace String In String`](/dev-tooling/blocks/string/replace-string-in-string.md) block, and feeding the "From" output of our `On Discord Private Message` block into the "ReplaceText" input of the `Replace String In String` block.<br>


---

# 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://docs.graphlinq.io/dev-tooling/blocks-messaging/discord/on-discord-private-message.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.
