Facebook Chatbot: Animated GIFs in Generic Templates - android

With the generic templates for Facebook chatbots it is possible to use animated GIF images. This works perfectly for the desktop version. With the messenger app on iOS or Android the animation is not playing and only the first frame is displayed instead.
Is there something I can do to make it also work in the messenger app?
Here is the documention about the generic templates for the Facebook chatbot: https://developers.facebook.com/docs/messenger-platform/send-api-reference/generic-template

I tried it too, but the answer is what you knew. Animated Gifs works as single picture, but doesn't work in any templates. I've read all reference by FB and checked all news they've published. But they haven't mentioned about it and there is just the true by my hand below.
o single picture on browser
o single picture on app
o picture of template on browser
x picture of template on app
o -> animating
x -> stop and just first frame is shown

I had the same issue when I posted a valid GIF URL in the generic template. You can see a question I posted and the answer I add after a couple of hours of searching.
Unfortunately, animated GIF images cannot be printed through the generic template yet.
The solution you can do is you create two payloads and not a template. The first payload will post a GIF Image and the second your buttons like,
code
def thanks(req):
your_welcome_gif=[ "https://media3.giphy.com/media/KCw6QUxe9zBO6QNrFe/giphy.gif",
"https://media1.giphy.com/media/H21d4avBXs8B9X0NLj/giphy.gif",
"https://media1.tenor.com/images/15bafc0b414757acab81650a6ff21963/tenor.gif?itemid=11238673"]
greeding = req.get('queryResult').get('parameters').get('greeding')
if greeding == 'Thank you' or greeding == 'thank you' or greeding == 'Thanks' or greeding == 'thanks' or greeding == 'Nice' or greeding == 'nice':
return {"fulfillmentMessages": [
{
'payload': {
"facebook": {
"attachment": {
"type": "image",
"payload":{
"url":random.choice(your_welcome_gif)
}
}
}
}
},
{
'payload': {
"facebook": {
"attachment": {
"type": "template",
"payload": {
"template_type": "button",
"text": "You're welcome :) \nWould you like to choose another movie?",
"buttons": [
{
"type": "postback",
"title":"Yes",
"payload":"Yes"
},
{
"type": "postback",
"title":"No",
"payload":"No"
}
]
}
}
}
}
}
]}
Here is my question with code uploaded.

Yes you also send a gif message but int the url section you have to give a valid url of that gif...you can do it by uploading on git first and then at the last of url you have to type.....=> ?raw=true
because in git it stored in raw format...
You may see all the details here on my link this chatbot is handling almost every feature in the described in the documents

Related

Is there a way to scan images in android studio to make sure they are not graphic? possibly using bitmap? [duplicate]

I am currently developing a website for a client. It consists of users being able to upload pictures to be shown in a gallery on the site.
The problem we have is that when a user uploads an image it would obviously need to be verified to make sure it is safe for the website (no pornographic or explicit pictures). However my client would not like to manually have to accept every image that is being uploaded as this would be time consuming and the users' images would not instantly be online.
I am writing my code in PHP. If needs be I could change to ASP.net or C#. Is there any way that this can be done?
2019 Update
A lot has changed since this original answer way back in 2013, the main thing being machine learning. There are now a number of libraries and API's available for programmatically detecting adult content:
Google Cloud Vision API, which uses the same models Google uses for safe search.
NSFWJS uses TensorFlow.js claims to achieve ~90% accuracy and is open source under MIT license.
Yahoo has a solution called Open NSFW under the BSD 2 clause license.
2013 Answer
There is a JavaScript library called nude.js which is for this, although I have never used it. Here is a demo of it in use.
There is also PORNsweeper.
Another option is to "outsource" the moderation work using something like Amazon Mechanical Turk, which is a crowdsourced platform which "enables computer programs to co-ordinate the use of human intelligence to perform tasks which computers are unable to do". So you would basically pay a small amount per moderation item and have an outsourced actual human to moderate the content for you.
The only other solution I can think of is to make the images user moderated, where users can flag inappropriate posts/images for moderation, and if nobody wants to manually moderate them they can simply be removed after a certain number of flags.
Here are a few other interesting links on the topic:
http://thomas.deselaers.de/publications/papers/deselaers_icpr08_porn.pdf
http://www.naun.org/multimedia/NAUN/computers/20-462.pdf
What is the best way to programmatically detect porn images?
The example below does not give you 100% accurate results but it should help you a least a bit and works out of the box.
<?php
$url = 'http://server.com/image.png';
$data = json_decode(file_get_contents('http://api.rest7.com/v1/detect_nudity.php?url=' . $url));
if (#$data->success !== 1)
{
die('Failed');
}
echo 'Contains nudity? ' . $data->nudity . '<br>';
echo 'Nudity percentage: ' . $data->nudity_percentage . '<br>';
If you are looking for an API-based solution, you may want to check out Sightengine.com
It's an automated solution to detect things like adult content, violence, celebrities etc in images and videos.
Here is an example in PHP, using the SDK:
<?php
$client = new SightengineClient('YourApplicationID', 'YourAPIKey');
$output = $client>check('nudity')>image('https://sightengine.com/assets/img/examples/example2.jpg');
The output will then return the classification:
{
"status": "success",
"request": {
"id": "req_VjyxevVQYXQZ1HMbnwtn",
"timestamp": 1471762434.0244,
"operations": 1
},
"nudity": {
"raw": 0.000757,
"partial": 0.000763,
"safe": 0.999243
},
"media": {
"id": "med_KWmB2GQZ29N4MVpVdq5K",
"uri": "https://sightengine.com/assets/img/examples/example2.jpg"
}
}
Have a look at the documentation for more details: https://sightengine.com/docs/#nudity-detection
(disclaimer: I work there)
There is a free API that detects adult content (porn, nudity, NSFW).
https://market.mashape.com/purelabs/sensitive-image-detection
We've using it on our production environment and I would say it works pretty good so far. There are some false detections though, it seems they prefer to mark the image as unsafe if they are unsure.
It all depends on the level of accuracy you are looking for, simple skin tone detection (like nude.js) will prob get you 60-80% accuracy on a generous sample set, for anything more accurate than that, let's say 90-95%, you are going to need some specialized computer vision system with an evolving model that is revised over time. For the latter you might want to check out http://clarifai.com or https://scanii.com (which I work on)
Microsoft Azure has a very cool API called Computer Vision, which you can use for free (either through the UI or programmatically) and has tons of documentation, including for PHP.
It has some amazingly accurate (and sometimes humorous) results.
Outside of detecting adult and "racy" material, it will read text, guess your age, identify primary colours, etc etc.
You can try it out at azure.microsoft.com.
Sample output from a "racy" image:
FEATURE NAME: VALUE:
Description { "tags": [ "person", "man", "young", "woman", "holding",
"surfing", "board", "hair", "laying", "boy", "standing",
"water", "cutting", "white", "beach", "people", "bed" ],
"captions": [ { "text": "a man and a woman taking a selfie",
"confidence": 0.133149087 } ] }
Tags [ { "name": "person", "confidence": 0.9997446 },
{ "name": "man", "confidence": 0.9587285 },
{ "name": "wall", "confidence": 0.9546831 },
{ "name": "swimsuit", "confidence": 0.499717563 } ]
Image format "Jpeg"
Image dimensions 1328 x 2000
Clip art type 0
Line drawing type 0
Black and white false
Adult content true
Adult score 0.9845981
Racy true
Racy score 0.964191854
Categories [ { "name": "people_baby", "score": 0.4921875 } ]
Faces [ { "age": 37, "gender": "Female",
"faceRectangle": { "top": 317, "left": 1554,
"width": 232, "height": 232 } } ]
Dominant color background "Brown"
Dominant color foreground "Black"
Accent Color #0D8CBE

not able to pass ofl parameter in request body in REST api of firebase dynamic link?

I am using firebase dynamic links where i used their REST api to create dynamic link. I am able to create the short link by using REST api and created link is working fine on android and ios app as well as on mobile browser. But i used same link on desktop browser it is not redirecting to play store page. Firebase provided "ofl" as a parameter to provide my intended functionality but there is no documentation to how i can pass that parameter in request body. Can anyone help me out ?
{
"dynamicLinkInfo": {
"domainUriPrefix": "my_custome_domain_name",
"link": "my_dynamic_link",
"androidInfo": {
"androidPackageName": "my_package_name",
"androidFallbackLink": "https://play.google.com/store/apps/details?id=my_package_name",
"androidMinPackageVersionCode": "2"
}
"navigationInfo": {
"enableForcedRedirect": true,
}
},
"suffix": {
"option":"UNGUESSABLE"
}
}
As far as I know, ofl is used to specify a different behavior on desktop, Like to display your webpage which gives brief info about your app or to display a link which can redirect to play store.... In your case you directly want to redirect to play store, so for that you can use desktopFallbackLink and provide your play store link of app
eg:
{
"dynamicLinkInfo":{
"domainUriPrefix":"my_custome_domain_name",
"link":"my_dynamic_link",
"androidInfo":{
"androidPackageName":"my_package_name",
"androidFallbackLink":"https://play.google.com/store/apps/details?id=my_package_name",
"androidMinPackageVersionCode":"2"
},
"navigationInfo":{
"enableForcedRedirect":true,
}
},
"suffix":{
"option":"UNGUESSABLE"
},
"desktopInfo":{
"desktopFallbackLink":"https://www.other-example.com/"
}
}

Parse CloudCode won't show my app

I'm beginning to use CloudCode but I can't find my application after authentication.
Once I enter my email account and pass I get the following:
Email:
Pass:
1: results
Select an App:
From this step nothing works (Ex. parse deploy) and I get the error msg "Unknown application _default"
I'm using the latest parse-windows.2.0.11.exe, PowerShell on Win8.1
Should CloudCode be activate on the project in order to use it? if so, how is this done?
===UPDATE===
It turns out the global.json was created wrong (bug?)
{
"applications": {
"results": {
"applicationId": {
"appName": "AppName1",
"applicationId": "zzz",
"masterKey": "zzz"
},
"masterKey": {
"appName": "AppName2",
"applicationId": "xxx",
"masterKey": "xxx"
}
}
}
}
I've manually fixed it using this thread link
Hope this will help others..
=== END UPDATE===
Please advise.
Thanks,
Liran
My experience is with Android over Linux, but from what I see the base is the same - in Linux you create a folder for your CloudCode that you reference for deployments, so when you deploy you do that from inside that folder, read carefully through This Parse Tutorial - seems pretty similar.

Sencha touch app in offline

My app is almost completed with sencha touch2.3, now I want to make it working in offline mode.
I need to load lot of data and images from my server application, It's working fine in online mode.
Problems I need to solve and what I have done
1. Need to store data in websql (using sql proxy) when there is a network.
I did this by.. if there is a network,I am loading online store and adding all the record to offline store.
Ext.getStore('foodGroup').load({
callback: function(records, operation, success) {
var offFoodGrup = Ext.getStore('offFoodGroup');
offFoodGrup.add(records);
offFoodGrup.sync();
offFoodGrup.load();
}
},
scope: this
});
2. I need to update the offline data if needed, I tried but it's not working. It adds duplicate data.
Ext.getStore('foodGroup').load({
callback: function(records, operation, success) {
var offFoodGrup = Ext.getStore('offFoodGroup');
if(records.length != (localStorage.offFoodGroup || 0)){
offFoodGrup.removeAll();
offFoodGrup.sync();
offFoodGrup.load({
callback: function(offRecords, operation, success) {
offFoodGrup.add(records);
offFoodGrup.sync();
offFoodGrup.load();
localStorage.offFoodGroup = offFoodGrup.getAllCount();
},
scope: this
});
}
},
scope: this
});
3. I need to show lot of images offline, so I though converting image url to base64 string may solve my problem. How can I do this in following code.
Ext.define('MyAPP.view.PhotoContainer', {
extend: 'Ext.Container',
xtype : 'photoContainer',
config:{
tpl: Ext.create('Ext.XTemplate',
'<ul class="foodList">',
'<tpl for=".">',
'<li class="foodContainer" code="{code}">',
'<img class="food" src="'+localStorage.httpServerPrefix+'food/showImage/{code}" alt="{name}"/>',
'<p code="{code}" class="foodnamestyle">{[this.getpreferedlanguage(values)]}</p>',
'</li>',
'</tpl>',
'</ul>'
}),
store : 'FoodStore'
}
});
It would be helpful to see your code for the FoodGroup model and online and offline stores if thats ok.
With the image in base64 format just use a data url like this:
<img src="data:image/png;base64,{Your Base64 Image Data}"/>
Hope that helps, and if you can post your models and stores I might be able to help with that.
Thanks,
Tristan

How to create a generic "create photo" code for both iPhone and Android using Appcelerator?

I am trying to create an application that is capable of creating photos on both Android and iPhone using Appcelerator. The functionality should launch default photo API, create a photo, allow user to either agree with photo, or cancel it, and on successful result save it on the memory card. It is not necessary that photos should be automatically added to the Gallery.
Currently I am using this code which works perfectly for Android :
Rf.media.photo = {
key: 'photo',
title: 'Photo',
extension: 'jpg',
type: 'image/jpeg',
create: function(created) {
Ti.Media.showCamera({
// TODO: disallow video for ios
animated: false,
saveToPhotoGallery: false,
showControls: true,
success: function(media_item) {
var name = Rf.util.timestamp() + '.' + Rf.media.photo.extension;
Rf.write_to_new_file(name, media_item.media, function(file) {
created(file);
});
},
});
},
};
I am looking for ways to tweek this code, so it would work also for iPhone. At the moment it is unresponsive when tested on iPhone 4.
Anyone knows whats wrong with it?
take a look at the kitchenSink examples for photo and photo gallery, they provide a pretty complete example

Categories

Resources