# Trouble sending and receiving chat messages using the Meeting SDK

**URL:** <https://devforum.zoom.us/t/trouble-sending-and-receiving-chat-messages-using-the-meeting-sdk/118692>\
**Category:** Meeting SDK\
**Created:** [October 7, 2024, 2:00pm UTC](https://devforum.zoom.us/t/trouble-sending-and-receiving-chat-messages-using-the-meeting-sdk/118692 "2024-10-07T14:00:35Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![saranshabd](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/saranshabd/32/63298_2.png) [@saranshabd](https://devforum.zoom.us/u/saranshabd)\
**Post date:** [October 7, 2024, 2:00pm UTC](https://devforum.zoom.us/t/trouble-sending-and-receiving-chat-messages-using-the-meeting-sdk/118692/1 "2024-10-07T14:00:35Z")

</div>

I have written a simple Zoom Meeting SDK integration. My objective is to send and receive chat messages using my bot. If anyone sends a public message or directly sends a message to my bot then the bot should receive it, and secondly, the bot should be able to respond to such messages either publicly or privately.

I am facing a problem with both sending and receiving messages.

I implemented `IMeetingChatCtrlEvent` and added it like this:

```cpp
m_pChatController->SetEvent(new MeetingChatControllerEvent());

```

```auto
class MeetingChatControllerEvent : public IMeetingChatCtrlEvent
{
public:
    MeetingChatControllerEvent();
    virtual void onChatMsgNotification (IChatMsgInfo *chatMsg, const zchar_t *content);
    virtual void onChatMsgNotifcation (IChatMsgInfo *chatMsg, const zchar_t *content);
    virtual void onChatStatusChangedNotification (ChatStatus *status_);
    virtual void onChatMsgDeleteNotification (const zchar_t *msgID, SDKChatMessageDeleteType deleteBy);
    virtual void onShareMeetingChatStatusChanged (bool isStart);
    virtual void onFileSendStart (ISDKFileSender *sender);
    virtual void onFileReceived (ISDKFileReceiver *receiver);
    virtual void onFileTransferProgress (SDKFileTransferInfo *info);
};

```

- I added logging and found out that the constructor gets called however `onChatMsgNotification` method does not get called.
- As a matter of fact, the only other method called was `onChatStatusChangedNotification` with the `status->is_chat_off` set as 0.

`onChatMsgNotification` method should be called with the chat messages as per my expectation. Also, I noticed `onChatMsgNotifcation` (notice the typo) method had to be implemented for the code to successfully compile. Weird.

Secondly, here is how I am trying to send a test message to everyone in the meeting:

```cpp
std::wstring wstr = L"Hello world!";
wchar_t wcharArray[1024];
wcscpy(wcharArray, wstr.c_str());

char charArray[1024];
std::wcstombs(charArray, wcharArray, 1024);

IChatMsgInfoBuilder* chat_builder = m_pChatController->GetChatMessageBuilder();
chat_builder->SetReceiver(0);
chat_builder->SetMessageType(SDKChatMessageType_To_All);
chat_builder->SetContent(charArray);
chat_builder->Build();
m_pChatController->SendChatMsgTo(chat_builder->Build());
std::cout << "Chat message sent successfully" << std::endl;

```

Here, I can see the success log in the console but the bot did not actually send any message in the meeting. I was expecting the method to throw an error if it did not have the permissions or if it failed to send the message. I have given almost all the permissions related to meetings and chats to my Zoom app.

The Zoom Meeting SDK version is 6.1.0.225.

@chunsiong.zoom @gofmannir Would you be able to help here?

---

<div class="post-metadata">

**Author:** ![gofmannir](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/gofmannir/32/56746_2.png) [@gofmannir](https://devforum.zoom.us/u/gofmannir)\
**Post date:** [October 7, 2024, 2:18pm UTC](https://devforum.zoom.us/t/trouble-sending-and-receiving-chat-messages-using-the-meeting-sdk/118692/2 "2024-10-07T14:18:01Z")

</div>

> [@saranshabd](#):
>
> `SendChatMsgTo`

Hi,  
The method retures ` SDKError` value, try to log it to understand if there is an error sending a message.

---

<div class="post-metadata">

**Author:** ![saranshabd](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/saranshabd/32/63298_2.png) [@saranshabd](https://devforum.zoom.us/u/saranshabd)\
**Post date:** [October 7, 2024, 3:57pm UTC](https://devforum.zoom.us/t/trouble-sending-and-receiving-chat-messages-using-the-meeting-sdk/118692/3 "2024-10-07T15:57:56Z")

</div>

@gofmannir @chunsiong.zoom I modified the code a bit:

```cpp
ZOOM_SDK_NAMESPACE::SDKError chat_controller_event_err = m_pChatController->SetEvent(
    new MeetingChatControllerEvent()
);
if (chat_controller_event_err != ZOOM_SDK_NAMESPACE::SDKERR_SUCCESS)
{
    std::cout << "Failed to init chat controller: " << chat_controller_event_err << std::endl;
}
else
{
    std::cout << "Chat controller event initialized successfully" << std::endl;
}

```

From here I got the success log. That means the controller was initialised so ideally I should be notified of the chat messages from the meeting.

Next up, I received the error message from `SendChatMsgTo`:

```cpp
ZOOM_SDK_NAMESPACE::SDKError send_msg_err = m_pChatController->SendChatMsgTo(
    chat_builder->Build()
);
if (send_msg_err != ZOOM_SDK_NAMESPACE::SDKERR_SUCCESS)
{
    std::cout << "Failed to send a chat message: " << send_msg_err << std::endl;
}

```

Here, I got the following log: _Incorrect usage of the feature_

```auto
Failed to send a chat message: 2

```

What am I doing wrong here?

---

<div class="post-metadata">

**Author:** ![saranshabd](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/saranshabd/32/63298_2.png) [@saranshabd](https://devforum.zoom.us/u/saranshabd)\
**Post date:** [October 8, 2024, 5:35pm UTC](https://devforum.zoom.us/t/trouble-sending-and-receiving-chat-messages-using-the-meeting-sdk/118692/4 "2024-10-08T17:35:45Z")

</div>

@gofmannir @chunsiong.zoom - Can either of you guys help me out here?

---

<div class="post-metadata">

**Author:** ![donte.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/donte.zoom/32/24412_2.png) [@donte.zoom](https://devforum.zoom.us/u/donte.zoom)\
**Post date:** [October 9, 2024, 3:48am UTC](https://devforum.zoom.us/t/trouble-sending-and-receiving-chat-messages-using-the-meeting-sdk/118692/5 "2024-10-09T03:48:57Z")

</div>

@saranshabd, Is this behavior only happening with your integration? Have you tested this behavior with the sample app as well?

---

<div class="post-metadata">

**Author:** ![saranshabd](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/saranshabd/32/63298_2.png) [@saranshabd](https://devforum.zoom.us/u/saranshabd)\
**Post date:** [October 9, 2024, 12:37pm UTC](https://devforum.zoom.us/t/trouble-sending-and-receiving-chat-messages-using-the-meeting-sdk/118692/6 "2024-10-09T12:37:35Z")

</div>

@donte.zoom - the sample app does not implement this interface for chat. Can you point me to the sample implementation for chat?

---

<div class="post-metadata">

**Author:** ![donte.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/donte.zoom/32/24412_2.png) [@donte.zoom](https://devforum.zoom.us/u/donte.zoom)\
**Post date:** [October 9, 2024, 1:32pm UTC](https://devforum.zoom.us/t/trouble-sending-and-receiving-chat-messages-using-the-meeting-sdk/118692/7 "2024-10-09T13:32:06Z")

</div>

@saranshabd ,

Currently, there is no implementation for the chat interface. That sample app was designed to show folks how to get raw data from meetings. I am happy to you get to the bottom of this.

> [@saranshabd](#):
>
> ```auto
> chat_builder->Build();
> m_pChatController->SendChatMsgTo(chat_builder->Build());
> std::cout << "Chat message sent successfully" << std::endl;
> 
> ```

To start, can you log what chat\_builder-\>[Build()](https://marketplacefront.zoom.us/sdk/meeting/linux/class_i_chat_msg_info_builder.html#a1c3a666bece564b50f8f2acc05d04fdb) returns and share the result?

---

<div class="post-metadata">

**Author:** ![saranshabd](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/saranshabd/32/63298_2.png) [@saranshabd](https://devforum.zoom.us/u/saranshabd)\
**Post date:** [October 9, 2024, 4:19pm UTC](https://devforum.zoom.us/t/trouble-sending-and-receiving-chat-messages-using-the-meeting-sdk/118692/8 "2024-10-09T16:19:31Z")

</div>

@donte.zoom - I will try this. More importantly, I want to understand how to get notified about chat messages in the meeting. Can you help me with that first?

I want people to be able to send messages to my bot because I want to perform operations based on those messages (commands?). My implementation does not work (you can refer to the thread). How can it be correctly implemented?

---

<div class="post-metadata">

**Author:** ![donte.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/donte.zoom/32/24412_2.png) [@donte.zoom](https://devforum.zoom.us/u/donte.zoom)\
**Post date:** [October 9, 2024, 5:36pm UTC](https://devforum.zoom.us/t/trouble-sending-and-receiving-chat-messages-using-the-meeting-sdk/118692/9 "2024-10-09T17:36:07Z")

</div>

Have you looked

> [@saranshabd](#):
>
> `onChatMsgNotifcation`

I noticed you’ve implemented the [onChatMsgNotification()](https://marketplacefront.zoom.us/sdk/meeting/linux/class_i_meeting_chat_ctrl_event.html#a4b3c4c5c7738995d8ea62598f37d1fb3) callback in your integration. Could you please share more details about what specific aspects aren’t working as expected? Are you receiving any events at all?

---

<div class="post-metadata">

**Author:** ![saranshabd](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/saranshabd/32/63298_2.png) [@saranshabd](https://devforum.zoom.us/u/saranshabd)\
**Post date:** [October 9, 2024, 7:09pm UTC](https://devforum.zoom.us/t/trouble-sending-and-receiving-chat-messages-using-the-meeting-sdk/118692/10 "2024-10-09T19:09:15Z")

</div>

@donte.zoom - As you can see from my implementation I have implemented the chat interface already. The constructor was called (verified from the logs) and `onChatStatusChangedNotification` was also called. But no other methods were called. I tried to post public chat messages in the meeting and I also tried directly sending a message to my bot. I did not get any error nor was any of the other methods were called.

Am I doing anything wrong here? Is it a permissions issue? I am not sure why this is not working here.

---

<div class="post-metadata">

**Author:** ![donte.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/donte.zoom/32/24412_2.png) [@donte.zoom](https://devforum.zoom.us/u/donte.zoom)\
**Post date:** [October 9, 2024, 8:11pm UTC](https://devforum.zoom.us/t/trouble-sending-and-receiving-chat-messages-using-the-meeting-sdk/118692/11 "2024-10-09T20:11:09Z")

</div>

Check out this thread @saranshabd and let me know if it helps:

> [@IMeetingChatController::SendChatMsgTo fails](https://devforum.zoom.us/t/imeetingchatcontroller-sendchatmsgto-fails/113099/6):
>
> @seungkoo I’ve just tried this and it works, however I’m a different implementation to make sure that the sending of message will be definitely in the main thread. //onChatMessageReceived is a helper method in the main thread, which is passed into this event listener. When there is message received on the event listener, it passes the message back into onChatMessageReceived method in the main thread. MeetingChatEventListener::MeetingChatEventListener(void(\*onChatMessageReceived)(IChatMsgInfo\*…

---

<div class="post-metadata">

**Author:** ![amanda-recallai](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/amanda-recallai/32/44747_2.png) [@amanda-recallai](https://devforum.zoom.us/u/amanda-recallai)\
**Post date:** [October 15, 2024, 11:55pm UTC](https://devforum.zoom.us/t/trouble-sending-and-receiving-chat-messages-using-the-meeting-sdk/118692/13 "2024-10-15T23:55:09Z")

</div>

Hey @saranshabd,

Are you by chance trying to send the message in a background thread?

If you are, you’ll want to make sure it’s sent from the main thread, as sending chat messages will not work from a background/child thread!
