Answered

How to best manage multiple API calls?

  • 16 May 2023
  • 2 replies
  • 69 views

Hi there,

 

I am looking for advice on how to best manage API calls for our business application.

It appears that using the API, multiple calls will be necessary to be able to perform given actions. For example, if a user has signed into our application and wishes to start a conversation, from what I understand they will have to:

- Fetch their id with their email using the /contacts/search endpoint
- Create a conversation with their id using the /conversations endpoint
- If successful, we want to refresh our device to display the new message and created conversation, meaning we must hit the /conversations/id endpoint

For this flow, this is 3 calls per action, which could add up quite substantially if multiple users are operating simultaneously.

Is there a better way to do this? Perhaps I am not using the API as efficiently as I could be.

 

Thanks!

icon

Best answer by Jacob Cox 21 May 2023, 16:37

View original

2 replies

Userlevel 4
Badge +5

Hi @Max De Burnay-Bastos !

 

It’s possible there are members of the community who have some more experience building out this flow and have some tips, but what you’ve laid out above sounds right to me. You would need to find the User and create the conversation. I’m not 100% clear on that 3rd step, but it sounds like this might be specific to your use case, so I’m going to go with your judgement there.

One thing you could consider doing is updating your User with an attribute that stores their Intercom ID. Then you wouldn’t have to look the User up anymore, rather you could directly access their Intercom ID from your database. It might mean more traffic in the early days, but could save API calls down the road.

Thanks a lot for the reply Jacob! Will look into this.

Reply