Looking for a Platform API Text Chat Example

Hi, I am working on an application where the chat is integrated with our server side code. I am having difficulty finding examples of code using the Platform API. I have seen the docs but I would like to see some examples as the docs still leave somethings a little unclear. It would also be helpful to see a couple examples of how to approach problems.

Are there are any sample Platform API projects out there? Any other advice as to how to proceed?

Hi @scottpatrickwright,

Welcome to the Sendbird Community. Can you expand on what kind of difficulty you’re having? The Platform API is pretty vast and thus it can cover a large variety of use cases.

In terms of implementation, The Platform API is purely an HTTP request and thus you can utilize it with your favorite libraries like Axios, Fetch, Got, etc.

Additionally, we just released an SDK for the Platform API for node. sendbird-platform-sdk - npm

Thanks for the reply.

Well specifically we are looking to build an experience where the server can control on a message by message basis whether a user can send a message to a recipient. I can imagine how to get the work done in broad strokes but there can be missing details. I find examples clear up the gaps that most docs leave.

In this case I am wondering about the format of the channel url when sending a message:

POST https://api-{application_id}.sendbird.com/v3/{channel_type}/{channel_url}/messages

The docs say its a string and one assumes a URL. But it doesn’t seem to say much more about it. Is it an actual URL or just some unique string like a UUID? If its a URL - what should it be specifically?

Ok had an idea while forming the question to you. I see that when I create a channel I either specify or get back a URL. So it would match that. I also see an example where the channel URL appears to be a string identifier essentially.

Here is the response you would get from creating a channel:

{
    "name": "Saturday soccer members",
    "channel_url": "private_chat_room_424",
    "cover_url": "https://sendbird.com/main/img/cover/cover_08.jpg",
    "custom_type": "sports",
    "is_distinct": true,
    "inviter_id": "Jay",
    "user_ids": ["Jay", "James", "Young"],
    "invitation_status": {
        "James": "invited_by_friend",
        "Young": "invited_by_non_friend"
    },
    "hidden_status": {
        "Jay": "hidden_allow_auto_unhide"
    },
    "operator_ids": ["Jeff"]
}

But I guess no sample project readily available then?

Hi @scottpatrickwright,

Unfortunately, we don’t have any kind of sample projects around the the Platform API. The Platform API is more specifically for management purposes and isn’t how you should be sending messages to channels on behalf of users. That should be occurring via the SDKs so they can receive realtime updates.

Does that mean that if I called the POST message endpoint on a user’s behalf the recipient would not have the message broadcast to them as I would normally expect if the message was sent from the client via the SDK?

I’d like to tease out the differences between sending messages via the Platform API and via the client SDKs.

I recognize that this may not be a core expectation with the Platform API but our use case really does require that we can ‘gate’ message sending on a message by message basis.

If the user is connected to Sendbird via the SDK, they’ll still receive realtime updates that a message was sent to a channel they’re in.