Triggering Google Now Cards using email schemas: Cards don't show up - google-schemas

I inserted schema into an email that confirms an event registration in JSON-LD format. I mailed this to myself using Google AppScript. But I'm unable to see the triggered card in Google Now. The markup has been verified by Google's markup tester and is valid.
<html>
<body>
<script type="application/ld+json">
{
"#context" : "http://schema.org",
"#type" : "EventReservation",
"reservationNumber" : "SDCC12345",
"reservationFor" : {
"#type" : "Event",
"name" : "San Diego Comic Con 2014",
"startDate" : "2014-07-29T08:30",
"location" : {
"#type" : "Place",
"name" : "San Diego Convention Center",
"address" : {
"#type" : "PostalAddress",
"streetAddress" : "111 West Harbor Drive",
"addressLocality" : "San Diego",
"addressRegion" : "California",
"addressCountry": "USA"
}
}
},
"underName" : {
"#type" : "Person",
"name" : "Jon Snow"
},
"reservationStatus": "confirmed"
}
</script>
<p>
Dear Jon, thanks for booking your San Diego Comic Con ticket with us.
</p>
<p>
BOOKING DETAILS<br/>
Order for: Jon Snow<br/>
Event: San Diego Comic Con 2014<br/>
When: July 27th 2014 8:30am PST<br/>
Venue: 111 West Harbor Drive, San Diego,California<br/>
Reservation number: SDCC12345<br/>
</p>
</body>
</html>
What could be the problem here?

Your code has a slightly different structure to mine, but mine has worked. The parts where there are obvious differences are:
The order of the elements
The reservation status value format
The start date value format
The order shouldn't matter, so skip that for now, and try changing your status value to be:
"reservationStatus": "http://schema.org/ReservationConfirmed",
Then change your Start Date value format to include a timezone, similar to:
"startDate": "2015-04-25T15:00:00-00:00",
If that doesn't make it work, try ordering your data to the following order:
Event type
Confirmed status
Under Name
Reservation For
Cheers,
Conor

Related

retrieve unique data from firebase

I have some information being sent to firebase. In my app, users enter info about themselves and it's stored under the uids. Here is the hierarchy:
{
"gJRhIOfmckTq9cRWNnwhg7tdxxv1" : {
"City" : "New York, New York",
"College" : "New York University of New York",
"Major" : "Nursing",
"uid" : "gJRhIOfmckTq9cRWNnwhg7tdxxv1"
},
"ix7JSoW5JZMSmDjwQRUUd8W7fi2" : {
"City" : "Miami, Florida",
"College" : "University of Miami",
"Major" : "Neuroscience ",
"uid" : "ix7JSoW5JZMSmDjwQRUUd8W7fi2"
}
}
Here is the path to uploading the data:
FIRDatabase.database().reference().child("info").child(self.loggedInUser!.uid)
.observeSingleEvent(of: .value, with: { (snapshot:FIRDataSnapshot) in
The issue is that when a particular user is logged in, they should be able to see other user's information but when I try to retrieve the not logged in user's information, I run into a problem because of the uid. I get only the logged in user's information displayed in the non-logged in user information page. How can I make .child(self.loggedInUser!.uid)so that it does not only capture the logged in user's uid but all uids.
Based on your response to my comment, it seems like you need all of the information about a user when, say, their profile is selected. This is where denormalization will come in handy. This blog post and this YouTube video go into detail on the what and why of denormalization, so I won't get into that too much here.
Using denormalization, you could include a child that lists all users with a username as a key and the user's uid as the value. Then when a user selects that user by username, say from a list in a table, you can find the user's uid and then listen to the value of the user's profile. The database structure would be something like this:
{
users: {
"thisperson": "gJRhIOfmckTq9cRWNnwhg7tdxxv1",
"anotherperson": "ix7JSoW5JZMSmDjwQRUUd8W7fi2",
...
},
info: {
"gJRhIOfmckTq9cRWNnwhg7tdxxv1" : {
"City" : "New York, New York",
"College" : "New York University of New York",
"Major" : "Nursing",
"uid" : "gJRhIOfmckTq9cRWNnwhg7tdxxv1"
},
"ix7JSoW5JZMSmDjwQRUUd8W7fi2" : {
"City" : "Miami, Florida",
"College" : "University of Miami",
"Major" : "Neuroscience ",
"uid" : "ix7JSoW5JZMSmDjwQRUUd8W7fi2"
},
...
}
}
Then instead of listening to the values for the logged in user, you listen for the value of the selected user's uid, then listen using that instead:
FIRDatabase.database().reference().child("info").child(otheruid)
.observeSingleEvent(of: .value, with: { (snapshot:FIRDataSnapshot) in
Where otheruid is the value of FIRDatabase.database().reference().child("users").child(username)

Google Markup not seen in e-mail

I test send markups with Google scripts and works find,
if send the same template via Google SMTP from my Gmail account to my Gmail account the ld+json don't see.
My template is:
<!DOCTYPE html>
<html>
<head>
<title>Prenotazine TiPrenota</title>
<meta charset="UTF-8">
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "EventReservation",
"reservationNumber": "5aa46b79-140d-491e-a1db-568ec1c423bd",
"reservationStatus": "http://schema.org/Confirmed",
"underName": {
"#type": "Person",
"name": "Savio Capannini"
},
"reservationFor": {
"#type": "Event",
"name": "SAN MARINO ADVENTURES SRL - COE 21269",
"startDate": "2017-03-27T12:30:00",
"location": {
"#type": "Place",
"name": "SAN MARINO ADVENTURES SRL - COE 21269",
"address": {
"#type": "PostalAddress",
"streetAddress": "San Marino Adventure Parco Montecerreto, San Marino (RSM)"
},
"geo": {
"#type": "GeoCoordinates",
"latitude": "44,490501",
"longitude": "12,281881"
}
},
"performer":"Reservation"
},
"modifyReservationUrl": "https://www.mysite.it/?token=5aa46b79-140d-491e-a1db-568ec1c423bd"
}
</script>
</head>
<body>
Testo emeil
</body>
</html>
Do I need a G Suite account to try this?
Why the markup is not seen?
Where is the problem?
Pleas help!
Thks.
You may refer with this SO post. Make sure that you registered with Google before you send emails to other users properly. Also, be noted that Emails must be authenticated via DKIM or SPF. If you're using Google SMTP relay, you have to use an SPF record looking like this: v=spf1 include:_spf.google.com ~all.
Here's another thread which might help: Gmail Email Markup not Working

How does google NOW parses E-Mail's, to generate NOW notifications - cards

How can I change the E-Mail header settings in the emails sent by a train company - e.g. Deutsche Bahn, so the mail receiver with Google now enabled would get a now card.
It works great with Amazon and flight bookings, but there seems no "Train or railway" Schema to exist so far?
I was testing out the TrainReservation schema the other day and I was able to generate a Now card using the sample below:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "TrainReservation",
"reservationNumber": "12345",
"reservationStatus": "http://schema.org/ReservationConfirmed",
"reservationFor": {
"#type": "TrainTrip",
"departureStation": {
"#type": "TrainStation",
"name": "Munich Central"
},
"departureTime": "2015-05-26T10:30:00+01:00",
"arrivalStation": {
"#type": "TrainStation",
"name": "Paris Gare De Lyon"
},
"arrivalTime": "2015-05-27T03:10:00+01:00"
},
"reservedTicket": {
"#type": "Ticket",
"underName": "Eva Green",
"ticketedSeat": {
"#type": "Seat",
"seatNumber": "27B",
"seatingType": "1st Class"
},
"ticketNumber": "123XYZ",
"ticketToken": "aztecCode:AB34",
"additionalTicketText": "We recommend that you arrive at the station at least 30 minutes prior to your scheduled departure. Allow additional time if you need help with baggage or tickets."
}
}
</script>
Here's a screenshot of the result on my HTC One Android device:
Note, that this will not appear in Gmail/Inbox like the FlightReservation. You will only be able to generate a Now card.

Mongoid and Mongodb querying

I have a data strcuture like this
Courses
{
"name" : "Course1",
"student_id"
"subjects" :
[{
"level" : "1",
"short_name" : "Maths",
"topics" : [{
"name" : "Algebra 101",
"week" : "1",
"submission_week" : ISODate("2013-07-28T00:00:00Z"),
"correction_week" : ISODate("2013-07-28T00:00:00Z")
},
{
"name" : "Algebra 201",
"week" : "1",
"submission_week" : ISODate("2013-07-28T00:00:00Z"),
"correction_week" : ISODate("2013-07-28T00:00:00Z")
}
]},
{
"level" : "2",
"short_name" : "Chem"
}
]
}
Using Mongoid I am trying to retrieve all topics.
I have tried all sorts of queries but cannot seem get it.
e.g I don't understand why this doesn't work?
Topic.where( name: "Algebra 101", 'subject.short_name' =>"Maths", 'subject.course.name' =>"Course1")
Can I query like this?
My ruby code is
class Course
embeds_many :subjects
class Subject
embedded_in :course
embeds_many :topics
class Topic
embedded_in :subject
A far as I know it's only possible to make such a query on the top-most model (in this case Course); I have not seen a way to directly obtain an embedded model like that yet.
So this should work, but only gives you the Course:
Course.where(name: 'Course1', 'subjects.short_name' => 'Maths', 'subjects.topics.name' => "Algebra 101")
And this is the (unfortunately rather ugly) query that should give you what you want:
Course.where(name: 'Course1').subjects.where(short_name: 'Maths').topics.where(name: 'Algebra 101')

MongoDB/Mongoid: Can one query for ObjectID in embedded documents?

For the record, I'm a bit of a newbie when it comes to Rails and MongoDB.
I'm using Rails+Mongoid+MongoDB to build an app and I've noticed that Mongoid adds ObjectID to embedded documents for some reason.
Is there any way to query all documents in a collection by ObjectID both the main documents and nested ones?
If I run this command
db.programs.findOne( { _id: ObjectId( "4d1a035cfa87b171e9000002" ) } )
I get these results which is normal since I'm querying for the ObjectID at root level.
{
"_id" : ObjectId("4d1a035cfa87b171e9000002"),
"created_at" : "Tue Dec 28 2010 00:00:00 GMT+0000 (GMT)",
"name" : "program",
"routines" : [
{
"name" : "Day 1",
"_id" : ObjectId("4d1a7689fa87b17f50000020")
},
{
"name" : "Day 2",
"_id" : ObjectId("4d1a7695fa87b17f50000022")
},
{
"name" : "Day 3",
"_id" : ObjectId("4d1a76acfa87b17f50000024")
},
{
"name" : "Day 4",
"_id" : ObjectId("4d1a76ecfa87b17f50000026")
},
{
"name" : "Day 5",
"_id" : ObjectId("4d1a7708fa87b17f50000028")
},
{
"name" : "Day 6",
"_id" : ObjectId("4d1a7713fa87b17f5000002a")
},
{
"name" : "Day 7",
"_id" : ObjectId("4d1a7721fa87b17f5000002c")
}
],
"user_id" : ObjectId("4d190cdbfa87b15c2900000a")
}
Now if I try to query with an ObjectID with one of the embedded document (routines) I get null like so.
db.programs.findOne( { _id: ObjectId( "4d1a7689fa87b17f50000020" ) } )
null
I know one can query embedded objects like so
db.postings.find( { "author.name" : "joe" } );
but that seems a bit redundant if you get passed an ObjectID of some sort and want to find in what document that ObjectID resides.
So I guess my question is this...
Is it possible, with some method I'm not familiar with, to query by ObjectID and search the ObjectID's in the embedded documents?
Thanks.
You can't query ObjectIDs globally like that. You would have to do
db.programs.find({"routines._id": ObjectId("4d1a7689fa87b17f50000020")})
no, you can search only by field like { "routines._id" : ObjectId("4d1a7689fa87b17f50000020")}
If you want to get the matched sub-document only you can use $elemMatch with '$' operator like below:
db.programs.find({"_id" : ObjectId("4d1a035cfa87b171e9000002"),
routines:{$elemMatch:{"_id" : ObjectId("4d1a7689fa87b17f50000020")}}},{"routines.$":1})
It will return you only that matched sub-document instead of the complete sub-document.

Resources