Which alert timestamp (createTime or endTime) correlates to the time an email was "REMOVED_FROM_INBOX" - google-admin-sdk

Is anyone aware of which timestamp presented in alerts correlates to the actual time the email was removed from the inbox if the systemActionType states "REMOVED_FROM_INBOX"?
My question is specific to the "Gmail phishing" alert source (https://developers.google.com/admin-sdk/alertcenter/reference/alert-types). I have yet to see an endTime that is after the alerts createTime for Phishing reclassification and a review of the alert-types page and definitions makes me assume createTime is the correct time to utilize...... however that makes me confused on why there is an endTime being populated for these types.
Key/Value
Description
Phishing reclassification
Unopened messages that are detected as phishing post-delivery are automatically reclassified and removed from the user's inbox.
createTime
Output only. The time this alert was created.
endTime
Optional. The time the event that caused this alert ceased being active. If provided, the end time must not be earlier than the start time. If not provided, it indicates an ongoing alert.
Sample Alert
"customerId": "<removed>",
"alertId": "<removed>",
"createTime": "2021-03-11T18:25:47.538082Z",
"startTime": "2021-03-11T13:19:50.374062Z",
"endTime": "2021-03-11T17:53:54.482936Z",
"type": "Phishing reclassification",
"source": "Gmail phishing",
"data": {
"#type": "type.googleapis.com/google.apps.alertcenter.type.MailPhishing",
"domainId": {
"customerPrimaryDomain": "<removed>"
},
"maliciousEntity": {
"fromHeader": "<removed>"
},
"messages": [
{
"messageId": "<removed>",
"md5HashMessageBody": "<removed>",
"md5HashSubject": "<removed>",
"attachmentsSha256Hash": [
"<removed>"
],
"recipient": "<removed>",
"date": "2021-03-11T13:19:50.374062Z"
}
],
"isInternal": true,
"systemActionType": "REMOVED_FROM_INBOX"
},
"metadata": {
"customerId": "<removed>",
"alertId": "<removed>",
"status": "NOT_STARTED",
"updateTime": "2021-03-11T18:25:47.538082Z",
"severity": "MEDIUM",
"etag": "<removed>"
}
API Link if you so desire: https://developers.google.com/admin-sdk/alertcenter/reference/rest/v1beta1/alerts

Answer:
In Phishing reclassification alerts, the date when each message was removed from inbox (when it was reclassified) corresponds to the date field in each message:
{
"data": {
"messages": [
{
"date": "2021-03-11T13:19:50.374062Z"
}
]
}
}
You will notice that it corresponds to the date in startTime. That’s because startTime corresponds to the date when the first message in the report was reclassified (since that’s the first and only reclassified message in this alert).
Reported in Issue Tracker:
The documentation at GmailMessageInfo is not clear on this, since date corresponds to The date the malicious email was sent only in some alert types.
Therefore, I reported a documentation bug in Issue Tracker:
[Alert Center API] Description of date in GmailMessageInfo not meaningful for all alert types

Related

searchContacts with phone number query is broken

Using the [searchContacts API method] (https://developers.google.com/people/api/rest/v1/people/searchContacts) used to support searching by telephone number - indeed this is called out in the documentation:
The query matches on a contact's names, nickNames, emailAddresses, phoneNumbers, and organizations fields that are from the CONTACT source.
It no longer returns results when using a phone number as the query. Is this deliberate, or a bug?
As per google people api search by phonenumbers I have tried a query of "canonical format without plus". I have also tried "canonical format with plus" and "exact number as stored".
Name query still works
https://people.googleapis.com/v1/people:searchContacts?readMask=names%2cphoneNumbers&query=Go Ogle&pageSize=30
returns
{
"results": [
{
"person": {
"resourceName": "people/c832768086350305259",
"etag": "%EgcBAgsuNz0/GgECIgwxZGVYd20reHpEUT0=",
"names": [
{
"metadata": {
"primary": true,
"source": {
"type": "CONTACT",
"id": "b8e96298f3117eb"
}
},
"displayName": "Go Ogle",
"familyName": "Ogle",
"givenName": "Go",
"displayNameLastFirst": "Ogle, Go",
"unstructuredName": "Go Ogle"
}
],
"phoneNumbers": [
{
"metadata": {
"primary": true,
"source": {
"type": "CONTACT",
"id": "b8e96298f3117eb"
}
},
"value": "020 7031 3000",
"canonicalForm": "+442070313000"
}
]
}
}
]
}
Phone number query fails
https://people.googleapis.com/v1/people:searchContacts?readMask=names%2cphoneNumbers&query=442070313000&pageSize=30
returns
{}
The query function does indeed seem to be broken at the moment. My tests gave the same results and the question you linked shows that it clearly worked in the past.
I found a bug report on Google's issue tracker. A Googler already replied to it saying that they were able to reproduce it and filed an internal report. It's a matter of time until they fix it so you may want to keep track of that thread or post on it yourself to apply some pressure.
The bug didn't went away although they say it was closed and verified
In order to get the same functionality I had to be creative, the documentation says:
The query matches on a contact's names, nickNames, emailAddresses,
phoneNumbers, and organizations fields that are from the CONTACT
source.
The names, emailAddresses, phoneNumbers and organizations are important fields where you don't want to have garbage, but on my case at least the nickNames had no usage, so I simply add the phone number as nick name and the search works like charm.
Keep in mind that if you have many previous contacts you will have to write a script that will copy their phone number to the one of the nicknames fields.
Enjoy :)

How do I extract a string of numbers from random text in Power Automate?

I am setting up a flow to organize and save emails as PDF in a Dropbox folder. The first email that will arrive includes a 10 digit identification number which I extract along with an address. My flow creates a folder in Dropbox named in this format: 2023568684 : 123 Main St. Over a few weeks, additional emails arrive that I need to put into that folder. The subject always has a 10 digit number in it. I was building around each email and using functions like split, first, last, etc. to isolate the 10 digits ID. The problem is that there is no consistency in the subjects or bodies of the messages to be able to easily find the ID with that method. I ended up starting to build around each email format individually but there are way too many, not to mention the possibility of new senders or format changes.
My idea is to use List files in folder when a new message arrives which will create an array that I can filter to find the folder ID the message needs to be saved to. I know there is a limitation on this because of the 20 file limit but that is a different topic and question.
For now, how do I find a random 10 digit number in a randomly formatted email subject line so I can use it with the filter function?
For this requirement, you really need regex and at present, PowerAutomate doesn't support the use of regex expressions but the good news is that it looks like it's coming ...
https://powerusers.microsoft.com/t5/Power-Automate-Ideas/Support-for-regex-either-in-conditions-or-as-an-action-with/idi-p/24768
There is a connector but it looks like it's not free ...
https://plumsail.com/actions/request-free-license
To get around it for now, my suggestion would be to create a function app in Azure and let it do the work. This may not be your cup of tea but it will work.
I created a .NET (C#) function with the following code (straight in the portal) ...
#r "Newtonsoft.Json"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
string strToSearch = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String((string)data?.Text));
string regularExpression = data?.Pattern;
var matches = System.Text.RegularExpressions.Regex.Matches(strToSearch, regularExpression);
var responseString = JsonConvert.SerializeObject(matches, new JsonSerializerSettings()
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
});
return new ContentResult()
{
ContentType = "application/json",
Content = responseString
};
}
Then in PowerAutomate, call the HTTP action passing in a base64 encoded string of the content you want to search ...
The is the expression in the JSON ... base64(variables('String to Search')) ... and this is the json you need to pass in ...
{
"Text": "#{base64(variables('String to Search'))}",
"Pattern": "[0-9]{10}"
}
This is an example of the response ...
[
{
"Groups": {},
"Success": true,
"Name": "0",
"Captures": [],
"Index": 33,
"Length": 10,
"Value": "2023568684"
},
{
"Groups": {},
"Success": true,
"Name": "0",
"Captures": [],
"Index": 98,
"Length": 10,
"Value": "8384468684"
}
]
Next, add a Parse JSON action and use this schema ...
{
"type": "array",
"items": {
"type": "object",
"properties": {
"Groups": {
"type": "object",
"properties": {}
},
"Success": {
"type": "boolean"
},
"Name": {
"type": "string"
},
"Captures": {
"type": "array"
},
"Index": {
"type": "integer"
},
"Length": {
"type": "integer"
},
"Value": {
"type": "string"
}
},
"required": [
"Groups",
"Success",
"Name",
"Captures",
"Index",
"Length",
"Value"
]
}
}
Finally, extract the first value that you find which matches the regex pattern. It returns multiple results if found so if you need to, you can do something with those.
This is the expression ... #{first(body('Parse_JSON'))?['value']}
From this string ...
We're going to search for string 2023568684 within this text and we're also going to try and find 8384468684, this should work.
... this is the result ...
Don't have a Premium PowerAutomate licence so can't use the HTTP action?
You can do this exact same thing using the LogicApps service in Azure. It's the same engine with some slight differences re: connectors and behaviour.
Instead of the HTTP, use the Azure Functions action.
In relation to your action to fire when an email is received, in LogicApps, it will poll every x seconds/minutes/hours/etc. rather than fire on event. I'm not 100% sure which email connector you're using but it should exist.
Dropbox connectors exist, that's no problem.
You can export your PowerAutomate flow into a LogicApps format so you don't have to start from scratch.
https://learn.microsoft.com/en-us/azure/logic-apps/export-from-microsoft-flow-logic-app-template
If you're concerned about cost, don't be. Just make sure you use the consumption plan. Costs only really rack up for these services when the apps run for minutes at a time on a regular basis. Just keep an eye on it for your own mental health.
TO get the function URL, you can find it in the function itself. You have to be in the function ...

Amazon Product Advertising API v5 - How to retrieving different type of books (hardcopy, paperback, kindle... ) with one API call

I’m a developer for a company where we’re using Amazon's great product advertising API (PA-API) for a many years for fetching book information. We’re currently using the Java SDK and API v5.
Issue
We provide our customers directly links with our affiliate to the related hardcopy or ebook on different Amazon stores. We do this by creating a SearchItems documentation request with the ISBN (example 9780399562396) as the keyword and no specific search index. In the past we got a response back with two items and therefore two ASINs, one for the hardcopy and one for the ebook (distinguishable by the itemInfo’s product group). However, since some time we had to recognize that the response only contains normally one item, the hard copy product.
I have already tried different approaches with the great Scratchpad.
Questions
The interesting thing is that when I explicitly include the search index (more information here) “Books” or “KindleStore” the API is responding with the expected item (for "books" with a book and for "KindleStore" with a kindle). We do that by having a look at the ItemInfo.Classifications (more information here) However, if I search in the index “All” or don’t specified it, it returns only one item (normally the hardcopy). Which seems to me quite strange… Should the API/search index even behave like this?
Furthermore, I was not able to figure out how to search in to indexes within the same request and it seems to me that this is not supported at all but I would expect that at least this would then return two items…
Therefore, I would like ask you if somebody has an explanation for us to retrieve with one request both ASINs (kindle + hard copy book) of the same ISBN. Of course it is possible to create two separate requests for each product group, however since the API rates are tied to the shipped item revenue, we would like to avoid unnecessary API requests.
Some examples with and without the usage of the explicit usage of the search index
In the following example I looking for the hardcopy or kindle of the book with ISBN 9780262043649 by doing a SearchItem request.
a) Hardcopy with given search index
Payload
{
"Keywords": "9780262043649",
"Resources": [
"ItemInfo.Classifications",
"ItemInfo.Title"
],
"SearchIndex": "Books",
"PartnerTag": "*********",
"PartnerType": "Associates",
"Marketplace": "www.amazon.com",
"Operation": "SearchItems"
}
Response
{
"SearchResult": {
"Items": [
{
"ASIN": "0262043645",
"DetailPageURL": "https://www.amazon.com/dp/0262043645?tag=getabstractcom&linkCode=osi&th=1&psc=1",
"ItemInfo": {
"Classifications": {
"Binding": {
"DisplayValue": "Hardcover",
"Label": "Binding",
"Locale": "en_US"
},
"ProductGroup": {
"DisplayValue": "Book",
"Label": "ProductGroup",
"Locale": "en_US"
}
},
"Title": {
"DisplayValue": "Novacene: The Coming Age of Hyperintelligence (The MIT Press)",
"Label": "Title",
"Locale": "en_US"
}
}
}
],
"SearchURL": "https://www.amazon.com/s?k=9780262043649&i=stripbooks&rh=p_n_availability%3A-1&tag=getabstractcom&linkCode=osi",
"TotalResultCount": 1
}
}
b) Kindle with given search index
Payload
{
"Keywords": "9780262043649",
"Resources": [
"ItemInfo.Classifications",
"ItemInfo.Title"
],
"SearchIndex": "KindleStore",
"PartnerTag": "******",
"PartnerType": "Associates",
"Marketplace": "www.amazon.com",
"Operation": "SearchItems"
}
Response
{
"SearchResult": {
"Items": [
{
"ASIN": "B08BT4MM18",
"DetailPageURL": "https://www.amazon.com/dp/B08BT4MM18?tag=getabstractcom&linkCode=osi&th=1&psc=1",
"ItemInfo": {
"Classifications": {
"Binding": {
"DisplayValue": "Kindle Edition",
"Label": "Binding",
"Locale": "en_US"
},
"ProductGroup": {
"DisplayValue": "Digital Ebook Purchas",
"Label": "ProductGroup",
"Locale": "en_US"
}
},
"Title": {
"DisplayValue": "Novacene: The Coming Age of Hyperintelligence",
"Label": "Title",
"Locale": "en_US"
}
}
}
],
"SearchURL": "https://www.amazon.com/s?k=9780262043649&i=digital-text&rh=p_n_availability%3A-1&tag=getabstractcom&linkCode=osi",
"TotalResultCount": 1
}
}
c) No specific search index
Payload
{
"Keywords": "9780262043649",
"Resources": [
"ItemInfo.Classifications",
"ItemInfo.Title"
],
"PartnerTag": "*******",
"PartnerType": "Associates",
"Marketplace": "www.amazon.com",
"Operation": "SearchItems"
}
Response
{
"SearchResult": {
"Items": [
{
"ASIN": "B08BT4MM18",
"DetailPageURL": "https://www.amazon.com/dp/B08BT4MM18?tag=getabstractcom&linkCode=osi&th=1&psc=1",
"ItemInfo": {
"Classifications": {
"Binding": {
"DisplayValue": "Kindle Edition",
"Label": "Binding",
"Locale": "en_US"
},
"ProductGroup": {
"DisplayValue": "Digital Ebook Purchas",
"Label": "ProductGroup",
"Locale": "en_US"
}
},
"Title": {
"DisplayValue": "Novacene: The Coming Age of Hyperintelligence",
"Label": "Title",
"Locale": "en_US"
}
}
}
],
"SearchURL": "https://www.amazon.com/s?k=9780262043649&rh=p_n_availability%3A-1&tag=getabstractcom&linkCode=osi",
"TotalResultCount": 1
}
}
Research/Further information
Documentation of the API
Search Index of Amazon
Scratchpad
Many thanks for any advice.

Utterances to test lambda function not working (but lambda function itself executes)

I have a lambda function that executes successfully with an intent called GetEvent that returns a specific string. I've created one utterance for this intent for testing purposes (one that is simple and doesn't require any of the optional slots for invoking the skill), but when using the service simulator to test the lambda function with this utterance for GetEvent I'm met with a lambda response that says "The response is invalid". Here is what the interaction model looks like:
#Intent Schema
{
"intents": [
{
"intent": "GetVessel",
"slots": [
{
"name": "boat",
"type": "LIST_OF_VESSELS"
},
{
"name": "location",
"type": "LIST_OF_LOCATIONS"
},
{
"name": "date",
"type": "AMAZON.DATE"
},
{
"name": "event",
"type": "LIST_OF_EVENTS"
}
]
},
{
"intent": "GetLocation",
"slots": [
{
"name": "event",
"type": "LIST_OF_EVENTS"
},
{
"name": "date",
"type": "AMAZON.DATE"
},
{
"name": "boat",
"type": "LIST_OF_VESSELS"
},
{
"name": "location",
"type": "LIST_OF_LOCATIONS"
}
]
},
{
"intent": "GetEvent",
"slots": [
{
"name": "event",
"type": "LIST_OF_EVENTS"
},
{
"name": "location",
"type": "LIST_OF_LOCATIONS"
}
]
}
]
}
With the appropriate custom skill type syntax and,
#First test Utterances
GetVessel what are the properties of {boat}
GetLocation where did {event} occur
GetEvent get me my query
When giving Alexa the utterance get me my query the lambda response should output the string as it did in the execution. I'm not sure why this isn't the case; this is my first project with the Alexa Skills Kit, so I am pretty new. Is there something I'm not understanding with how the lambda function, the intent schema and the utterances are all pieced together?
UPDATE: Thanks to some help from AWSSupport, I've narrowed the issue down to the area in the json request where new session is flagged as true. For the utterance to work this must be set to false (this works when inputting the json request manually, and this is also the case during the lambda execution). Why is this the case? Does Alexa really care about whether or not it is a new session during invocation? I've cross-posted this to the Amazon Developer Forums as well a couple of days ago, but have yet to get a response from someone.
This may or may not have changed -- the last time I used the service simulator (about two weeks ago at the time of writing) it had a pretty severe bug which would lead to requests being mapped to your first / wrong intent, regardless of actual simulated speech input.
So even if you typed in something random like wafaaefgae it simply tries to map that to the first intent you have defined, providing no slots to said intent which may lead to unexpected results.
Your issue could very well be related to this, triggering the same unexpected / buggy behavior because you aren't using any slots in your sample utterance
Before spending more time debugging this, I'd recommend trying the Intent using an actual echo or alternatively https://echosim.io/ -- interaction via actual speech works as expected, unlike the 'simulator'

Shares count of Graph API

Regarding Graph API, shares count of post, shares count of post's insights and shares count displayed on page are not identical. I've assumed that these represent same count. Is my assumption wrong?
From post:
https://graph.facebook.com/XXXX_YYYY
{
"id" : "XXXX_YYYY",
...
"shares": {
"count": 1 !!!!!
}
...
}
From post's insights:
https://graph.facebook.com/XXXX_YYYY/insights
[
...
{
"id": "XXXX_YYYY/insights/post_storytellers_by_action_type/lifetime",
"name": "post_storytellers_by_action_type",
"period": "lifetime",
"values": [
{
"value": {
"like": 90,
"share": 14, !!!!!
"comment": 10
}
}
],
"title": "Lifetime Talking About This (Post) by action type",
"description": "Lifetime The number of unique people who created a story about your Page post, by action type. (Unique Users)"
}
...
]
On facebook page: 4 shares !!!!!
Thanks.
I see the same problem on my side, api has had many issues since 2012 started (at least for me) , I think you have better luck reporting this as a bug on Facebook, they can give you a better insight and solve the problem on their side
Url : Facebook Bugs