const response = await serverClient.feeds.createFeedGroup({
id: "myid",
activity_processors: [
{ type: "text_interest_tags" },
{ type: "image_interest_tags" },
],
});
Processors
Activity processors enable you to do additional processing on activities after they are posted.
Supported activity processors:
Type | Description |
---|---|
text_interest_tags | Analyzes text content to extract topics |
image_interest_tags | Analyzes image attachments to extract topics |
og_metadata_enrichment | Analyzes Open Graph (OG) metadata of links in activity text to extract topic |
Processors use AI to extract topics from the given sources.
The topics of an activity are stored in the interest_tags
field.
Topic information can be used to query activities or filter feeds based on topics.
Activity topics enable the Stream API to automatically compute users’ interests (what activities a user interacts with). A user’s interest can be used as input for activity selectors and ranking.
Topics can also be set explicitly with the create and update activity endpoints.
Setting up activity processors
You can set up activity processors on the feed group level:
createResponse, err := feedsClient.CreateFeedGroup(ctx, &getstream.CreateFeedGroupRequest{
ID: feedGroupID,
DefaultVisibility: getstream.PtrTo("public"),
ActivityProcessors: []getstream.ActivityProcessorConfig{
{Type: "text_interest_tags"},
},
})
$createResponse = $this->feedsV3Client->createFeedGroup(
new \GetStream\GeneratedModels\CreateFeedGroupRequest(
id: $feedGroupId,
defaultVisibility: 'public',
activityProcessors: [
['type' => 'text_interest_tags']
]
)
);
var createResponse = await _feedsV3Client.CreateFeedGroupAsync(new CreateFeedGroupRequest
{
ID = feedGroupId,
DefaultVisibility = "public",
ActivityProcessors = new List<ActivityProcessorConfig>
{
new() { Type = "text_interest_tags" }
}
});
create_response = self.client.feeds.create_feed_group(
id= feed_group_id,
default_visibility= "public",
)
Reading topics
Whenever a new activity is posted, the processors will run. Interest topics are not computed instantly; they are added with the feeds.activity.updated
event.
try await feed.addActivity(
request: .init(
text: "check out my 10 fitness tips for reducing lower back pain",
type: "post"
)
)
// Wait for feeds.activity.updated event
print(activity.interestTags) // ["fitness", "health", "tips"]
feed.addActivity(
request = FeedAddActivityRequest(
text = "check out my 10 fitness tips for reducing lower back pain",
type = "post"
)
)
// Wait for feeds.activity.updated event
println(activity.getOrNull()?.interestTags) // ["fitness", "health", "tips"]
await feed.addActivity({
type: "post",
text: "check out my 10 fitness tips for reducing lower back pain",
});
// Wait for feeds.activity.updated event
console.log(activity.interest_tags); // ["fitness", "health", "tips"]
await client.feeds.addActivity({
feeds: ["user:1"],
type: "post",
text: "check out my 10 fitness tips for reducing lower back pain",
user_id: "<user id>",
});
// Wait for feeds.activity.updated event
console.log(activity.interest_tags); // ["fitness", "health", "tips"]
feedIdentifier := fmt.Sprintf("%s:%s", userFeedType, testUserID)
response, err := feedsClient.AddActivity(ctx, &getstream.AddActivityRequest{
Type: "post",
Feeds: []string{feedIdentifier},
Text: getstream.PtrTo("This is a test activity from Go SDK"),
UserID: &testUserID,
Custom: map[string]interface{}{
"test_field": "test_value",
"timestamp": time.Now().Unix(),
},
})
AddActivityRequest activity =
AddActivityRequest.builder()
.type("post")
.feeds(List.of(testFeedId))
.text("This is a test activity from Java SDK")
.userID(testUserId)
.build();
AddActivityResponse response = feeds.addActivity(activity).execute().getData();
$activity = new GeneratedModels\AddActivityRequest(
type: 'post',
feeds: [$this->testFeed->getFeedIdentifier()],
text: 'This is a test activity from PHP SDK',
userID: $this->testUserId,
custom: (object)[
'test_field' => 'test_value',
'timestamp' => time()
]
);
$response = $this->feedsV3Client->addActivity($activity);
var activity = new AddActivityRequest
{
Type = "post",
Text = "This is a test activity from .NET SDK",
UserID = _testUserId,
Feeds = new List<string> { $"user:{_testFeedId}" }
};
var response = await _feedsV3Client.AddActivityAsync(activity);
response = self.client.feeds.add_activity(
type="post",
feeds=[self.test_feed.get_feed_identifier()],
text="This is a test activity from Python SDK",
user_id=self.test_user_id,
custom={
"test_field": "test_value",
"timestamp": int(datetime.now().timestamp()),
},
)