Skip to content
Last updated

Dynamic Data Sources (RPC)

Sources provide dynamic dropdown options in action forms. Define them at the miniapp root level under source, and reference them in parameters via x-source.

// MiniApp root level
source: {
  // Each key must start with "rpc_"
  rpc_channels_list: {
    url: 'https://slack.com/api/conversations.list?limit=1000&types=public_channel,private_channel',
    method: 'GET',
    headers: {
      Authorization: 'Bearer [[accessToken]]',
    },
    dataPath: 'channels',         // JSONPath to the array in the response
    valueField: 'id',             // Field to use as the option value
    labelField: 'name',           // Field to use as the option label
  },

  rpc_users_list: {
    url: 'https://slack.com/api/users.list?limit=1000',
    method: 'GET',
    headers: {
      Authorization: 'Bearer [[accessToken]]',
    },
    dataPath: 'members',
    valueField: 'id',
    labelField: 'profile.real_name',  // Supports nested paths
  },
},

// Then reference from action parameters:
actions: [{
  parameters: {
    properties: {
      channel: {
        type: 'string',
        title: 'Channel',
        'x-source': 'rpc_channels_list',  // ← Matches key in source
        'x-fallback': 'input',
      },
    },
  },
}]

Source definition fields:

FieldTypeRequiredDescription
urlstringAPI endpoint URL (supports [[cred]] placeholders)
methodstringHTTP method (GET or POST)
headersobjectRequest headers
queryParamsobjectAdditional query parameters
dataPathstringPath to the array in the API response
valueFieldstringField name to use as the option value
labelFieldstringField name to use as the option label
valueFieldsobjectAlternative value fields per sourceRef context

How it works at runtime:

  1. User opens the action form
  2. Frontend calls miniAppsActionSources GraphQL query with the sourceKey
  3. Backend fetches the source URL with the user's credentials injected
  4. Response array is extracted from dataPath
  5. Each item is mapped to { value, label } using valueField and labelField
  6. Dropdown renders with the options