Trouble sending and receiving chat messages using the Meeting SDK

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:

m_pChatController->SetEvent(new MeetingChatControllerEvent());
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:

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?

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

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

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:

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

Failed to send a chat message: 2

What am I doing wrong here?

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

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

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

@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.

To start, can you log what chat_builder->Build() returns and share the result?

@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?

1 Like

Have you looked

I noticed you’ve implemented the onChatMsgNotification() 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?

@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.

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

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!