Gather session minutes of a Tokbox session - opentok

I have the requirement to collect the total number of streamed minutes for all the tokbox sessions of the past month. Basically something similar to the billing report tokbox provides. I don't need it "live", a delay of minutes or even hours would be acceptable.
The inspector does not seem to have an API, and we are currently not archiving the sessions.
My current idea would be to use the Session Monitoring events and collect all Stream Destroyed events. I would then store them somewhere and use timestamp - stream.createdAt as the duration of each stream.
It feels a bit brittle at first glance - I don't want to report wrong numbers or miss something. Am I on the right track or is there an easier/better solution?
{
"sessionId": "2_MX4xMzExMjU3MX5-MTQ3MDI1NzY3OTkxOH45QXRr",
"projectId": "123456",
"event": "streamDestroyed",
"reason": "clientDisconnected",
"timestamp": 1470258896953,
"stream": {
"id": "63245362-e00e-4834-8371-9397deb3e452",
"connection": {
"id": "c053fcc8-c681-41d5-8ec2-7a9e1434a21e",
"createdAt": 1470257688143,
"data": ""
},
"createdAt": 1470258845416,
"name": "",
"videoType": "camera"
}
}

TokBox support confirmed that is is a valid way to go and that the Session Monitoring events are reliable enough. So we will go ahead with the idea of using the StreamDestroyed events.
Unfortunately, this is not equivalent to the subscribed minutes. Calculating those should be possible using the events, but could become quite complex.
{
"sessionId": "2_MX4xMzExMjU3MX5-MTQ3MDI1NzY3OTkxOH45QXRr",
"projectId": "123456",
"event": "streamDestroyed",
"reason": "clientDisconnected",
"timestamp": 1470258896953,
"stream": {
"id": "63245362-e00e-4834-8371-9397deb3e452",
"connection": {
"id": "c053fcc8-c681-41d5-8ec2-7a9e1434a21e",
"createdAt": 1470257688143,
"data": ""
},
"createdAt": 1470258845416,
"name": "",
"videoType": "camera"
}
}

The correct approach would be to collect both stream and connection events.
Then you can calculate the duration of each connection, and sum up those durations as streaming minutes for each session.

Related

Youtube Data API - /channels Endpoint not Returning Smaller Users

I am creating a networking app for musicians. I was wanting to use the Youtube Data API to let users connect their Youtube channel to their profile within my app. I got everything in place and working via making requests to URLs similar to https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics&forUsername=PewDiePie&key=[YOUR_API_KEY]. This works great and returns this JSON:
{ "kind": "youtube#channelListResponse", "etag": "\"p4VTdlkQv3HQeTEaXgvLePAydmU/bj_rirVFbrVoTIOa6lCGdaXaG5M\"", "pageInfo": { "totalResults": 1, "resultsPerPage": 5 }, "items": [ { "kind": "youtube#channel", "etag": "\"p4VTdlkQv3HQeTEaXgvLePAydmU/Blp06js4r7j93y1EfKve84oXWpo\"", "id": "UC-lHJZR3Gqxm24_Vd_AJ5Yw", "snippet": { "title": "PewDiePie", "description": "I make videos.", "publishedAt": "2010-04-29T10:54:00.000Z", "thumbnails": { "default": { "url": "https://yt3.ggpht.com/a/AGF-l79FVckie4j9WT-4cEW6iu3gPd4GivQf_XNSWg=s88-c-k-c0xffffffff-no-rj-mo", "width": 88, "height": 88 }, "medium": { "url": "https://yt3.ggpht.com/a/AGF-l79FVckie4j9WT-4cEW6iu3gPd4GivQf_XNSWg=s240-c-k-c0xffffffff-no-rj-mo", "width": 240, "height": 240 }, "high": { "url": "https://yt3.ggpht.com/a/AGF-l79FVckie4j9WT-4cEW6iu3gPd4GivQf_XNSWg=s800-c-k-c0xffffffff-no-rj-mo", "width": 800, "height": 800 } }, "localized": { "title": "PewDiePie", "description": "I make videos." }, "country": "US" }, "statistics": { "viewCount": "24334379402", "commentCount": "0", "subscriberCount": "102000000", "hiddenSubscriberCount": false, "videoCount": "4054" } } ] }
Most of my app's users will be smaller musicians, likely with less than 10k youtube subscribers. Take my sister for example, this is a link to her youtube channel: https://www.youtube.com/channel/UCe4Eogv2uGaKUe4x3VNrwsg.
Whenever trying to search for her Youtube channel with the API via https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics&forUsername=Audrey_Chopin&key=[YOUR_API_KEY] (and variations such as replacing Audrey_Chopin with Audrey%20Chopin or Audrey+Chopin) yield no results: { "kind": "youtube#channelListResponse", "etag": "\"p4VTdlkQv3HQeTEaXgvLePAydmU/zJL80hJ0IwMo5wddECFapC8I6Q4\"", "pageInfo": { "totalResults": 0, "resultsPerPage": 5 }, "items": [] }.
Are smaller users not supposed to be returned from this endpoint? If so, is there any way I can implement users to search for their profile without forcing the user to do the OAuth process, i.e. signing into their Youtube account?
It seems that using the /search endpoint works better for smaller channels, though there is less information available in this endpoint (I am unable to get subscriber count and video count, which was included in the "statistics" part of the /channel endpoint).
So updating
https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics&forUsername=Audrey_Chopin&key=[YOUR_API_KEY]
to
https://www.googleapis.com/youtube/v3/search?part=snippet&channelType=any&maxResults=50&order=relevance&q=Audrey%20Chopin&type=channel&key=[YOUR_API_KEY]
yielded smaller channels, though without as much data as when using the /channel endpoint.
Still curious, if anybody knows, why the /channel endpoint does not return smaller channels.
Since you know the user's channel id, simply issue a query to the Channels endpoint on the URL:
https://www.googleapis.com/youtube/v3/channels?part=...&id=$CHANNEL_ID&key=$APP_KEY,
and you'll obtain all public (i.e. non-private) info attached to the referenced channel -- without needing any further authentication. Of course you can specify the part parameter as you see fit.
On the other hand, please note that querying the Search.List endpoint for snippet part is much more costly than querying the Channels.List endpoint for both snippet and statistics parts: 100 vs. 5 quota points.

How do we get to know to which response user has reacted(like/dislike) on MS teams?

We need help in understanding how Microsoft teams like and dislike works with BotFramework. When user clicks on like option provided in background we are getting reactionID but how do we get to know for which specific message user has given his feedback. Do we have this feasibility on Teams?
You can find it in the replyToId. Example from the docs:
The messageReaction event is sent when a user adds or removes his or her reaction to a message which was originally sent by your bot. replyToId contains the ID of the specific message.
{
"reactionsAdded": [
{
"type": "like"
}
],
"type": "messageReaction",
"timestamp": "2017-10-16T18:45:41.943Z",
"id": "f:9f78d1f3",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer-client-ss.msg/",
"from": {
"id": "29:1I9Is_Sx0O-Iy2rQ7Xz1lcaPKlO9eqmBRTBuW6XzkFtcjqxTjPaCMij8BVMdBcL9L_RwWNJyAHFQb0TRzXgyQvA",
"aadObjectId": "c33aafc4-646d-4543-9d4c-abd28e4d2110"
},
"conversation": {
"isGroup": true,
"id": "19:3629591d4b774aa08cb0887902eee7c1#thread.skype"
},
"recipient": {
"id": "28:f5d48856-5b42-41a0-8c3a-c5f944b679b0",
"name": "SongsuggesterLocal"
},
"channelData": {
"channel": {
"id": "19:3629591d4b774aa08cb0887902eee7c1#thread.skype"
},
"team": {
"id": "19:efa9296d959346209fea44151c742e73#thread.skype"
},
"tenant": {
"id": "72f988bf-86f1-41af-91ab-2d7cd011db47"
}
},
"replyToId": "1:19uJ8TZA1cZcms7-2HLOW3pWRF4nSWEoVnRqc0DPa_kY"
}
Note, however, that this replyToId is specific to Teams and I don't believe it will persist if you set it yourself. Once you have that, you can update the activity.
If you're trying to analyze which messages are reacted to, you might want to log the outgoing activity's Id and Text in TurnContext.OnSendActivities. Then, when a reaction comes in, you can use the new Activity Handler to handle the message and add the reaction to your log. I believe this would come in OnUnrecognizedActivityTypeAsync. This is similar to the previous link, update the activity.

Trustpilot invitation api weird result

Trying to create invitations using their API, I get a proper result back, however the status is "notsent". There is zero debug information to go by, so I'm wondering if anyone else has seen this and might have ideas for fixing the issue.
Here's an example of a response I got from their api:
{
"businessUnitId": "<business unit id here>",
"businessUserId": "<business user id here>",
"createdTime": "2018-10-02T09:58:35.135569Z",
"id": "<invitation id here>",
"locale": "da-DK",
"preferredSendTime": "2018-10-09T09:58:34Z",
"recipient": {
"email": "<email goes here>",
"name": "<name goes here>"
},
"redirectUri": "http://trustpilot.com",
"referenceId": "<our ref id>",
"replyTo": "trustpilot#boozt.com",
"sender": {
"email": "noreply.invitations#trustpilotmail.com",
"name": "Booztlet.com"
},
"sentTime": null,
"source": "InvitationApi",
"status": "notsent",
"tags": [],
"templateId": "57cfc1a660e1cc0620b53a38"
}
So, the NotSent status code is expected for new invitations. This is because invitations are sent asynchronously - at around the time you put in as your "preferredSendTime".
If you login to your account at https://businessapp.b2b.trustpilot.com/#/invitations/invitation-history, you should be able to see the invitation you created, and whether it was sent or not (since you specified October 9th as your preferredSendTime, the invitation will still be queued until that point)

POST google Places API - INVALID_REQUEST

{
"location": {
"lat": -33.8669710,
"lng": 151.1958750
},
"accuracy": 50,
"name": "Google Shoes!",
"phone_number": "(02) 9374 4000",
"address": "48 Pirrama Road, Pyrmont, NSW 2009, Australia",
"types": ["shoe_store"],
"website": "http://www.google.com.au/",
"language": "en-AU"
}
This one I tried and as well as other places without modifying the request structure with Indian places. I'm getting the following response:
{
"html_attributions": [],
"results": [],
"status": "INVALID_REQUEST"
}
I'm not getting exactly what is the Issue, please revert back for the solution.
Since you didn't specify, I'm assuming that you are trying to use the add places endpoint on the Places API described here in the documentation.
The most likely problem is that you neglected to include your API key in the request URL, which should look like this:
https://maps.googleapis.com/maps/api/place/add/json?key=YOUR_API_KEY
Note that this endpoint is deprecated and that Google may remove it altogether at some point in the future.

Event subject is missing for recruiting events when use "delta" to get

When I use
GET https://graph.microsoft.com/v1.0/me/calendarview?startdatetime={today}&enddatetime={next-week}
I can get event subject no matter it is one-time or recruiting events.
However, when I use "delta"
GET https://graph.microsoft.com/v1.0/me/calendarview/delta?startdatetime={today}&enddatetime={next-week}
One-time events have subject while recruiting events do not have subject. Below is one of recruiting events I got:
{
"#odata.type": "#microsoft.graph.event",
"#odata.etag": "W/\"DwAAABYAAACpTc/InBsuTYwTUBb+VIb4AAB0+Esn\"",
"seriesMasterId": "AAMkADBlZTUwNTkxLWVmODgtNDVhNC1iZjhlLTdjNjA1ODZlMDI5MgBGAAAAAACUbnk-iwQZRbXMgkfKtmYhBwCpTc-InBsuTYwTUBb_VIb4AAAAAAENAACpTc-InBsuTYwTUBb_VIb4AAAUHFHiAAA=",
"type": "occurrence",
"start": {
"dateTime": "2017-09-19T05:00:00.0000000",
"timeZone": "UTC"
},
"end": {
"dateTime": "2017-09-19T06:00:00.0000000",
"timeZone": "UTC"
},
"id": "AAMkADBlZTUwNTkxLWVmODgtNDVhNC1iZjhlLTdjNjA1ODZlMDI5MgFRAAgI1P7xXviAAEYAAAAAlG55P4sEGUW1zIJHyrZmIQcAqU3PyJwbLk2ME1AW-lSG_AAAAAABDQAAqU3PyJwbLk2ME1AW-lSG_AAAFBxR4gAAEA=="
}
Is it a bug?
What I see is that using the /delta causes me to get each occurrence in the view as a much smaller entity, but I also get the corresponding series master, which has the full details. So in this case, you would get the subject from the master.
So for entities with "type": "occurrence", you would look at the seriesMasterId, which should correspond to the id of another entity in your response. You can then pull properties like subject and body from that.

Resources