Deeplinking into a telegram bot - telegram

I have a simple use case. When a user clicks the link below,
T.me/MycompanynameBot?start=Microsoft
I want to show him 3 inline buttons corresponding to 3 Telegram channels within Microsoft. Is this possible?
The key is the bot must be able to retrieve the parameters from the URL.
Thank you.

Yes it's possible to retrieve bot parameter via answerCallbackQuery
Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via #Botfather and accept the terms. Otherwise, you may use links like:
t.me/your_bot?start=XXXX
that open your bot with a parameter.
Here is an example I made for you :
{
"ok": true,
"result": [{
"update_id": 89590932,
"message": {
"message_id": 5978,
"from": {
"id": 223110107,
"is_bot": false,
"first_name": "Ğąme",
"last_name": "Ǿver!",
"username": "GameO7er",
"language_code": "en"
},
"chat": {
"id": 223110107,
"first_name": "Ğąme",
"last_name": "Ǿver!",
"username": "GameO7er",
"type": "private"
},
"date": 1579094448,
"text": "/start Microsoft",
"entities": [{
"offset": 0,
"length": 6,
"type": "bot_command"
}]
}
}]
}
As you can see type=bot_command so you can parse the message if (type == "bot_command") and get text and substring /start from the original text or what ever you want to do.
In many cases I detect users with the parameters for example when I wanna to know who invited this user to bot I share the link in this format:
t.me/NameBot?start=ReferUserID
for example :
t.me/NameBot?start=223110107
is my ID and I can see how many user I've invited to the bot.
Hope be useful.

Related

Find and delete Discord webhook message

I'm using a Discord webhook to send information which may later be invalidated, so I want to be able to delete it. To do this i use these endpoints:
First i make a post request to send a message:
POST /webhooks/{webhook.id}/{webhook.token}
And then i want to do a delete request to remove the message again:
DELETE /webhooks/{webhook.id}/{webhook.token}/messages/{message.id}
However I don't have the ID of the message i want to delete, since no response is given to the first POST request which is always an empty 204 response. Is it possible to get the message id?
Any help would be appreciated.
Per this reddit post:
If you need to reference a message ID of a webhook message you sent, you can add ?wait=true to the end of the URL which will give you the message data (including the ID) instead of a 204 (No Content) when you don't include the query parameter.
So if you send your normal POST request to your url like this: POST /webhooks/{webhook.id}/{webhook.token}, add ?wait=true to the end of that. Then you will get back data like this:
{
"id": "MESSAGEID",
"type": 0,
"content": "This is a test",
"channel_id": "CHANNELID",
"author": {
"bot": true,
"id": "AUTHORID",
"username": "USERNAME",
"avatar": "AVATARID",
"discriminator": "0000"
},
"attachments": [],
"embeds": [],
"mentions": [],
"mention_roles": [],
"pinned": false,
"mention_everyone": false,
"tts": false,
"timestamp": "2021-11-13T18:10:24.412000+00:00",
"edited_timestamp": null,
"flags": 0,
"components": [],
"webhook_id": "WEBHOOKID"
}

Does the RingCentral Call Log API Return a "Missed" Value?

In the RingCentral Online Account Portal (https://service.ringcentral.com) and endpoint apps, the call log display shows whether a call was Inbound, Outbound or Missed.
In looking at the API Reference for the Call Log API, it seems that it only sends back Inbound or Outbound for "Direction". Does the developer Call Log API return a "Missed" value? Is there another way to get this information via the Call Log API?
Ref: https://developer.ringcentral.com/api-docs/latest/index.html#!#RefCallLog.html
This question appears to be in reference to the Online Account Portal UI's "Type" column as shown in this screenshot:
The web UI's "Type" column shows Inbound, Outbound or Missed. This can be generated by using the response properties for both direction and result.
direction API response property will be Inbound or Outbound
result API response property is an enumerated value that includes Missed and other values including Voicemail which is the example screenshot. A full list is available in the link below:
Ref: https://developer.ringcentral.com/api-docs/latest/index.html#!#ResultStatusValues
Here is an example response:
{
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/call-log?view=Simple&showBlocked=true&withRecording=false&dateFrom=2018-08-27T06:18:00.000Z&page=1&perPage=100",
"records": [
{
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/call-log/22222222?view=Simple",
"id": "22222222",
"sessionId": "33333333",
"startTime": "2018-08-27T17:38:12.634Z",
"duration": 27,
"type": "Voice",
"direction": "Inbound",
"action": "Phone Call",
"result": "Missed",
"to": {
"phoneNumber": "+16505550101"
},
"from": {
"phoneNumber": "+16505550102",
"name": "LOS ALTOS CA",
"location": "Los Altos, CA"
}
}
],
...
}
Please read this blog to find out more information you can find from the call log.

How to get Google Analytics dimension/metric description in multi-language?

I am using this API to get a list of dimensions/metrics from Google Analytics: https://developers.google.com/apis-explorer/#s/analytics/v3/analytics.metadata.columns.list?reportTy..., however, I just realized the API only supports 'uiName', 'description' in English! is that true? is there any work around to support multi-language? Thanks!
"items": [
{
"id": "ga:userType",
"kind": "analytics#column",
"attributes": {
"type": "DIMENSION",
"dataType": "STRING",
"group": "User",
"status": "PUBLIC",
"uiName": "User Type",
"description": "A boolean, either New Visitor or Returning Visitor, indicating if the users are new or returning.",
"allowedInSegments": "true",
"addedInApiVersion": "3"
}
That is true the Meta data api only returns data in english. You are going to have to translate the metadata names to your chosen language yourself after you have downloaded the data you need

Google Analytics Experiments always chooses original variation?

I'm setting up a multivariate test through Google Analytics. I created the experiment through the API, and everything is looking like its running, however, only the original is being selected and the variants aren't being served.
I've tried using incognito windows, and had a few other people visit the page as well, but everyone receives a page with ?utm_expid=XXXXXXXX-XX.YYYYYYYYYYYYYYYYYY.0 on the end, where the .0 seems to indicate "show original."
Any ideas why an experiment might always show the original? Here's my experiment as retrieved through the API.
{
"id": "YYYYYYYYYYYYYYYYYYYYY",
"kind": "analytics#experiment",
"accountId": "AAAAAAAA",
"webPropertyId": "UA-ZZZZZZZZZ-0",
"profileId": "XXXXXXXX",
"name": "Product Page - Grid Content",
"description": "Test of product page grid content.",
"created": "2013-11-22T15:53:32.634Z",
"updated": "2013-11-22T16:27:15.406Z",
"objectiveMetric": "ga:timeOnSite",
"optimizationType": "MAXIMUM",
"status": "RUNNING",
"startTime": "2013-11-22T16:00:37.367Z",
"rewriteVariationUrlsAsOriginal": true,
"winnerConfidenceLevel": 0.95,
"minimumExperimentLengthInDays": 7,
"trafficCoverage": 1,
"equalWeighting": true,
"variations": [{
"name": "Newest Products (Original)",
"url": "http://mystore.com/product/pastel-lipstick",
"status": "ACTIVE",
"weight": 0
}, {
"name": "Most Popular Products",
"url": "?",
"status": "ACTIVE",
"weight": 0
}, {
"name": "Related Products",
"url": "?",
"status": "ACTIVE",
"weight": 0
}],
"servingFramework": "REDIRECT",
"editableInGaUi": true
}
UPDATE:
I've suspected this might have something to do with those weight: 0 fields under variations[]. I'm not entirely sure why they appear as weight: 0, or whether that actually prevents variations from showing.
Originally, I wanted to set url: "?" for my variations because I wanted to avoid polluting my query string. Instead of using different URLs/query string variables to determine which variation to show, I used the utm_expid query string variable the GA Experiment redirect adds to determine which variation to show. Although the API accepted these URLs without issue, I'm not sure they're actually considered 'valid.' So I tried changing the URLs to be ?mvt=1 and ?mvt=2 respectively, and saw the weights changed to 0.3333 and variations serve.
Although changing the URL seems to work, does anyone have a thorough explanation for what or why this is happening?
There is an open issue on this https://code.google.com/p/analytics-issues/issues/detail?id=377. If you subscribe to that then you'll get notified when it's fixed.

How to "Add guest" to event via google calendar API?

could you please give me a hint on how to share a single event via google calendar api?
That is I'd like to invite other users to see the event programmatically without sharing the whole calendar. To mimic the "Add guests" UI action
As Claudio mentioned, you need to use the Google Calendar Advanced API for this.
You'll want to use a patch because you don't want to replace all the other data on the calendar invite. However, even in the case of patch, since the attendees lives in an array, if you attempt to pass a patch such as this:
{
attendees: [ { email: "new#example.com"} ]
}
... it'll replace all old invitees (i.e. it'll remove anyone that was on the invite before you called patch). To fix this, you must first get the current invitees, add a new person to the array, and then send a patch.
You can see a detailed example of this in this answer which also explains how to use Google Apps Scripting to ensure an email is sent to the user when adding them to a calendar event (see the addGuestAndSendEmail() method in that post).
You can use the API to add people to the attendees collection:
https://developers.google.com/google-apps/calendar/v3/reference/events/update
refer the following request.
method: POST
endpoint: https://www.googleapis.com/calendar/v3/calendars/primary/events?sendUpdates=all
here, sendUpdates means when you add any guest so he would get an invitation mail used based on scenario.
Input Json:
{
"kind": "calendar#event",
"etag": "etag",
"status": "confirmed",
"summary": "JayKara",
"description": "eqwbdjhwhhwhhwrhjehrhejhfj",
"location": "America",
"creator": {
"email": "#mail.com",
"self": true
},
"organizer": {
"email": "#mail.com",
"self": true
},
"start": {
"date": "2019-12-23"
},
"end": {
"date": "2019-12-24"
},
"originalStartTime": {
"date": "2019-12-24"
},
"visibility": "public",
"attendees": [
{
"email": "****#mail.com" //this guys are the guest
}
]
}.
After that there is no patch method required your guest guys will receive an invitation whenever update event
Cheers!

Resources