Sharing a photo with text - google-glass

The "Add a cat to that" example explains how to share a photo with my service.
But is there a way to share a photo with a text (using voice recorder) in a single item ?

Yup! You can do this using the REPLY built-in menu item.
However, the flow is a bit different than the Add a Cat to That flow. It works like this:
Subscribe to updates to the timeline collection.
Insert a timeline item with the REPLY built in action specified as shown here. Optionally, you can rename the menu item and customize the icon.
{
"text": "Hello world",
"menuItems": [
{
"action": "REPLY"
}
]
}
The timeline card will have a reply option in its menu. When the user selects it, they will be prompted to speak.
A new timeline card is then created which contains the text transcription and has an attached audio recording. Your Glassware has access to this card.
Your Glassware is then notified about this item insertion. The notification looks something like this:
{
"collection": "timeline",
"itemId": "3hidvm0xez6r8_dacdb3103b8b604_h8rpllg",
"operation": "INSERT",
"userToken": "harold_penguin",
"verifyToken": "random_hash_to_verify_referer",
"userActions": [
{
"type": "REPLY"
}
]
}
Fetch the indicated timeline item to access the transcribed text (in the text property) and the attached audio recording

Related

How to display response messege as response card in Amazon aws lex?

I have created a simple chatbot with the following flow.
Bot: do you want to buy a book?
Human: yes
Bot: what kind of book are you interested? (Response card)
-drama
-crime
-action
Human: drama (on click or typing)
Bot: Here is list of available drama movies in store(response card)
- Django
- first man
-true story
The last part is problem , I can't figure out how I can achieve that.
Can some one please help me what do I need to do to get what I want? Similar demo or tutorial Will be appreciated.
Here you need to add a response card using your Lambda code because the values are dynamic (available movies).
Here is the example code of adding response card:
"dialogAction": {
"type": "Close",
"fulfillmentState": "Fulfilled or Failed",
"message": {
"contentType": "PlainText or SSML",
"content": "Message to convey to the user. For example, Thanks, your pizza has been ordered."
},
"responseCard": {
"version": "1",
"contentType": "application/vnd.amazonaws.card.generic",
"genericAttachments": [
{
"title":"card-title",
"subTitle":"card-sub-title",
"imageUrl":"URL of the image to be shown",
"attachmentLinkUrl":"URL of the attachment to be associated with the card",
"buttons":[
{
"text":"button-text",
"value":"Value sent to server on button click"
}
]
}
]
}
}
This is an example of adding response card in a fulfimmnet message, you can add this in elicit_slot as well. Play around it and let us know if you have any confusion.
Hope it helps.

Facebook graph api. how to list all pages that my app is subscribed to?

So I am aware of how to check each page to get a list of all subscribed apps.
But I would like to get a list of all pages my app has real time update subscriptions for?
so i have tried this
https://graph.facebook.com/v2.5/$app_id/subscriptions?access_token=$app_token
but this just brings back basic info on the app.
I would like a list of pages that it has subscriptions to already?
Can anyone help?
This doesn't look to be possible.
Endpoint you're using - https://developers.facebook.com/docs/graph-api/reference/v2.8/app/subscriptions - is to get list of application webhooks (callback_url and type of changes), which are called subscriptions for some reason. It's not about pages that subscribed to this webhook (or this app in general).
Overall, even in https://developers.facebook.com/apps/ for your app, under e.g. Messenger tab, you will only see subset of all pages that subscribed to this app. The visible subset is limited by your facebook user account permissions, presumably only show pages that you're either Admin or Editor.
Therefore, if such call would be possible, it would be somehow tied to User Access Token as well, not only app token.
You can do this here: https://developers.facebook.com/tools/explorer
Once logged, you can click on right button and select "Get User Access Token". You will need at least manage_pages or pages_show_list permission to accomplish this.
Now, all you have to do is call this endpoint: /me/accounts.
It should list all subscribed pages on your app.
Hope it helps.
As per
https://developers.facebook.com/docs/facebook-login/access-tokens/#apptokens
it is possible (graph api):
GET /oauth/access_token
?client_id={app-id}
&client_secret={app-secret}
&grant_type=client_credentials
And then /<app_id>/subscriptions
which returns something like:
{
"data": [
{
"object": "application",
"callback_url": "https:...",
"active": true,
"fields": [
{
"name": "ads_rules_engine",
"version": "v2.9"
}
]
},
{
"object": "page",
"callback_url": "https://...",
"active": true,
"fields": [
{
"name": "leadgen",
"version": "v2.5"
}
]
}
]
}

Passing arbitrary fields in a CUSTOM notification

Is it possible to specify a payload in arbitrary fields in a menu item? Right now, I’m passing them as the id for the menu (which works but feels hacky) but I notice that if I set them as fields of the menu item, I never receive them in the POST:
MenuItem menuItem = new MenuItem()
// ... bunch skipped
.setId("5141...")
.set("eventId", "eventIdGoesHere")
;
Here is what I receive in the callback URL: I see the id in the payload field but I don’t see any "eventId" in the body of the POST:
body: {
"collection": "timeline",
"itemId": "a11d33c2-32d8-49c7-989e-2b69814e260f",
"operation": "UPDATE",
"userToken": "ya29.1....",
"userActions": [
{
"type": "CUSTOM",
"payload": "5141..."
}
]
}
You found the best practice - the ID of the menu item is returned as the payload of the user action when it is sent to you. The ID is opaque, so you are free to set it to whatever values you wish to decode however you want to.
Since the timeline itemId is also sent to you, you may also wish to set the sourceItemId or other (defined) attributes on the original timeline item to values that may contain information that will be useful to you. You can then do a timeline.get on the item to fetch this additional information.

How to link a website on timeline card html template?

Is it possible to have link on html template for google glass?
I want the user to tap on a link inside a timeline card and go to a website .
Thanks
Prem
While you can't open a link that way directly what you can do is add an OPEN_URI menu item with the link as payload to your timeline card.
{
"html": "(your card html code here)",
"menuItems": [
{
"action": "OPEN_URI",
"payload": "(your link here)"
}
]
}
Reference: https://developers.google.com/glass/v1/reference/timeline#menuItems.action

Get total number of Custom Actions on Open Graph Object

I want to access number of custom actions (that I've defined) done on my Open Graph object. Facebook will return number of Like actions in response(like this) but they don't include number of custom actions.
Apps can retrieve actions published for the authorized user. For example, a Recipe app can retrieve all the recipes I've cooked or plan on cooking and customize the app experience based the data.
This API returns the action’s metadata including timestamps along with custom properties and their values. Objects referenced from an action are returned a single level deep.
GET /{action-instance-id}
The following retrieves a specific action instance
https://graph.facebook.com/{action-instance-id}?access_token=USER_ACCESS_TOKEN
Response
{
"id": "1538292028372"
"start_time": 1303502229,
"end_time": 1303513029,
"data": {
"type": "recipebox:recipe",
"url": "http://www.example.com/pumpkinpie.html",
"id": "1234567890",
"title": "Pumpkin Pie"
},
}
The above content is from FB Documentaion