hangout API event on exit - google-plus

I created a Hangout API that works to send invites to certain users from my server by sending an ajax request from my app with hangout url etc.
For now I need hangout event on exit so that I can make another callback to my server indicating that particular hangout has been closed.
I know it sounds odd. I looked around on https://developers.google.com/+/hangouts/api/gapi.hangout but didn't get any such events.
Can I tweak it in some other way to get a notification on exit?

I think this was already answered on the Google forums. The short answer is no there is currently not an event to detect the exit of the Hangout.
You could have your app send a periodic heartbeat to your server and once you detect a timeout then you can conclude the hangout stopped.
Another approach might be to implement an onbeforeunload handler within your hangout app and use that to send a Ajax call back to your server each time a participant leaves or just when the final participant leaves. You can get the participant count from the API and might also be able to use the participantChanged event. Not sure if participantChanged event will fire if the last user exits the hangout by closing the window, that could be a route to explore too.

+1 what Brett said for the heartbeat. I would also optimize by only starting the heartbeat when there is one participant. It would be rare that everyone exists the hangout at the exact same time.
Darn solar flares!

Related

How to chat and call automatically in MS Teams?

I'm working on a solution to build a system that automatically alerts users on Microsoft Teams. The order of execution will be:
Automatically scan alarm logs
Sort and send MS Teams messages to personnel for corresponding processing
If the processing staff does not receive the message, make a call on MS Teams to read the pre-recorded voice record.
I used python to automatically get the warning list, to send this alert list to the handler, I have tried MS Teams REST API but it only supports sending messages to Channel. How do I automatically chat and voice calls to an MS Teams user? Can chatbot help me with this problem? I see there are many types of bots that can be added to the conversation:
I think a chatbot is definitely the best way to deal with this. Essentially, you're wanting the bot to message a user on demand, which is something called "Proactive Messaging". You can read more here and here. There are a few things you need to know about this, but in a nutshell you need a way to specifically identify the user for sending the message, which you can get when the user first installs your bot (mostly you need "ServiceUrl" and "ConversationId").
With regards to knowing if the user has read the message, you might want to send an "adaptive card" with a button for the user to acknowledge that they've read the message, and if you don't get a callback within some time frame, start the voice call.

Telegram Bots: Can I now start a chat or not?

https://core.telegram.org/bots clearly says:
Bots can't initiate conversations with users. A user must either add them to a group or send them a message first.
But if I visit https://telegram.org/blog/login it says
Telegram bots are a powerful communication tool, but until today they couldn't start a conversation. Even if you wanted them to reach out to you, you had to chat them up first.
With the new login widget, moving from interacting with a website to a conversation on Telegram becomes completely frictionless.
So it is somehow possible to start a conversation via the login widget. But how do I do it?
I get a user id. Is there an api endpoint to initiate a chat with the user?
The only way to begin conversing with a Telegram bot is to start the conversation with them yourself. There's no way for the bot to start a conversation with a user themselves.
As you said, telegram clearly says there is no way for bot to start a conversation, the only thing bots can do is sending messages to an old conversation (I mean a user have to start the conversation).

Twilio integration

I am using twilio from salesforce (On a custom object) to call some numbers. Is there any way to send voicemails to those numbers without ringing there phone or with ring as least as possible .
Will appreciate your help .
Thanks!
Twilio developer evangelist here.
The voicemail of someone else's phone is not under control by Twilio. So you can't directly leave a voicemail without ringing them. You also cannot control the number of rings someone else's phone will make before going to voicemail.
Using Twilio, you could make calls to the numbers and play a message when they or their voicemail answers. This would either directly deliver the message to the user or record it on their voicemail.
[edit]:
After the discussion in comments below, here is an updated answer.
I'll give an overview of the system I think you need to build. I can't be more specific, because I have little details of your system or what you've tried.
I think you need to build in Twilio Client to your Salesforce application. You can watch a video on how to integrate Twilio Client with Salesforce.
You can use this to generate the calls to your customers and speak to them from within Salesforce.
To add to this, you also want to leave a message if you get a voicemail. You will need to do a few things to achieve this.
First, you will need to store the Call Sid of the call you made in the browser. You can get this from the parameters attribute of the Twilio.Connection.
You will need to add a button to your interface that is active when you are on an active call. This button needs to hook up to an endpoint in your Salesforce app. The button should send the Call Sid you saved from your connection to the app.
Within the Salesforce app, you will need to build the endpoint for the above. This will receive the Call Sid as an argument. This Call Sid is the parent call and represents your connection to the call. We need to get the Child Call, which is the other end. We do this by calling on the Calls resource passing the Call Sid as the ParentCallSid parameter. This will get you access to the child call.
You now need to redirect the child call using the REST API to another endpoint that has the TwiML to <Play> your recorded message for voicemail.
Then, when your user is on a call and it goes to voicemail, they should press the button in the interface. This will redirect the child call away and consequently hang up on the user in salesforce.
Let me know if this helps at all.

Strategy for notification checking

Is there a recommended strategy for checking of notifications within my AngularJS app?
By 'notification' I'm talking about message alerts that are to be displayed to a user when they're logged into the application.
My plan is to notify the user of unread notifications in the app's NavBar as shown below:
My app communicates with my restFul API (written using Node.js, express, MongoDB), so I anticipate that new notification will be written to a MongoDB collection with details the user the notification is intended for.
What I'm unsure about is how the AngularJS application will check for notifications once a user is logged on. I could call my API for unread notifications every time the user navigates from one path to another but that seems simplistic and it wouldn't work if a new notification occurs whilst a user is viewing a page.
Another way would be some sort of timer system that checked, say, every 30 seconds. But this would results in unnecessary polling of my API when there aren't any new notification for a user.
So, wondering if there is a recommended strategy. Thanks for your help.
Polling is a solution but it is very inefficient. The solution to your problem are websockets. Websockets is a technology that provides a full-duplex bidirectional communication between your clients and your server. So you can send messages from your server to your connected clients. Your server maintains an array of connected clients and you just have to know which ID you need to send a message to it.
For your stack, the best solution I have came to is Socket.io http://socket.io
It also have cool features. For example, you can "observe" models, so if a model change in your database, for example an update to a user profile is made, you can trigger an event and automagically send a message to your client. This client get and handles the notification and do something, like put a badge on your alerts icon.
Hope this is useful for you.

Telegram bots - how can we detect that a user has started typing?

We can get Telegram messages when they are complete and sent via long polling or webhooks, but is there a way to understand when the user has started typing?
I guess this is not a normal case for bots and I dont think there is a straight away method but could we fall back on the Telegram API for messaging apps for that?
Well, actually I found a solution in the current Bot API; inline queries. While they are not intended for this, inline queries send what the user types in to the bot in real-time, so you are alerted as soon as the first characters are typed in.
There is a way in Telegram Core API, named: updateUserTyping.
But there is not any way in Telegram Bot API yet (until today: 2016-10-17).
If you type or send a file to the bot during these processes you do not get any message from Telegram in your webhook, but it's possible they'll add a new feature to detect user typing in future Bot API updates.