Twilio: How to get Programmatical Chat statistics via API? - node.js

Question
How can the Twilio API be used to get overall statistics for all channels and messages with given time ranges?
One example of this statistic is: What is the total message count for all channels today?
Bruteforce method (Non-ideal)
Get all channels for a Twilio service. Get all messages for each channel. Check the timestamp of these messages.
The bruteforce method mentioned above is not scalable. Is there a more efficient way this could be done?

Twilio developer evangelist here.
To get that information from the API, you're right you will need to loop through your channels and fetch the messages.
An alternative is to register for the onMessageSent webhook and aggregate the messages in your own database.
Hope this helps.

Related

What is the send message throughput of MS Teams bot?

I am developing an MS Teams app with a bot. Occasionally, the bot needs to send a proactive message to a subset of users who have installed the app.
We cannot send a message to multiple users at once. So we have to make one HTTP request per user per message. Given that batching is not possible and there are API rate limits, I want to know how scalable is this.
Specifically, I want to know the approximate time between when the first and the last user receive the messages if I send message to 5k users at once. What about 10k? 20k?
Any help is much appreciated, thanks :)
This document gives a lot of detail on the throttle limits, and the related time periods required: https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/rate-limit

If I have multiple clients subscribed to a pusher channel, can I have only one of them receive the message?

I have a load balanced situation, in which I have multiple instances running. I'm subscribing to a channel in each instance, but I only want one of them to trigger when a message comes through.
Is there any way to accomplish this?
If you want to have different subscribers and some are only interested in a subset of the messages distributed by a your publisher. Then your messaging service must allow subscribers to specify the topics relevant for them and/or inspect the messages and specify the content they are interested in.
that kind of goes against pub/sub pattern. Even if you added a streaming application in between you channel and your clients, this will still need to read all messages to decide which one to filter out to different clients
If you mean, for example, Android or IOS notifications, then you are able to store push tokens in your database, filter them and send a message only selected users.
P.S. It could help if you provide more details about the environment of push notifications you ask, and an architecture of the application you develop.

Twilio - Understanding if outbound call is transferred by receiver

Using Node.JS and the Twilio API I can easily see when a transfer initiated by my Twilio code is answered using Call Status Events. But, what if the person I am calling transfers my call?
Is there anything in the Twilio API that will tell me the call is being transferred, is currently on hold, and when that transfer is answered?
Desired Flow:
Twilio Bot calls Number
Receptionist answers
Twilio Bot asks to speak with a salesperson
Receptionist says they will transfer the call, and begins the transfer
Twilio Bot is put on hold and hears Silence/Ringing/Music/Automated "pease wait. You are # in the que" messages
Salesperson answers
Twilio Bot greets and continues the conversation with Salesperson
This is not possible.
The information is hidden behind the receptionists PBX, and not exposed outside that platform. The transfer is basically invisible to Twilio or any external parties from a signaling perspective.

MessageBird: How to read a response from consumer

I am evaluating MessageBird service. I got a Virtual Mobile Number. I am able to send message to dummy numbers (until i get approval for sending messages to real USA number)
Unknown: My problem is about reading the messages received by a VMN.
Details: If I as a VMN owner send a message to consumer e.g. +1(111)111-1111 and i am interested in reading the response from the consumer, how to do get it?
MessageBird documentation expects me to know the ID for response message object (or my understanding is wrong). The documentation is good but i don't see a way to programmatically achieve it. Any suggestions How to achieve it?
Thanks in advance!
Messagebird have a feature of forward incoming sms data through webhook(get or post method). if you set an url then Messagebird will forward every incoming sms to you(or your server). You can easily read get/post response.

Push notification to millions of device + Apns + node.js

My application stack is ios(front-end) and node.js(back-end). I have to send notification to devices. In my node.js part im using apns module to send notification, its working fine......
Now i have to send Mass notification like at a time consider i have 10,000 devices to notified, the logic what im following is
I'm looping through 10,000 devices and calling apns provider.
1.Why this for loop approach
I have to store each notification details in my mongodb collection, so i followed this approach.
The problem is the notification is received by some devices and that too very late(next day).
I read the link also
https://www.raywenderlich.com/156966/push-notifications-tutorial-getting-started
saying apns will reject.
Is the above approach is correct also any way to make all notification deliverer.
Please share your ideas. Thanks in advance.
If you need to process each individual notification before/after it is sent I would instead recommend a design change from a loop and have you look at job queue instead.
With this design pattern, instead of your only step being to loop over notifications and send via APN, you push these notification into a queue/messaging system and have workers which pull from the queue and process (send via APN and write to mongo) the notifications. The nice part of this design is that as your application grows you can add on more workers to handle the increased load without rewriting your application/architecture. Once you have it built it may look something like this:
I personally use RabbitMQ for my job queue, but that decision is something you need to research on your own. For example if you don't want to manage the messaging system you could look into something like AWS Simple Queue Service.
I think looping through 10,000 devices ids and calling APNS provider is not the right way forward. The documentations strictly says here node-apn readme file to reuse apn.Provider rather than recreate it every time to achieve the best possible performance.
If you send notification using arrays of device ids rather than just a device id then you will get a response from the APNS mentioning all the details for each device.

Resources