Actions on Google card carousel response: Images not being displayed - dialogflow-es

This is the response I'm sending from the webhook:
conv.ask(new Carousel({
title: 'Carousel Title',
items: {
'AU': {
title: 'Australia',
subtitle: '',
image: new Image({
url: 'https://blocky-host-files.web.app/dc_graphics/au.png',
alt: 'Australia graphic',
}),
},
'CA_US': {
title: 'Americas',
subtitle: 'Canada / United States',
image: new Image({
url: 'https://blocky-host-files.web.app/dc_graphics/ca_us.png',
alt: 'Canada United States graphic',
}),
},
'EU': {
title: 'Europe',
subtitle: '',
image: new Image({
url: 'https://blocky-host-files.web.app/dc_graphics/eu.png',
alt: 'Europe graphic',
}),
}
}
}));
This is how it looks on my phone:
I cannot figure out why the images aren't shown. They are not being displayed on my Google Home Hub too.
However, the Actions on Google simulator displays my images.

I think your issue is coming due to two possible reasons:
There might be a problem with the platform you are using (blocky host). It is possible that this platform is not supported for displaying the carousel, Please check, if you are able to display a card in this platform. If not - then there is some problem with the platform you are are using
It can be due to a network issue
You can try seeing the surface capability in the request. It can help

It works now after moving the images to a different host (imgur).
I've used Firebase Hosting to host the images before and somehow Google couldn't get these images from it's own platform, even though they are public accessible.

Related

How to convert my Wordpress website to flutter application?

I am a college student and during my intern my client gave me this project to convert his wordpress website into a mobile application while including existing features as well as some new features. The website is news website. I am also provided with wordpress admin panel credentials.
However, I am having hardtime fetching all data of website in json form. I tried using the wordpress api url: "https://example.com/wp-json/wp/v2/posts" as well as
"https://example.com/wp-json/wp/v2/posts?perpage=100" and
"https://example.com/wp-json/wp/v2/posts/?filter[limit]=100"
but none of them provided with whole data, it only rendered 10 latest news posts.
I am looking to get whole access to the website data myself. Is there any possible way for that? I want comments from the users on that news post, number of shares, likes, the related news section below post, everything.
Do I have to ask for the organization's main api or is there any other way? I am fluent in flutter and node js.
Flutter WordPress
Flutter WordPress is a library that allows for easy communication between a Flutter app and the WordPress backend. It uses WordPress REST API v2 for this interaction.
If your app is going to make use of authentication or other admin level APIs then the developer recommends you use these two authenthentication wordpress plugins:
Application Passwords
JWT Authentication for WP REST API (recommended)
How to use Flutter WordPress
1.Go to your pubspec.yaml then add the following as a dependency:
flutter_wordpress: ^0.1.4
You can check for the latest version here.
2.Import it in your code:
import 'package:flutter_wordpress/flutter_wordpress.dart' as wp;
3.You instantiate WordPress:
wp.WordPress wordPress;
// adminName and adminKey is needed only for admin level APIs
wordPress = wp.WordPress(
baseUrl: 'http://localhost',
authenticator: wp.WordPressAuthenticator.JWT,
adminName: '',
adminKey: '',
);
4.You then authenticate the user:
Future<wp.User> response = wordPress.authenticateUser(
username: 'ChiefEditor',
password: 'chiefeditor#123',
);
response.then((user) {
createPost(user);
}).catchError((err) {
print('Failed to fetch user: $err');
});
5.Here's how you can fetch wordpress posts and show them in your flutter app:
Future<List<wp.Post>> posts = wordPress.fetchPosts(
params: wp.ParamsPostList(
context: wp.WordPressContext.view,
pageNum: 1,
perPage: 20,
order: wp.Order.desc,
orderBy: wp.PostsOrderBy.date,
),
fetchAuthor: true,
fetchFeaturedMedia: true,
fetchComments: true,
);
6.And here's how you can fetch users:
Future<List<wp.User>> users = wordPress.fetchUsers(
params: wp.ParamsUserList(
context: wp.WordPressContext.view,
pageNum: 1,
perPage: 30,
order: wp.Order.asc,
orderBy: wp.UsersOrderBy.name,
role: wp.UserRole.subscriber,
),
);
7.And here's how to fetch comments:
Future<List<wp.Comment>> comments = wordPress.fetchComments(
params: wp.ParamsCommentList(
context: wp.WordPressContext.view,
pageNum: 1,
perPage: 30,
includePostIDs: [1],
),
);
8.Then creating a wordpress post via flutter is easy:
void createPost(wp.User user) {
final post = wordPress.createPost(
post: new wp.Post(
title: 'First post as a Chief Editor',
content: 'Blah! blah! blah!',
excerpt: 'Discussion about blah!',
author: user.id,
commentStatus: wp.PostCommentStatus.open,
pingStatus: wp.PostPingStatus.closed,
status: wp.PostPageStatus.publish,
format: wp.PostFormat.standard,
sticky: true,
),
);
post.then((p) {
print('Post created successfully with ID: ${p.id}');
postComment(user, p);
}).catchError((err) {
print('Failed to create post: $err');
});
}
Then to post a comment:
void postComment(wp.User user, wp.Post post) {
final comment = wordPress.createComment(
comment: new wp.Comment(
author: user.id,
post: post.id,
content: "First!",
parent: 0,
),
);
comment.then((c) {
print('Comment successfully posted with ID: ${c.id}');
}).catchError((err) {
print('Failed to comment: $err');
});
}
Download full example here.

PayPal subscription and webhooks

I made an website with a service that I am charging for. I want to create a PayPal subscription. I need that subscription to be connected with my backend (firebase functions - node.js) so I can change some data in the database to serve my users different content depending if they are paying or not. I wanted to use PayPal buttons for my subscription but I can't find a way to connect that button with my backend so it seems PayPal buttons aren't optimal for my problem. I can't use Stripe because it's not supported in my country. Can you offer me a different solution for my subscripton payments or show how can I use PayPal?
You can use Paypal Node SDK for your use case instead of relying to the embeddable Paypal subscribe button. The SDK will give you better integration with NodeJs.
There are basically 2 steps to do this:
1.) Define the Billing Plan Object
The billing plan object defines the subscription plan, including the number of cycles, frequency of payment, any setup fees, and so on.
var billingPlanAttribs = {
name: 'Food of the World Club Membership: Standard',
description: 'Monthly plan for getting the t-shirt of the month.',
type: 'fixed',
payment_definitions: [{
name: 'Standard Plan',
type: 'REGULAR',
frequency_interval: '1',
frequency: 'MONTH',
cycles: '11',
amount: {
currency: 'USD',
value: '19.99'
}
}],
merchant_preferences: {
setup_fee: {
currency: 'USD',
value: '1'
},
cancel_url: 'http://localhost:3000/cancel',
return_url: 'http://localhost:3000/processagreement',
max_fail_attempts: '0',
auto_bill_amount: 'YES',
initial_fail_amount_action: 'CONTINUE'
}
};
Of course, you will need to change cancel_url and return_url to your actual Firebase functions endpoints (or localhost if you are running your functions in localhost for development purposes)
2.) Create and Activate Billing Plan, so once you created or defined your billing - you will need to create that object and activate the billing plan like so:
paypal.billingPlan.create(billingPlanAttribs, function (error, billingPlan){
var billingPlanUpdateAttributes;
if (error){
console.error(JSON.stringify(error));
throw error;
} else {
// Create billing plan patch object
billingPlanUpdateAttributes = [{
op: 'replace',
path: '/',
value: {
state: 'ACTIVE'
}
}];
// Activate the plan by changing status to active
paypal.billingPlan.update(billingPlan.id, billingPlanUpdateAttributes, function(error, response){
if (error){
console.error(JSON.stringify(error));
throw error;
} else {
console.log('Billing plan created under ID: ' + billingPlan.id);
}
});
}
});
Again, all of these are documented in Paypal's Developer Section.
Here's also a link to their github example using NodeJs (which is same underlying backend as a Firebase Function)

Playback media object for specified time on google assitant

Is there a way to play back a media objects for a specified period using nodejs actions sdk ?
For example in the code below in the code below the file is for 1 minutes and 42 seconds. But suppose I had a file that was 60 minutes long, I want to be able to pass a parameter to the object that will specify the duration of the play back, which would be less than the total duration .
function yourFunctionHandler(agent) {
let conv = agent.conv();
conv.ask(new SimpleResponse("Here is a funky Jazz tune"));
conv.ask(new Suggestions(['suggestion 1', 'suggestion 2']));
conv.close(new MediaObject({
name: 'Jazz in Paris',
url: 'https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3',
description: 'A funky Jazz tune',
icon: new Image({
url: 'https://storage.googleapis.com/automotive-media/album_art.jpg',
alt: 'Media icon',
}),
})); }
No, there is currently no way to limit the playback from a Media Response to a limited time, to specify a start point in the media, or to specify an end point in the media.

I'm trying to make sense of session, but cannot get any data out of it

Currently using LUIS in a bot that connects to Slack. Right now I'm using interactive messages and trying to respond to user input correctly. When I click an item from the drop down LUIS receives it as a message. I can get the text with session.message.text, however I need to get the callback_id of the attachment as well as the channel it was sent from.
I've used console.log(session) to get an idea of what session looks like. From there I've seen that session.message.sourceEvent contains the data I need, however I can't use indexOf() or contains() to actual extrapolate the data. I've also tried session.message.sourceEvent.Payload but end up getting "[object [Object]]". I've tried searching for documentation on session formatting but to no avail.
Below is a snippet of what is returned when I run console.log(session.message.sourceEvent).
{ Payload:
action_ts: '1513199773.200354',
is_app_unfurl: false,
subtype: 'bot_message',
team: { id: 'T03QR2PHH', domain: 'americanairlines' },
user: { id: 'U6DT58F2T', name: 'john.cerreta' },
message_ts: '1513199760.000073',
attachment_id: '1',
ts: '1513199760.000073' },
actions: [ [Object] ],
callback_id: 'map_selection1',
original_message:
username: 'Rallybot',
response_url: 'https://hooks.slack.com/actions/T03QR2PHH/287444348935/Y6Yye3ijlC6xfmn8qjMK4ttB',
type: 'message',
{ type: 'interactive_message',
channel: { id: 'G6NN0DT88', name: 'privategroup' },
token: 'removed for security',
{ text: 'Please choose the Rally and Slack team you would like to map below.',
bot_id: 'B7WDX03UM',
attachments: [Array],
trigger_id: '285857445393.3841091595.085028141d2b8190b38f1bf0ca47dd88' },
ApiToken: 'removed for security' }
session.message.sourceEvent is a javascript Object, however indexOf or contains are functions of String or Array types.
Any info you required in the object, you should direct use the code <object>.<key> to invoke that value. You can try session.message.sourceEvent.Payload.action_ts for example.
Also, you can use Object.keys(session.message.sourceEvent) to get all the keys in this object.

Instagram - media user and caption user stored separately

I'm playing around with instagram's API and got a JSON object as below, assume it's stored in variable media
{
id:'1222XXXXXX_XXXXX',
created_time: "1459991213",
user: {
username: "user1",
profile_picture: "http://link",
id: "7xxxx",
full_name: "SomeName"
},
caption: {
created_time: "1459991213",
text: "hello",
from: {
username: "user1",
profile_picture: "http://link",
id: "7xxxx",
full_name: "SomeName"
},
id: "1222831055034209838"
}
images:{...}
}
Notice that
media.user and media.caption.from are same user info.
media.created_time and media.caption.created_time are the same.
I'm curious why Instagram duplicate these information and if it's possible for them to have different values.
I tried to upload an image without a caption and added caption later but the media.caption.created_time simply inherits the value from media.created_time.
I don't know how to let other people to add/edit caption of my own image, so now sure if media.caption.from can be different from media.user.
Could anyone advise on this?

Resources