Skip to content

RevealBi/sdk-samples-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting Started with Reveal AI Add-On (Private Preview)

This guide will walk you through setting up the Reveal AI Add-On in your existing Reveal SDK application.

⚠️ PRIVATE PREVIEW: This is pre-release software for evaluation only. Not intended for production use. Breaking changes expected before RTM.

Time to Complete: 30-45 minutes


Prerequisites

  • âś… Private preview access granted by your Reveal sales representative
  • âś… NuGet feed credentials (URL, username, and password will be emailed to you)
  • âś… Reveal SDK v1.8.3+ installed and working in your ASP.NET Core app
  • âś… .NET 8.0 SDK installed
  • âś… LLM Provider account (OpenAI or Anthropic recommended)
  • âś… At least one datasource configured in Reveal SDK

Step 1: Install NuGet Package

1a. Add Reveal AI NuGet Feed

Add the Reveal AI NuGet feed to your project using the credentials emailed to you.

dotnet nuget add source YOUR_FEED_URL \
  --name RevealAI \
  --username YOUR_USERNAME \
  --password YOUR_PASSWORD \
  --store-password-in-clear-text

Verify:

dotnet nuget list source
# Should show: RevealAI [Enabled]

1b. Install the Package

Using .NET CLI:

cd YourProject
dotnet add package Reveal.Sdk.AI.AspNetCore
dotnet build

Using Visual Studio:

  1. Right-click on your project in Solution Explorer
  2. Select "Manage NuGet Packages"
  3. Select the "Browse" tab
  4. Check the "Include prerelease" checkbox (required for preview packages)
  5. Search for Reveal.Sdk.AI.AspNetCore
  6. Click "Install"

1c. Optional: Install Client-Side Package

If using the JavaScript API:

npm install @revealbi/api@0.0.1-preview.2

See the @revealbi/api npm package README for client-side usage.


Step 2: Configure LLM Provider

Choose OpenAI (recommended for quick setup) or Anthropic Claude.

Option A: OpenAI (Recommended)

Get API Key:

  1. Visit OpenAI Platform
  2. Create an API key (starts with sk-)

Configure in appsettings.json:

{
  "RevealAI": {
    "DefaultClient": "openai",
    "OpenAI": {
      "ApiKey": "sk-your-api-key-here",
      "ModelId": "gpt-4.1"
    }
  }
}

Option B: Anthropic Claude

Get API Key:

  1. Visit Anthropic Console
  2. Create an API key (starts with sk-ant-)

Configure in appsettings.json:

{
  "RevealAI": {
    "DefaultClient": "anthropic",
    "Anthropic": {
      "ApiKey": "sk-ant-your-api-key-here",
      "ModelId": "claude-sonnet-4-5"
    }
  }
}

Tip: Store your API key in User Secrets rather than committing it to source control.


Step 3: Register AI Services

Update your Program.cs:

using Reveal.Sdk.AI;

var builder = WebApplication.CreateBuilder(args);

// Your existing Reveal SDK setup
builder.Services.AddControllers()
    .AddReveal(revealBuilder =>
    {
        revealBuilder
            .AddAuthenticationProvider<AuthenticationProvider>()
            .AddDataSourceProvider<DataSourceProvider>()
            .AddUserContextProvider<UserContextProvider>();
    });

// Add Reveal AI services
builder.Services.AddRevealAI();

var app = builder.Build();

app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();

app.Run();

Step 4: Configure Metadata Generation

The AI needs metadata about your datasources. Add to appsettings.json:

{
  "RevealAI": {
    "DefaultClient": "openai",
    "OpenAI": {
      "ApiKey": "OPENAI_API_KEY",
      "ModelId": "gpt-4-turbo"
    },

    "MetadataService": {
      "GenerateOnStartup": true
    },

    "MetadataManager": {
      "Datasources": [
        {
          "id": "my-datasource-id",
          "provider": "SQLServer"
        }
      ]
    }
  }
}

Supported Providers: SqlServer, MySQL, Oracle, Postgres, Snowflake, Athena, AnalysisServices, WebService, Excel and CSV.


Step 5: Run and Verify

Start your application:

dotnet run

Watch console output for metadata generation:

MetadataGenerationHostedService starting
Triggering metadata initialization on startup
...
Generating metadata for datasource my-datasource-id
Enriching metadata for datasource my-datasource-id
...
Metadata initialization completed. Metadata is now ready.
Startup metadata initialization completed

Verify metadata files were created:

# Windows
dir %USERPROFILE%\.reveal\ai\metadata\

# Linux/Mac
ls ~/.reveal/ai/metadata/

You should see files like:

  • my-datasource-id_index.json
  • my-datasource-id_MyDB_Orders.json
  • etc.

Step 6: Test Dashboard Generation (Server-Side)

Test the AI dashboard generation endpoint:

Using curl:

curl -X POST http://localhost:5000/api/reveal/ai/dashboards \
  -H "Content-Type: application/json" \
  -d "{\"userPrompt\": \"Show me total sales by region\", \"datasourceId\": \"my-datasource-id\"}"

Expected Response:

{
  "dashboard": "{...dashboard JSON...}",
  "explanation": "I've created a dashboard showing total sales by region..."
}

Step 7: Set Up Client-Side API (Optional)

If you want to use the JavaScript/TypeScript API for insights and chat in your web application:

7a. Install the Client Package

npm install @revealbi/api@latest

7b. Initialize the Client

TypeScript/JavaScript:

import { RevealSdkClient } from '@revealbi/api';

// Initialize the client with your server endpoint
const client = new RevealSdkClient({
  serverUrl: 'http://localhost:5000'
});

7c. Generate Dashboards

// Generate a dashboard from natural language
const result = await client.ai.dashboards.generate({
  userPrompt: 'Show me total sales by region',
  datasourceId: 'my-datasource-id'
});

console.log('Dashboard JSON:', result.dashboard);
console.log('Explanation:', result.explanation);

7d. Use Chat Interface

// Send a chat message
const chatResponse = await client.ai.chat.sendMessage({
  question: 'What were the top 5 products last quarter?',
  datasourceId: 'my-datasource-id',
  dashboard: revealView.dashboard //the current dashboard (optional)
});

console.log('AI Response:', chatResponse.explanation);
console.log('AI Dashboard:', chatResponse.dashboard);

7e. Get Widget Insights

// Analyze an existing widget for insights
const insights = await client.ai.insights.get({
  widgetId: 'widget-123',
  dashboardId: 'dashboard-abc'
});

console.log('Insights:', insights);

7f. List Available Datasources

// Get list of datasources
const datasources = await client.ai.datasources.list();

datasources.forEach(ds => {
  console.log(`${ds}`);
});

7g. Check Metadata Status

// Check metadata generation status for a datasource
const status = await client.ai.metadata.getStatus();

console.log('Status:', status.status);

For complete API documentation and advanced usage, see the @revealbi/api npm package README.


Success Checklist

  • NuGet feed configured with credentials emailed to you
  • NuGet package Reveal.Sdk.AI.AspNetCore installed
  • LLM provider configured (OpenAI or Anthropic)
  • AddRevealAI() registered in Program.cs
  • Application builds without errors
  • Metadata files generated in ~/.reveal/ai/metadata/
  • POST to /api/reveal/ai/dashboards returns dashboard JSON
  • No errors in console logs

Questions? Contact your Reveal sales representative

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •