How do I make a messaging sytem using only API

DesperateCoder
Participant

I am unfamiliar with this system and am very confused with the documentation. From what I need, I have the following goals:
1. Send messages from a user to an agent, if the user sends another one then it's a new chain. (Attatchments needed)
2. Send follow up messages from a user to an agent, this continues an existing chain. (Attatchments needed)
3. Get all the message chains that belong to 1 user.

I have been researching and looking around the documentation and am really confused with regards to the following API:


Conversations:
- Requires threads to exist before making a message
- The entire Thread works as one giand message chain from what I understand, getting the messages gets ALL the messages.
- making a thread for each user seems to be impossible by API only.
- I seem to be missing something here.

Custom Channels:
- Can make as many as we want
- each channel can have a custom name
- Sending a message can start a thread yes, but it's not very clear on how to continue or follow up a thread without making a new one.
- I am unclear how each message chain is tracked

I feel like I'm doing it wrong from the get-go. so I need to know: which do I go with and would like to be at least pointed in the right direction.

I am very confused on how this works and thanks to anyone in advance.

0 Upvotes
1 Accepted solution
BérangèreL
Solution
Community Manager
Community Manager

Hi @DesperateCoder and great job mapping this out!

Your steps are accurate with one clarification:

For step 6, you can filter threads by associatedContactId as a query parameter, but the endpoint is GET /conversations/v3/conversations/threads (not a separate endpoint).

I hope this helps!

Have a lovely day!
Bérangère

This post was created with the assistance of AI tools.





loop


Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.

Learn More




View solution in original post

5 Replies 5
RubenBurdin
Top Contributor

Hi @DesperateCoder , you’re not doing it “wrong,” HubSpot’s naming just makes it easy to get turned around the first time. If your goal is a messaging system API-only that still shows up in Inbox/Help Desk, the “Custom Channels” route is the right mental model.

 

A thread is the message chain, and messages live inside that thread. Custom Channels is basically how you’re allowed to create and feed those threads from an external system, while still using the same underlying Conversations threads/messages endpoints to read and append to them (so yes, it all converges back into the Conversations platform). The official custom channels guide is the cleanest place to anchor the flow and required objects (https://developers.hubspot.com/docs/api-reference/conversations-custom-channels-v3/guide )

 

Two important gotchas. First, Custom Channels is not supported with legacy private apps, so if you were hoping to do this with a private app only, you’ll hit a wall and need a public app setup instead (that note is in the Custom Channels docs). Second, “new chain vs follow-up” is something you control: you create a new thread when you decide it’s a new conversation, and you POST a message to the existing threadId when it’s a follow-up. That “send message to an existing thread” behavior is documented here (https://developers.hubspot.com/docs/api-reference/conversations-conversations-v3/guide )

 

One quick question that affects the whole design: do you need agents to work these conversations inside HubSpot’s Inbox/Help Desk UI, or is this purely a backend messaging store with no human-in-HubSpot requirement? Attachments especially can push you toward one approach vs another depending on where you want the files to live.

Did my answer help? Please mark it as a solution to help others find it too.

Ruben Burdin Ruben Burdin
HubSpot Advisor
Founder @ Stacksync
Real-Time Data Sync between any CRM and Database
Stacksync Banner
0 Upvotes
DesperateCoder
Participant

@RubenBurdin wrote:

One quick question that affects the whole design: do you need agents to work these conversations inside HubSpot’s Inbox/Help Desk UI, or is this purely a backend messaging store with no human-in-HubSpot requirement? Attachments especially can push you toward one approach vs another depending on where you want the files to live.


(sorry for late reply, just got back from christmas vacation)

The latter based of my clients requirements. they want to use hubspot as a back end to their messaging sytem. the files can technically live anywhere but they seem to want it to be on hubspot. based on the documentations it looks straightfoward enough:  upload the file with the Upload file api then provide the file ID in the message if I recall correctly. unless I happen to be mistaken on that?

0 Upvotes
BérangèreL
Community Manager
Community Manager

Hey @DesperateCoder 👋 and welcome, it's a pleasure to have you here!

To start with, I'd like to share these resources that might point you in the right direction:

- Custom channels
- Publish a message

Now, I'd love to put you in touch with our Top Experts who have experience with the conversations API: Hi @suprdense, @hugo-at-ukio and @sylvain_tirreau do you have any insights to share with @DesperateCoder, please?

Thanks so much and have a brilliant weekend!
Bérangère





loop


Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.

Learn More




0 Upvotes
DesperateCoder
Participant

@BérangèreL from looking at the documentation you linked and reading the info from the ai assistant, I got the following steps, please inform me if I got something wrong:

Setup:
1. Create a custom channel to facilitate messaging- POST /conversations/v3/custom-channels/
2. Create a channel account to act as the message delivery- POST /conversations/v3/custom-channels/{channelId}/channel-accounts

User api side preperation:
3. Create a contact (for the local site based user to be linked to) - POST /crm/v3/objects/contacts

New message being sent:
4. Create a thread and be given a thread id- POST /conversations/v3/custom-channels/{channelId}/threads

Follow up messages being sent:
5. Send messages to the thread (both agent and user level)- POST /conversations/v3/conversations/threads/{threadId}/messages

Get All messages:
6. Retrieve threads by contact - GET /conversations/v3/conversations/threads?associatedContactId={contactId}
7. get the messages of a thread (a call for each thread)- GET /conversations/v3/conversations/threads/{threadId}/messages 

Terms and concepts to verify:
- Threads are message chains
- Custom channels work with the regular conversations API and not just the custom-channels API
- The "Flow" is Inbox->Channels->threads->messages. and Threads are supposed to be created each time a new conversation starts.

Thank you for your time and effort, I hope I got this right.

0 Upvotes
BérangèreL
Solution
Community Manager
Community Manager

Hi @DesperateCoder and great job mapping this out!

Your steps are accurate with one clarification:

For step 6, you can filter threads by associatedContactId as a query parameter, but the endpoint is GET /conversations/v3/conversations/threads (not a separate endpoint).

I hope this helps!

Have a lovely day!
Bérangère

This post was created with the assistance of AI tools.





loop


Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.

Learn More