I try to create activity feed with posts from category.
User can follow category or tags (eq. "Buddhism", "Neuroscience", "Psychology" etc.) When user follow category or many categories I need to create personalized activity feed with posts from categories that user follow.
I know that getstream have posibility to create many feed groups, but how to create activity where category is the actor? Unless I am thinking the wrong way.
I create feed groups like: user, timeline, categories, articles.
Feed group user show only activity that user create like: user like article, user added comment etc.
and categories feed group for post from categories that user follow.
I try to send activity like that:
for (let category in event.result.categories) {
const categoryFeed = client.feed('categories', category.id);
const activity = {
actor: `category:${category.id}`,
verb: 'dodano przepis do kategorii',
object: event.result.id(article ID),
foreign_id: event.result.id(article ID),
created_at: event.result.createdAt,
};
await categoryFeed.addActivity(activity);
}
When I try run this, I see error: "error: Please provide a feed slug and user id, ie client.feed("user", "1")
Error: Please provide a feed slug and user id, ie client.feed("user", "1")"
Is there any way to create thing I need with getstream?
Related
Good Day!
I need help on the below issue:
Goal: is to filter data depending on the department content. What I'm trying to do is to fetch data from MongoDB based on your designation or department. For example, I'm from the Email Team:
I was able to fetch the data correctly using the below code:
return Announcement.find({ department: params.department }).collation({locale:'en',strength: 2}).sort({createdOn:1}).then(announcement => {
return announcement
})
However, what I'm trying to achieve is to get the data from the "All" department. For example, Email Team data plus the All data. This is a notification app. Wherein agents will receive or be notified if there are news recently published.
Example: As admin I have the option to assign a news to a specific department. I'm using a ComboBox for the selection: All, Email, Chat, Phone
So, if I selected All, since I'm from the email team, I should be getting the notification too.
After few minutes of research, I found this:
return Announcement.find({ $or: [{"department" : "All"},{department: params.department}]}).collation({locale:'en',strength: 2}).sort({createdOn:1}).then(announcement => {
return announcement
})
In examples on the Get stream Website, I see that they show examples where users are following other users and then they get to see the posts of the user they are following. How can I change this and make it so that users can follow a category(s) instead of a user and then see posts on their feed from the category(s) they are following? Currently, when I make a new post, I add a custom field to capture category id. Not sure what to do next.
I'm using the Get Stream for Laravel.
In Stream a feed can represent anything. So it can be a user, or a timeline (wall) or a category. Simply create a feed for the category and add the activities to it with the TO field. Then your user can follow the category feed.
More information about this can be found on the official docs: https://getstream.io/docs/#targetting
I am making a bot for booking rooms. For booking rooms a user can choose "Premium Service" or "Standard Service".
However the hotels available to be booked depends on "Premium" or "Standard".
How to do this in dialog flow?
I tried to set entities "Service_type" and "Hotels". However how to set values for entity "Hotels" based on "Service_type" the user has selected?
Please note that the intent of the bot is book rooms. And there are many other steps to be followed to complete it.
You can start by creating an entity like quality and it's helpful to think of other ways that the user might refer to the quality that you define as "standard" and "premium"
Now when you create your intents you should see that Dialogflow automatically detects your entity in the training phrases
If Dialogflow doesn't already detect your entity, you can highlight a word in the training phrase and associate it to a type of your choosing
That's the easy part.
In order to present a different set of hotels depending on which standard that was selected, you should look into developing a fulfillment endpoint that handles the logic.
The quality choice that the user made in the first question will be passed as a parameter and you can easily make conditional logic to select hotels depending on that
conv.ask(`Here is a list of ${quality} hotel options for you`);
if (quality === "premium") {
conv.ask(getPremiumHotelOptions()); // Carousel or list
} else {
conv.ask(getStandardHotelOptions()); // Carousel or list
}
You can create an empty Hotels entity and then populate it with the relevant entity values for that session in your fulfillment webhook.
If you're using node.js for your webhook, you can look into the Dialogflow library to do much of this work. The call might look something like this:
const sessionEntityTypeRequest = {
parent: sessionPath,
sessionEntityType: {
name: sessionEntityTypePath,
entityOverrideMode: entityOverrideMode,
entities: entities,
},
};
const [response] = await sessionEntityTypesClient.createSessionEntityType(
sessionEntityTypeRequest
);
(See a more complete example at https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/resource.js in the createSessionEntityType() function)
I want to implement a news feed where users can post both private ( shared ) and public activities. The difference between the two is public activities are shown in all the user's news feed and private activities are shown to all of my followers news feed.
I have been reading some resources about implementing news feed and I have come across this open source project.
Quoting from the documentation
Next up we want to start publishing this activity on several feeds. First of all we want to insert it into your personal feed, and then into your followers' feeds
Now this works well for private activities, I post the activity to author's own feed as well as all of my followers feed.
But the issue is when the activity is public. In this case I have to post it to user's own feed as well as all other users in the system so that this activity is shown in their feed.
Suppose there are 1 million users in the system than this will require posting to 1 million feeds (possibly 1 million DB records). I believe this is not correct.
I thought of separating out public activities in other collection and these activities are visible to all. This issue with this solution is suppose I want to retrieve a user's feed than how do I combine data from user's followers feed with public feed.
Consider this example.
User A has 10 followers and they posted 10 activities in total. So User A's feed has 10 activities from his followers. Now there is User B which user A does not follow. User B also posted 2 public activities. Now the user A's feed should have 12 activities (10 from followers + 2 from user B public activities) so I do I combine data from these two collection and implement sorting, filtering etc on the combined result set.
Additional Info:
platform: node.js
DB: rethinkdb
A possible solution is to setup a notifications table that contains the private and public feeds, with an index on for.
To insert a private notification:
r.table('notifications')
.insert({'for': ['user', 'sonia'], message: "you've got mail"})
To insert a public notification:
r.table('notifications')
.insert({'for': ['public'], message: 'hello, world'})
Meanwhile, use getAll to select which notifications to subscribe too:
r.table('notifications')
.getAll(['public'], ['user', 'sonia'], {index: 'for'})
.changes()
If your notifications are stored across multiple tables, you can use union to combine them into a single changefeed, for example:
r.table('notifications').getAll('sonia', {index: 'for'})
.union(r.table('public_notifications'))
.changes()
I'm building an activity feed application, where a user can like/comments on each activity feed. I went through GetStream.io documentation and looks like I'll have to send the activity with object ids.
{
id:"ef696c12-69ab-11e4-8080-80003644b625",
actor:"User:1",
object:"Comment:12",
started_at:"2014-11-11T15:06:16+01:00",
target:"Feed:100",
time:"2014-11-11T14:06:30.494",
verb:"add"
}
User:1 and Feed:12 are the objects in my application database? Does it mean that, while retrieving activities, I'll have to hit my database to retrieve the complete feeds?
Say the Feed:12 had few likes and comments earlier from other users. How do I get the complete set of likes/comments on user timeline feed?
What if I want to customize the view, say I want to show all users (image, name, the profile like etc) along with comment with timestamp similar to FB? Do I need to send these attributes as additional parameters for each feed?
Thanks,
Yes, when you fetch a feed from Stream and we give you back these references like user:1 or comment:12, we expect that you'd "enrich" those details from your database.
Typically what our users do is track the name of the model (eg, user) and the user_id (eg, 1). When you get the feed and put it into a hash map, you'll iterate over the activities, pull out all of the actor attributes, and do a single lookup like select * from user where id in (1,3,5,6,9,12) so that you're only hitting your database one time for all user objects or all comment objects or whatever. Then, replace those activities in your hash map so now you'd have actor: <object for User 9> and any other attributes you'd need for your UI presentment.
Then do the same for other references you pass in the activity, and so on.
Things we DON'T recommend are putting in string references for things that could change on your side. For example, if you had actor: "user:ian" instead of my user_id, if I ever change my username later then things probably wouldn't work properly on your side.