Skip to content

Build an HTTP Service With BI Copilot

In this tutorial, you’ll create an HTTP service to add key-value pairs to a Redis database. The integrated AI-assistant will help you generate the integration flow.

Prerequisites

  • Docker installed on your machine.

Step 1: Create a new integration project

  1. Click on the BI icon on the sidebar.
  2. Click on the Create New Integration button.
  3. Enter the project name as RedisService.
  4. Select project directory location by clicking on the Select Location button.
  5. Click on the Create New Integration button to create the integration project.

Step 2: Create a new integration

  1. In the design view click on the Generate with AI button.
  2. Enter the following prompt and press Enter:

     Create an integration service with a base path of /cache and a POST resource at /add that accepts key-value pairs and adds them to Redis.
    

    AI Prompt

  3. As shown, click on Keep if the generated integration is as expected. Otherwise, you can keep generating until you get the desired integration.

  4. The generated integration will look like below:

    Generated integration

Step 3: Add a resource to get value

  1. Add the following prompt and press Enter:
     Add a resource to get the value of a key from Redis.
    
  2. Click on Keep button after reviewing the generated integration to add it to the project.
  3. The generated integration will look like below:

    Add get resource

Step 4: Start the Redis server

  1. Start the Redis server by running the following command:
    docker run --name some-redis -d -p 6379:6379 redis
    
  2. The redis server will start on port 6379 without password protection.

    Start Redis

Step 5: Configure the Redis client

  1. In the Design View, click on the Configure button on the top-right side.
  2. Set redisHost value to localhost.
  3. Set redisPort value to 6379.
  4. Set redisPassword value to "".

Note: No need to set the above values if the configurable variables are generated with default values.

Configurations

Step 6: Test the integration

  1. Click on the Run button to start the integration.
  2. Tweak and execute the generated curl commands from the AI response to add a key-value pair.

    curl -X POST http://localhost:8080/cache/add -H "Content-Type: application/json" -d '{"key": "BI", "value": "BI is an AI-assisted integration platform."}' 
    {"message":"Successfully added to cache", "key":"BI"}
    

  3. Execute the generated curl command to get the value of the key.

    curl http://localhost:8080/cache/BI
    

  4. The response will be the value of the key BI stored in the Redis server.
    BI is an AI-assisted integration platform.
    

Step 7: Stop the integration

  1. Click on the Stop button to stop the integration.
  2. Stop the Redis server by running the following command:
    docker stop some-redis