Is there a way to simply follow a URL in the Caroussel Selector? - actions-on-google

I am trying to figure out how I can embed Google Actions responses, such as the cards carousel, in a webhook response for DialogFlow.
According to the documentation, the structure looks as following:
"carouselSelect": {
"items": [
{
"optionInfo": {
"key": "MATH_AND_PRIME",
"synonyms": [
"math",
"math and prime",
"prime numbers",
"prime"
]
},
"title": "Math & prime numbers",
"description": "42 is an abundant number because the sum of its proper divisors 54 is greater...",
"image": {
"url": "http://example.com/math_and_prime.jpg",
"accessibilityText": "Math & prime numbers"
}
}
Is there a way to let the device simply follow a link when a certain card is clicked?
In the documentation, there is a paragraph Handling selected item, but this does not really answer my question. In my case, I am showing the cards from a DialogFlow conversation as explained in How can I integrate the Google Actions responses in a webhook response in Dialogflow?, so I am not following the Google Actions SDK flow as explained in these docs.
Also as a side note, if I am understanding this paragraph correctly, the backend service is called with a certain selected item. In my scenario, I don't need this information in the backend, I would rather want the device to just follow the URL.

In short - not directly, no. (Update: Yes. See below.)
You're mixing terminology, which may be causing some confusion. The Actions on Google defines a few different GUI components which have different capabilities:
Options to advance the conversation can be presented as List or Carousel items. Both of these allow an image and some text (think around a sentence or two). The selection option is sent back to your Action with the intention that the user will select one to continue the conversation. It is not meant to be the result of the conversation.
You can also show a single Card which also contains an image and some text. Unlike the Options, however, you can only display a single card, and it can contain a URL that links elsewhere. Cards are intended to be the result of a conversation.
There are also Suggestion Chips which are a word or two and are intended to supplement the above options to change the direction of the conversation.
Finally, there is a Link-out Chip which is a chip with a URL.
The best you can do at this point is to present the user with the options available and, once they reply, present a card with a link out directly on the card, or prompt them if this is what they wanted and offer a suggestion chip saying "no" that goes back into the conversation or a link out chip to the destination that the card represents.
Update: Google has just added the ability to create a Browsing Carousel, which allows you to create something that looks like a carousel, but only has links. The Browsing Carousel is defined differently (it is part of a RichResponse rather than a possible Intent), but the two look very similar.

Related

building a list in "actions on google"

I'm doing a project where the Google Assistant generates a list of cards about information on research articles. Each card on the list would have the title and URL to the research article. The Google Assistant would ask what subject you wants to research about and the user would reply with the subject matter in one or two words. I have the following questions
I understand that the app.buildList() command requires an alias and key variable. Could I level them as blank or null in my code because I don't think I need them
If the user clicks on the URL in a card, will the browser automatically open the link? I remember reading that Google must filter and approve URLs in Google assistant apps
Any help would be appreciated
You should probably populate the relevant fields for each API call in order to handle various types of user inputs. The key is used to identify the item that is being said. If a list is shown, you will need to use the key to identify which is clicked. The user may click on the list item to select it. However, they could also say the thing they want. That is where the aliases are useful.
Let's say you were grabbing a list of scholarly articles. While long articles may not lend themselves well to voice, it could be designed like:
function list () {
const app = new DialogflowApp({request, response});
app.askWithList('Alright! Here are some articles about memristors! Which do you want?',
// Build a list
app.buildList('Memristor Research')
// Add the first item to the list
.addItems(app.buildOptionItem('TITLE_OF_FIRST_PAPER',
['title of first paper', 'first'])
.setTitle('Title of First Paper')
.setDescription('S. Smith, Ph. D')
// Add the second item to the list
.addItems(app.buildOptionItem('TITLE_OF_SECOND_PAPER',
['title of second paper', 'second'])
.setTitle('Title of Second Paper')
.setDescription('H. Paul, Ph. D')
)
);
}
In this snippet, if I say I want the first article, it will give me that one without me having to give the full title while still keeping the interaction hands-free. The key will let me identify the article that should be read.
You can use the title of the paper or perhaps the link URL in order to handle it and present a card with more information including the URL.
You do not need to have each URL manually approved. The documentation states:
Links to sites outside the developer's domain are allowed.
Link text cannot be misleading. This is checked in the approval process.
As long as you are being straightforward about it, users will be able to directly open the paper in a browser by clicking on the link in the card.
More information is available in the documentation
You can create list in action on google should have minimum of two values and maximum of 30 values.
For sample code here :
https://developers.google.com/actions/assistant/responses#sample_code_2

Actions on Google not passing parameters

I'm using Dialogflow (previously API.ai) to create an Actions on Google app.
Using Dialogflow I have set up a custom Entity to highlight single words from multiple Intents.
ie. mashable, recode, bbc sport are all words picked up as Entities.
The fulfilment sends a post webhook to an api I created.
When using Dialogflow it sends off
"parameters": {
"news-agent": "BBC Sport"
},
Which is fine, I set up API to detect the parameter and when using Actions on Google simulator
"parameters": {
"news-agent": ""
},
The parameter is blank, I don't see anything in the documentation about why this is happening.
Could someone help?
It's possible that Actions on Google is not picking up a value for the "news-agent" slot.
Try making the "news-agent" slot required in Dialogflow and define a re-prompt question for it.
That way, the event won't be sent to your app unless the "news-agent" slot is filled.

Track back the origin of a link to save data for logging purpose?

We have a product based website. We show same products on the search page, details page, recommendations, e-mails, SMS and many other places to the users like any other e-commerce website.
On each of our product, we give "Add to cart" button. We want to check this button's usage from each of these places. For example, how many "Add to cart" clicks we got from search, details etc. pages.
There are multiple ways to do this:
From client side i.e. android, ios, mobile, website: Start sending an origin id with each product's "Add to cart" button click i.e. 1 for search page, 2 for details etc.
From the server side, guide the clients with URL for "Add to cart" and send URL as /api/addcart/?origin=1. This way all clients will automatically start sending w/o putting and maintaining this logic at every client.
Is 2nd the best approach to solve this problem or do we have any other better alternative? And If its the best way, how good is to track such things in URL query string of POST API? (As /api/addcart is POST endpoint)
I prefer not to send any query parameter for a POST endpoint. You can update your POST API to accept the below format of the request which has clientData section holds the other details.
The input format:
{
"clientData": {
"origin": "1"
},
"shoppingCart": {
//Contains the cart details.
}
}
An another approach would be creating an another endpoint which will just collect the usage information something like an event logging. So on click of "Add to cart" button will trigger the addCart, then followed by the new usage endpoint to capture the usage details.

where is the “Recently Used”,“In Active Adverts”, "Action Needed", "Shared" filtering based from facebook custom audience data?

If you go to business manager of facebook, then go to the "All Audiences", then under the "Audiences" tab, you will see a "Filters" button right beside the "Create Audience" button. Now my question is, which part the json data being provided by the facebook apis should I based the data that I should pull out based from these filters ?
- Recently Used
- In Active Adverts
- Action Needed
- Shared
Because unlike the "ready" and "not ready" status, those four filters that I mentioned are not straight forward where I can just look for the numbers from the returned json data. so how ?
Most likely, not all of this information is available through the API.
However, if you take a look at the following doc, you can see some reelvant fields that may help:
https://developers.facebook.com/docs/marketing-api/reference/custom-audience
Most likely you can use the field operation_status to look at whether an audience needs action.
For whether it's shared, take a look ad the edge adaccounts which will let you see the ad accounts this audience has been shared with.
For recently used, you'll probably have to look at the edge ads and review the status of the ads.
To save having to make multiple requests, you can take a look at field expansion in the Graph API, which will let you query for fields of objects in results using a single request:
https://developers.facebook.com/docs/graph-api/using-graph-api#fieldexpansion

In Facebook messenger API, how to prevent button postback payload text from being logged to chat window on click?

TLDR; # bottom
I asked the following question in the Facebook bugs section
NOTE: This is more of a platform design suggestion than a bug, as I failed to find a Chat API feedback portal
Currently I'm building a Chat bot that allows the user to track a goal. It will say something like "Did you go for a walk on July 12, 2016 ?" and have Yes/NO buttons below.
Currently in order to pass the intent, the day and the achievement boolean I need to template a string like this "==GOAL== achieved? <<<{goal_achieved}>>>, date tracked [[[{date_tracked}]]]" and use regex to capture the delimited variables. This is prone to parsing error in other cases where the templated strings in the payload are user-input variables i.e. if the '{goal_achieved}' were replaced with the goal variable '>>meditated" then the regex that captures the templated variable could fail.
One could use the postback payload to store a JSON-encoded string but the problem with this is that the payload string gets logged into the user output and JSON strings are a bit ugly and confusing. The challenges I face could be easily remedied if the payload was not logged to the user Instead log the text for the button to help the user confirm the button was clicked.
If that is not possible, is there any other advice for encoding data into button payload ?
The following answer was offered (Mark Wiltse)
Hi Justin,
Unfortunately at this time our payload structure does not support the functionality that you are trying to implement. From my understanding you want to use the Payload to inform your backend if the user accomplished their 'goal' on that specific date. I would suggest that you create your payload response for the button on your end before passing it to us, which is basically the JSON idea that you had initially.
I know this is a bit cumbersome to handle but the payload response passed back is independent of the text that was provided with the messenger thread.
I would suggest that you also attempt to sanitize your strings if you are worried a user has previously provided you would cause an issue with your regex. You should be able to implement this functionality if the prior user data is sanitized to avoid any issues with regex/json parsing.
Since this is an implementation question I will have to close this report as Invalid. If you are still looking for additional insights and concrete tips for implementing this flow please post to our stack overflow where we have Facebook Engineers and a wide range of community members who also contribute.
http://facebook.stackoverflow.com/
Take care and best wishes with your messenger bot.
Mark
This sentence was particularly unclear:
I know this is a bit cumbersome to handle but the payload response
passed back is independent of the text that was provided with the
messenger thread.
TLDR;
Can anyone inform me of how to prevent the button from logging the payload string so that I can use it to pass JSON to my app without the user seeing it ?
Make sure to comment out sendTextMessage() in your receivedPostback() call :
function receivedPostback(event){
sendTextMessage(senderID, event.postback.payload);
}
From my understanding you're saying that when you press a button the PAYLOAD instead of the button's text is showing up.
Are you defining your buttons like this?
{
type: "postback",
title: "View Details",
payload: "details:12345"
}
I'd recommend removing any special characters that would mess with the parsing of your payload. As long as the special characters are not crucial to the user experience this is probably a fine solution.
If this doesn't solve your issue:
Can you add a screenshot showing the button you are pressing, and the log message you are talking about? From my understanding you're saying that when you press a button the PAYLOAD instead of the button's text is showing up. That's not the case for me, my buttons text shows up when I press a button.