Currently, I am developing a DB2 database-driven IBM Watson Assistant chatbot in Facebook page, integrated with IBM Cloud Functions. I have established the connection and able to send and receive messages on Facebook.
Now, I am trying to send Generic templates referencing to Facebook developer doc and implement a carousel of cards in facebook with images, titles and buttons.
Things I tried: According to IBM documentation, I tried message.attachment.payload (specified in facebook developer doc) inside output.facebook in Watson JSON editor.
{
"output": {
"generic": [{
"values": [{
"text": "ok"
}],
"response_type": "text",
"selection_policy": "sequential"
}],
"facebook": {
"text": "Hi,\n\nWe have a great giveaway for you, but first we’d like for you to follow us so that you can stay updated on the latest news and trends.\n\nPlease take a moment to follow us and let me know when you've followed us by typing DONE:\n\n",
"buttons": [{
"url": "https://www.facebook.com/ibmcommerce/",
"type": "web_url",
"title": "Follow IBM Commerce",
"messenger_extensions": "false",
"webview_height_ratio": "full"
}],
"template_type": "generic"
}
}
}
Also, I tried implementing the solution provided in IBM Watson developer forum
{
"output": {
"facebook": {
"message": {
"attachment": {
"type": "template",
"payload": {
"text": "Hi,\n\nWe have a great giveaway for you, but first we’d like for you to follow us so that you can stay updated on the latest news and trends.\n\nPlease take a moment to follow us and let me know when you've followed us by typing DONE:\n\n",
"buttons": [
{
"url": "https://www.facebook.com/ibmcommerce/",
"type": "web_url",
"title": "Follow IBM Commerce",
"messenger_extensions": "false",
"webview_height_ratio": "full"
}
],
"template_type": "button"
}
}
}
}
}
}
Neither of the solutions works for me. Kindly help me in figuring out what I am missing.
Any help is much appreciated. Thanks in advance!
update your webhook to an April version (2020-04-01)
instead of output.facebook use output.integrations.facebook
Related
i am trying to open a specific messenger page and trigger a dialog to display carousels based on the parameters that my users entered on my website.
i am leveraging the m.me link to open my messenger page (where my botframeowrk bot is deployed). After opening the page I am not able to invoke a dialog.
How can I achieve this ???
I went through the Ms Botframework V4 docs and didn't find any mention of channel specific trigger.I want to pass 4 parameters to my Bot from the website and then further make an api call in the dialog that i will invoke to display results.
Thanks in Advance.
You need to enable Messaging Referrals in the Facebook Developer portal to use m.me links. In the portal, click on the settings blade on the left, scroll down to webhooks, and click edit events. A window should pop up where you can enable messaging_referrals.
Facebook only lets you add the ref parameter to the m.me link, so to send additional data to the bot using this link, you will have to encode the values in the ref parameter and parse the data on the bot side - I would recommend using a separator value like a comma or a slash to organize your data.
https://m.me/<PAGE_NAME>?ref=my,additional,data
The event will be send to the bot as a message activity with a referral attribute where you can grab your data.
m.me link bot activity
{
"type": "message",
"id": "CDbQi3u62J7",
"timestamp": "2019-03-19T19:30:11.219Z",
"serviceUrl": "https://facebook.botframework.com/",
"channelId": "facebook",
"from": {
"id": "2031650190235097",
"name": "TJ Durnford"
},
"conversation": {
"isGroup": false,
"id": "2031650190235097-218838049015546"
},
"recipient": {
"id": "218838049015546",
"name": "thdurn-all-channels"
},
"channelData": {
"sender": {
"id": "2031650190235097"
},
"recipient": {
"id": "218838049015546"
},
"timestamp": 1553023811219,
"referral": {
"ref": "my,additional,data",
"source": "SHORTLINK",
"type": "OPEN_THREAD"
}
}
Hope this helps!
In api.ai,
Rich formatting is supported for skype pretty fine. Here's an example:-
Here's the code of custom payload of api.ai:-
{
"skype": {
"text": "OCAS means Online Credit Approval System.\n Click [here] (http://www.erainfotechbd.com/product/ocas-online-credit-approval-system/) for more information. ",
"attachments": [
{
"contentType": "image/png",
"contentUrl": "http://weknowyourdreams.com/images/smile/smile-07.jpg",
"name": "Profile-picture.png"
}
]
}
}
Now, I wanna do something like this in facebook messenger also. But in the api.ai doc, only audio, video and file is supported.
Is there any other way to do so for url also in messenger ?
Generally webhook responses can deliver any custom payload to most platforms that API.AI supports, so any feature supported by Facebook Messenger, Skype, Google Assistant, etc. can be utilized through API.AI. Unfortunately Facebook doesn't seem to support hyperlinked text. The closest analog I could find is a what Facebook calls a URL Button. Below is an example of how you could create a API.AI response that has a Facebook URL Button with Facebook's Button template:
{
"speech": "OCAS means Online Credit Approval System. Check your phone for more information.",
"displayText": "OCAS means Online Credit Approval System. Click here for more information: http://www.erainfotechbd.com/product/ocas-online-credit-approval-system/",
"data": {
"facebook": {
"attachment": {
"type": "template",
"payload": {
"template_type": "button",
"text": "OCAS means Online Credit Approval System",
"buttons": [
{
"type": "web_url",
"url": "http://www.erainfotechbd.com/product/ocas-online-credit-approval-system/",
"title": "Click here for more information"
}
]
}
}
}
}
}
You can use also use any other Facebook Messenger APIs by including any JSON inside the "message" attribute that you see from Facebook's Messenger documentation and it will be passed along to Facebook by API.AI
PS - the code above should produce a message that looks something like this:
Currently I'm working on a project that require me to collect celebrities followers number (from instagram or facebook).
To get that number, i have to get
1. celebrities instagram link
2. celebrities facebook link
3. send a request to instagram or facebook API to get their followers number
I have been researching for google knowledge API for celebrities instagram and facebook link. but what I get from it isn't satisfying.
For example, I put a request on google Knowledge,
https://kgsearch.googleapis.com/v1/entities:search?query=Ariana+Grande&limit=1&indent=1&key={API-CODE}
and the result is
{"#context": {
"#vocab": "schema.org/",
"goog": "schema.googleapis.com/",
"EntitySearchResult": "goog:EntitySearchResult",
"detailedDescription": "goog:detailedDescription",
"resultScore": "goog:resultScore",
"kg": "g.co/kg"
},
"#type": "ItemList",
"itemListElement": [
{
"#type": "EntitySearchResult",
"result": {
"#id": "kg:/m/09gkdy4",
"name": "Ariana Grande",
"#type": [
"Thing",
"Person"
],
"description": "Singer",
"image": {
"contentUrl": "t0.gstatic.com/images?q=tbn:ANd9GcS3KH3ae6ChLCPLguyQXbLbEXDTNMZ1Sb2LsMx6Vr-pjeuHg5AZ",
"url": "da.wikipedia.org/wiki/Ariana_Grande",
"license": "creativecommons.org/licenses/by/2.0"
},
"detailedDescription": {
"articleBody": "Ariana Grande-Butera, known professionally as Ariana Grande, is an American singer and actress. She began her career in the Broadway musical 13, before landing the role of Cat Valentine on the Nickelodeon television series Victorious in 2009. ",
"url": "en.wikipedia.org/wiki/Ariana_Grande",
"license": "en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"
},
"url": "www.arianagrande.com"
},
"resultScore": 802.862244
}
]
}
There's no information regarding her instagram or facebook link from the result, but if we search manually on google, it shows her instagram and facebook link on search result.
My question are:
1. Any way to get those link from Google knowledge?
2. Or any easier way to get follower number from celebrities beside my way? (jugling from 2-3 different APIs)
Thanks.
I really appreciate any comment and help.
You can use wikidata.org. There are steps:
Search https://www.wikidata.org/w/api.php?action=wbsearchentities&search=Ariana+Grande&language=en&format=json
{"searchinfo":{"search":"Ariana Grande"},"search":[{"id":"Q151892","concepturi":"http://www.wikidata.org/entity/Q151892","url":"//www.wikidata.org/wiki/Q151892","title":"Q151892","pageid":153289,"label":"Ariana Grande","description":"American actress, singer, composer and dancer","match":{"type":"label","language":"en","text":"Ariana Grande"}}],"success":1}
Get id Q151892 from the response and get the entity https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q151892&format=json&props=claims
There is a big response. You need the value arianagrande of claim P2003 from a list of claims. It refers to Instagram username (P2013 for Facebook)
Get public info from https://www.instagram.com/arianagrande/?__a=1
user:
follows:
count
followed_by:
count
media:
count
I am using this URL to access facebook likes off of an authorized and logged in user:
https://graph.facebook.com/v2.3/me/likes?access_token=accessToken
it returns this
"data": [
{
"name": "Page Name",
"category": "Category name",
"id": "12345678",
"created_time": "2012-03-26T08:02:01+0000"
},
However on my new app which uses API 2.5
https://graph.facebook.com/v2.5/me/likes?access_token=accessToken
it returns this
"data": [
{
"name": "Page Name",
"id": "12345678",
"created_time": "2012-03-26T08:02:01+0000"
},
Which is minus the category name.
I have my new app registered in FB and it will not allow me change API from 2.5, and even on my new app if I use the 2.3 URL it will still not display categories.
Does anyone know what extra calls I need to make to get categories or why they have disapeared in newer versions of the API, I can't find anything on google or on FB's doco's
It´s called "Declarative Fields", check out the changelog for v2.4: https://developers.facebook.com/docs/apps/changelog#v2_4
That´s what you need to change:
/me/likes?fields=name,category&access_token=accessToken
Context: For a Hackathon I building an app (web based - Ruby on Rails) that matches people based on their commun interests. For that I want to use Facebook connect and instantaneously get a person's likes so I can match him/her with someone with similar interests.
The problem: But apparently I can't access someone's likes through Facebook connect unless my app has been approved by Facebook. But without this login there is no app (and I can't wait 3-7 business days to have a working app).
Is there a way I can get my app to work (even if it's only with a set of approved users/testers)? Or do I have to come up with a an alternative page where my users will have to manually enter their interests?
No, there's no shortcut for the Login Review. What you can do is adding specific users (via your app's dashboard) you want to test your functionality with as admins/developers/testers of the specific app.
This will allow them to be able to grant your app extended permissions as user_likes without Login Review.
Also, I think Facebook already provides an endpoint for your use case:
/{user-id}?fields=context{mutual_likes}
which will produce something like
{
"context": {
"mutual_likes": {
"data": [
{
"category": "Media/news/publishing",
"name": "Mashable",
"id": "18807449704"
},
{
"category": "Food/beverages",
"name": "Coca-Cola",
"id": "40796308305"
}
],
"paging": {
"cursors": {
"before": "MTg4MDc0NDk3MDQ=",
"after": "NDA3OTYzMDgzMDU="
}
},
"summary": {
"total_count": 2
}
}
},
"id": "123456789"
}
See
https://developers.facebook.com/docs/graph-api/reference/v2.0/user.context/mutual_likes
https://developers.facebook.com/docs/graph-api/reference/v2.0/page.context/friends_who_like
https://developers.facebook.com/docs/facebook-login/review/how-to-submit#testpermissions
https://developers.facebook.com/apps/{your_app_id}/roles/