# How to send Direct Message?

**URL:** <https://forum.heroiclabs.com/t/how-to-send-direct-message/2744>\
**Category:** Game Design\
**Created:** [June 17, 2022, 5:36am UTC](https://forum.heroiclabs.com/t/how-to-send-direct-message/2744 "2022-06-17T05:36:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ownway88](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/ownway88/32/1201_2.png) [@ownway88](https://forum.heroiclabs.com/u/ownway88)\
**Post date:** [June 17, 2022, 5:36am UTC](https://forum.heroiclabs.com/t/how-to-send-direct-message/2744/1 "2022-06-17T05:36:50Z")

</div>

Hi,

I am trying to integrate Nakama into my game. I ran into a little trouble on sending direct message. I use C++ and used the example code from the documentation shown below. After the JoinChat request was sent, a notification of DM invitation was sent to the receiver. The receiver did receive the notification, but I do not know how to reply that notification to accept the invitation, I do not find any documentation on this detail. I tried to confirm by replying with the same Joinchat request to the sender. But it seems not working as I tried to send messages afterwards by using writeChatMessage API to the granted private channel, the receiver can not receive the those direct messages. Anyone can help or an example code for this? Thanks!

```auto
auto successCallback = [](NChannelPtr channel)
{
    std::cout << "You can now send messages to channel id: " << channel->id << std::endl;
};

string userId = "<user id>";
rtClient->joinChat(userId, NChannelType::DIRECT_MESSAGE, true, false, successCallback);

```

---

<div class="post-metadata">

**Author:** ![ownway88](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/ownway88/32/1201_2.png) [@ownway88](https://forum.heroiclabs.com/u/ownway88)\
**Post date:** [June 18, 2022, 2:36am UTC](https://forum.heroiclabs.com/t/how-to-send-direct-message/2744/2 "2022-06-18T02:36:22Z")

</div>

Just for anyone who had similar questions, I did found the solution by myself. It seems to me that the receiver’s responding with the same JoinChat request is the right way to accept the DM invitation, but I do not find this in any official documentation. Failing to send private messages was due to something else actually which is how I got confused. Maybe it is nice to make invitation responding mechanism clear in the documentation as in general the documentation is quite good and in detail.

---

<div class="post-metadata">

**Author:** ![formatCvt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/formatcvt/32/1127_2.png) [@formatCvt](https://forum.heroiclabs.com/u/formatCvt)\
**Post date:** [June 20, 2022, 7:06am UTC](https://forum.heroiclabs.com/t/how-to-send-direct-message/2744/3 "2022-06-20T07:06:06Z")

</div>

Yep, something like that

 ![изображение](https://us1.discourse-cdn.com/flex020/uploads/heroiclabs/original/2X/5/5a6cc5b95eed340b903be93c3fcbeff8aea7acb2.png)

---

<div class="post-metadata">

**Author:** ![formatCvt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/formatcvt/32/1127_2.png) [@formatCvt](https://forum.heroiclabs.com/u/formatCvt)\
**Post date:** [June 22, 2022, 1:02pm UTC](https://forum.heroiclabs.com/t/how-to-send-direct-message/2744/4 "2022-06-22T13:02:53Z")

</div>

I have one more question - How to receive direct messages after reconnect.  
For example: Alice and Bob connected to direct channel and send each other messages - everything work as expected.  
Bob disconnected from server and connected again. Alice still connected to channel and send messages to Bob. But Bob received nothing (No channel messages, no events). How to receive messages on Bob side? We should save all direct chat channels IDs and connect manually?

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [June 22, 2022, 2:02pm UTC](https://forum.heroiclabs.com/t/how-to-send-direct-message/2744/5 "2022-06-22T14:02:21Z")

</div>

Correct, to receive messages while disconnected (offline) they should be persisted, and when the disconnected user comes back it should use [Nakama: Real-time Chat | Heroic Labs Documentation](https://heroiclabs.com/docs/nakama/concepts/chat/#message-history) to list the “missed” messages and re-join the channel to receive any messages sent thereafter.

---

<div class="post-metadata">

**Author:** ![ownway88](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/ownway88/32/1201_2.png) [@ownway88](https://forum.heroiclabs.com/u/ownway88)\
**Post date:** [July 9, 2022, 12:50am UTC](https://forum.heroiclabs.com/t/how-to-send-direct-message/2744/6 "2022-07-09T00:50:36Z")

</div>

Now I see the documentation is updated and it is very clear now 👍
