Skip to content

Data sources

Data sources turn input fields into dropdowns. Use a static data source for a fixed set of choices and a dynamic one for options retrieved from the connected system.

This example compiles in the Setup project. The dynamic handler uses a small in-memory article fixture so you can test filtering without a provider account. Replace the fixture lookup with your provider client when building the integration.

using Blackbird.Applications.Sdk.Common;
using Blackbird.Applications.Sdk.Common.Dictionaries;
using Blackbird.Applications.Sdk.Common.Dynamic;
using Blackbird.Applications.Sdk.Common.Exceptions;
using Blackbird.Applications.Sdk.Common.Invocation;
namespace Apps.DataSourceExample;
public class ChannelDataSource : IStaticDataSourceItemHandler
{
public IEnumerable<DataSourceItem> GetData() =>
[
new("blog", "Blog"),
new("help", "Help center")
];
}
public class ArticleRequest
{
[Display("Channel")]
[StaticDataSource(typeof(ChannelDataSource))]
public string Channel { get; set; } = string.Empty;
[Display("Article")]
[DataSource(typeof(ArticleDataSource))]
public string ArticleId { get; set; } = string.Empty;
}
public class ArticleDataSource : BaseInvocable, IAsyncDataSourceItemHandler
{
private readonly ArticleRequest _input;
public ArticleDataSource(InvocationContext context,
[ActionParameter] ArticleRequest input) : base(context) => _input = input;
public Task<IEnumerable<DataSourceItem>> GetDataAsync(
DataSourceContext context, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
if (string.IsNullOrWhiteSpace(_input.Channel))
throw new PluginMisconfigurationException("Choose a channel before selecting an article.");
var articles = new[]
{
(Id: "article-1", Name: "Product launch", Channel: "blog"),
(Id: "article-2", Name: "Getting started", Channel: "help")
};
IEnumerable<DataSourceItem> options = articles
.Where(item => item.Channel == _input.Channel)
.Where(item => string.IsNullOrWhiteSpace(context.SearchString)
|| item.Name.Contains(context.SearchString, StringComparison.OrdinalIgnoreCase))
.Select(item => new DataSourceItem(item.Id, item.Name))
.ToArray();
return Task.FromResult(options);
}
}

A DataSourceItem has a stored value and a displayed label. Return stable provider IDs as values even if the labels change.

Use ArticleRequest as an [ActionParameter] on your action. Blackbird displays the channel choices and passes the selected channel to the article handler. The constructor is public so the platform can instantiate it.

For event parameters, use the event’s parameter attribute and request model. Avoid mixing a webhook input model with an unrelated action input model.

Create a client from InvocationContext.AuthenticationCredentialsProviders, as shown in Connections. Apply provider-side search and pagination where available, pass cancellation to I/O, and return a useful configuration error if a required parent field is missing.

Static choices must have unique stored values. Dynamic dropdowns should honor SearchString and return only choices the connected account can use.