building a list in "actions on google" - 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

Related

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

FB Chatbot how to get the previous message

Is it possible to receive the previous message that the user have send to the chatbot (without using quick replies or postback buttons). Example:
User: "Can you call a friend?"
Bot: "Who should I call?"
User: "Tim"
In the API I now have just the information "Tim", without knowing if I should call him or text him or make him a sandwich or whatever. So I basically I want to add some Postbackdata or metadata additionally to the text "Can you call a friend" (intent: 'CALL'), so the message "Tim" will come with that data.
Is there a way without storing the data into a database? AWS Lambda with ClaudiaJs.
I found the metadata field in the FB API which turns out to be the wrong field for that since it is only for communicating between several apps?!
What you are looking for a called a "slot-based bot", or slot-filling, basically meaning that you have a "slot", or blank that needs to be filled in before your bot can perform an action. In your example you have two slots: action and person
Actions could be: call, text, message
Person: name of a person, friend, etc.
I don't think any of the message frameworks (Slack, Facebook, etc) will provide you with the information you need. You will need to build this logic out yourself.
You can look at using wit.ai stories to achieve this.
Look to this similar Stack Overflow question and answer.
You can reverse order of conversation, and at beginning user writes some text or send you something else. After receiving, you should send to user buttonsTemplate, where postbacks will be like "CallTo&Tim" where instead of Tim you can put every text you need to pass to next executor(and you also can store previous user message here). Than just make substring of postback, check it`s type and do whatever you want.

Linkedin API - get company ID from url

Is there a way to get the numeric company ID from the URL of a company page on Linkedin? This ID is the one I'll use to query the Linkedin API and get more information on the company.
I need to get the ID from the information provided with the URL, to use it to get the rest of the information related to the company page.
It seems unusual to me that you need to dig in the HTML code to get the company ID you need to use to interact using the Linkedin API, so correct me if I'm wrong.
I know there have been similar request handlers, but I'm wondering why there isn't a handler available to get the company ID like there is to get the profile id from its url:
https://api.linkedin.com/v1/people/url=xxxx
I know there is the search company handler, but that is a text based research and I found myself with some inconsistent results from time to time.
I don't want to crawl the company page for the ID since I get blacklisted by Linkedin if I do it too many times from the same IP address.
I am aware of these answers:
how to get companies id from linkedin jsapi
How to get the company id from Linkedin Company URL in PHP?
LinkedIn API for Company Directory
But they seem outdated or marginally related to what I ask and since LI API has changed much over the past year, if there was any development on this.
EDIT: added more info on the kind of ID I am looking for. I had erroneously marked #display's answer as correct but unfortunately it's not what I am looking for. I am referring to the companyId that I'd use to query the Linkedin API concerning that company.
June 2020 Update
Most of the above methods no longer work, including using the jobs page URL and hovering over search results. The 2019 update by #rinogo almost works. To make it easier, paste this script into the console. Of course, updates from LinkedIn may case this to fail eventually.
(() => {
const name = document.location.pathname.replace(/^\/[^\/]*\/([^\/]*)\/?/, '$1');
for (let json of Array.from(document.querySelectorAll('code'))) {
try {json = JSON.parse(json.innerText);} catch (e) {json = null;}
if (json && json.included) {
for (let incl of json.included) {
if (incl.universalName === name && incl.objectUrn) {
return 'Company ID for [' + incl.universalName + '] is [' + incl.objectUrn.substr('urn:li:company:'.length) + ']';
}
}
}
}
return 'Company ID not found';
})();
2020 update
Please see Whatabrain's answer.
2019 update
Arbitrary Pages
The solutions provided previously are outdated. The following is not the best solution, but it will work in a pinch. It does require "crawling", unfortunately. (I know this doesn't answer OP's question, but it should help others who arrive here since this is the top Google result)
View the HTML source for the "home page" of the company whose ID you are trying to discover. Search for the string, https://www.linkedin.com/company/. The first instance of this string on the page is followed immediately by the company ID.
You can verify that you have the right company ID by visiting the entire link (including the Company ID), e.g. https://www.linkedin.com/company/123456.
If this approach stops working at some point, please comment below and I'll update this answer.
UPDATE: I'm using the strategy today (7/2/2019) and am finding that the last instance is currently more reliable due to some changes made by LinkedIn. Ultimately, the overall strategy remains sound. View the source and find some repeatable way to search for the company ID. It may take some experimentation to find a reliable approach.
Pages with admin rights
If you have admin rights to the Page, finding the Company ID is trivial. While signed in, visit your Company Page. The Company ID is used right within the URL.
For example:
Admin URL for Company Page: https://www.linkedin.com/company/123123123/admin/
Company ID: 123123123
Or, you can of course use the API to find the Company ID for any Company Page of which you are an admin.
We can obtain the company id from the url of a company page. For this we must have a valid linkedin account.
Once you are in the company page, just check the url
https://www.linkedin.com/company/123456
The numbers given as 123456 is the respective company id.
Hope that you meant this company id.
The way I got the ID is by going to the page, and clicking "View Jobs" (as long as they have some).
Then the URL will have the ID on it:
https://www.linkedin.com/jobs/search?locationId=OTHERS.worldwide&f_C=12345678
To find your LinkedIn company ID:
Open LinkedIn in a new tab
In your search results, select your company page.
Navigate to the URL at the top of your company page.
Copy the number immediately following 'www.linkedin.com/company/' but before the question mark.
Solution provided by: https://support.klipfolio.com/hc/en-us/articles/216181827-Use-LinkedIn-as-a-data-source
Anyone still looking a solution, please follow:
Go to https://developer.linkedin.com/plugins/company-profile
Type the name of the company in the Company Name box and it will suggest the name.
Once you select the Company page, click on Get Code button.
You will get the company page id with data-id.
Screenshot:
Successfully used this method 2/27/2019.
Search for the company in LinkedIn.com
When located in search window, HOVER over the company name.
Locate ID at the bottom showing where the URL will direct.
Hovered over company name in top arrow, gathered ID in displayed URL at bottom arrow
I have a much easier solution that works! (15/01/2019)
Go to the company's page e.g. https://www.linkedin.com/company/something
Then view the source (CTRL+U in Chrome). Search for the expression "company/". The second match contains the ID! Have fun.

What are the "base URLs" for status, photos, etc?

I developed an app that looks for specific terms using the facebook api (search).
Every result comes with an ID for the item that can be of many types like "status","photos",etc.
I remember that some time ago I could surf facebook and get this URLs from the browser address bar, but now with some updates that facebook has made it seems to be all AJAX based calls and it seems like you do not have a "specific page" for each item.
I looked over the web and could not find anything regarding this.
Is there any way I can get a "photo id" from the API and open it like "http://facebook.com/photos/0293820293842"?
Thanks for any clue.
https://graph.facebook.com/{id}/picture
https://graph.facebook.com/40796308305/picture (by page id)
https://graph.facebook.com/cocacola/picture (by page's name)
https://graph.facebook.com/4/picture (by user id)
https://graph.facebook.com/4/zuck (by user name)
after some time I just gave up trying to get the picture from the data provided by the search API.
From the api I get entries of type "photo" but they do not match with the API documentation found at http://developers.facebook.com/docs/reference/api/photo/ since I do not receive the fields "picture", "source" or "images" (they just does not exist in the results from a search)
Looking to find a way to use the approach of "setting up the URL from the fields received from the API" I could not get any sucess either.
That's one case... I set up a search for "pepsi"... and within the results I got a "photo" object.
In this object I have the following fields:
id: 100002307882828_188072634633218
author\id: 100002307882828
link : "http://www.facebook.com/photo.php?fbid=320417371337648&set=a.133681116677942.17717.131381520241235&type=1" (this link really points to the photo's page, but is not the photo itself)
object_id: 320417371337648
I used the URL you provided as a "base" and tried to setup some combination that returns me a photo but I always get "Content not found" as result.
The only way I could find the final photo URL is to make another call to the API using the Photo Id as parameter (but I would need to do a lot of calls to the API and this just do not fit my scenario)
If I call https://graph.facebook.com/320417371337648 I get everything I need from the photo, but this is the "another call" I would need to perform for each result I get.
Thanks a lot for your help,
Regards,
Victor Reboucas

MOODLE Teacher Capability

I want a teacher capability to check the whether the login user is a teacher?
If teacher, I want a different Home Page i.e, my custom page
If student, a different page
Could anyone help ?
What you want to do is use the has_capabilty() function. That is the way you should pose the question. Does the user i am looking at have the capability to see this page. Moodle is all about context and in one context the user may have a different capability than another. Hence, to ask "if a user is a teacher" is the wrong question.
Example of implementation (using moodle 1.9)
if(has_capability('block/my_history:userview', get_context_instance(CONTEXT_USER)) ){
$this->content->footer = 'Manager View';
}else{
$this->content->footer = 'Non Manager View';
}
See this forum discussion for more understanding http://moodle.org/mod/forum/discuss.php?d=70739
Notice the comments by Tim Hunt in this post http://moodle.org/mod/forum/discuss.php?d=126223
It takes a bit of learning, but it works well once you get your head around it.
Good luck