Custom Networks
UmbSocial ships six networks. You can add another one, as long as an Umbraco Automate provider can post to it: register a network definition in a composer. The network then works like the built-in ones: channels, managed automations, limits, live counts and outcomes.
What you need
Section titled “What you need”- An Automate provider package with a connection type for the network and a post action. The post action should return the live post’s URL in an output field called
postUrl, if it can, so Social can show the link. - The provider’s action should fail with a validation, authentication or rate-limiting error only when the network definitely refused the post. Social treats any other failure as Unknown (the post may be live). See Publishing lifecycle.
Register the network
Section titled “Register the network”using System.Text.RegularExpressions;using UmbSocial.Core.Automate;using UmbSocial.Core.Networks;using Umbraco.Cms.Core.Composing;using Umbraco.Cms.Core.DependencyInjection;
public class ThreadsComposer : IComposer{ public void Compose(IUmbracoBuilder builder) => builder.AddSocialNetwork(new SocialNetworkDefinition( new AutomationTemplate( Network: "threads", DisplayName: "Threads", ConnectionTypeAlias: "threads", ActionAlias: "threads.createPost", Bindings: new Dictionary<string, string> { ["text"] = "${ trigger.text }", ["imageUrl"] = "${ trigger.imageUrl }", ["imageAltText"] = "${ trigger.imageAltText }", }, ChannelSettings: new Dictionary<string, Regex>(), ChannelDefaults: new Dictionary<string, string>()), new TextLimit(MaxCharacters: 500, UrlWeight: null, CountsGraphemes: true, RequiresImage: false)));}The network is offered for new channels once the provider’s connection type (ConnectionTypeAlias) is installed in Automate.
The template
Section titled “The template”AutomationTemplate describes the network’s managed automation:
| Parameter | Use |
|---|---|
Network |
The network id, stored on each channel. 1 to 50 lowercase letters, digits or dashes, starting with a letter or digit. |
DisplayName |
The network’s name as people see it. The post step in the automation is named after it. |
ConnectionTypeAlias |
The alias of the provider’s Automate connection type. A channel’s connection must be of this type. |
ActionAlias |
The alias of the provider’s post action. Social reads the run’s step with this action to decide the outcome. |
Bindings |
Post action setting → a binding on the trigger’s output, such as ${ trigger.text }. The fields are listed in Automate integration. |
ChannelSettings |
Channel option → the regular expression its value must match. Values are copied into the post step as literals, so make the patterns exclude Automate bindings (${ … }) and configuration references ($Config:…). An option is required unless it has a default. |
ChannelDefaults |
Values for options a channel leaves out. |
The limits
Section titled “The limits”TextLimit tells Social how the network counts text and what it requires:
| Parameter | Default | Use |
|---|---|---|
MaxCharacters |
(required) | The most characters the network accepts. |
UrlWeight |
(required) | What each link counts as, or null to count it in full. |
CountsGraphemes |
(required) | Count characters as people see them (an emoji counts as 1), rather than code points. |
RequiresImage |
(required) | The network needs an image. |
WeightsWideCharacters |
false |
Characters above U+10FF (emoji, Chinese, Japanese, Korean and similar) count as 2. |
RequiresLinkTitle |
false |
A post with a link needs a link title. |
SupportsAltText |
true |
The post action sends the image’s alt text. |
Link |
InText |
How the network takes the link: Card (sent separately), InText (added to the end of the text and counted) or NotSent. |
LinkOrImage |
false |
A post can have a link or an image, not both. |
With Link = InText (the default), the link is already in ${ trigger.text }. With Card, bind ${ trigger.linkUrl } (and the title and description) to the action’s link settings.
- Built-in networks can’t be replaced. Registering
bluesky,mastodon,linkedin,x,facebookorinstagramthrows anInvalidOperationException. - A network id can be registered once. A second registration throws an
InvalidOperationException. - An invalid network id throws an
ArgumentException. - Register in a composer, so the network is known before the site starts.
- If you later remove a network’s registration, its channels can’t get a new automation (
channel.network_unavailable), and Social can no longer find the post step in their runs, so their outcomes are recorded as Unknown (or Failed when the run failed).