B
B
bal_square2018-10-22 23:30:27
Node.js
bal_square, 2018-10-22 23:30:27

How to competently use third-party APIs in your web application on NodeJS?

Hello, I am doing my project - a chat server. For example, I have a function that, by voice phrase "add a reminder on X number", interacts with the Google Calendar API. The request path looks like this: the user sends a message -> the server opens the stream and sends it to Yandex SpeechKit -> SpeechKit returns a string result -> the server redirects the string to the dialogFlow API -> dialogFlow API returns the result to the server -> the server makes a Google Calendar API request -> the server receives the result of the add reminder operation. As a result, before reaching the result, a whole series of requests to third-party APIs occurs, because. the project is still working with one user, there are no performance problems, but if the user base is expanded, I am sure that large drawdowns will begin. Perhaps there are ways to shorten such a long chain of events, or there are certain design patterns for such applications. Who faced this problem, tell me please.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Philipp, 2018-10-23
@zoonman

1. Why not use Google Actions? Or things like dialogflow.com?
2. Reducing latency is possible with a number of tricks, such as starting to send voice data directly to the service from the moment it starts to be spoken. Next is the caching layer for the results of intent extraction.
3. Hosting the entire speech recognition stack and intents.
4. Parallelization of the chain where possible.
For example
- Buy movie tickets for a good Tarantino movie

1. Распознавание
2. Параллельно:
   = Поиск хороших фильмов Тарантино
   = Поиск кинотеатров поблизости
   = Получение данных вашего календаря
3. = Запрос расписаний из ближайших кинотеатров (можно делать параллельно, если нет общего API)
4. Поиск оптимального сеанса
5. Заказ билетов

5. Asynchronous execution through the queue, where possible.
For example:
- Send tickets to mom.
- Good. (the task is queued, executed asynchronously without blocking the user)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question