IBM WatsonX Knowledge With Milvus To Construct a Slack Bot – DZone – Uplaza

In at present’s fast-paced work surroundings, fast and easy accessibility to info is essential for sustaining productiveness and effectivity. Whether or not it is discovering particular directions in a runbook or accessing key information switch (KT) paperwork, the power to retrieve related info swiftly could make a major distinction.

This tutorial will information you thru constructing an clever Slack bot that leverages IBM WatsonX.information and Milvus for environment friendly information retrieval. By integrating these instruments, you may create a bot that may search and supply solutions to queries primarily based in your group’s information sources. We are going to use IBM WatsonX.information to populate and question related paperwork and IBM WatsonX.ai to reply questions from the fetched paperwork.

The tutorial is split into two primary elements: the primary focuses on populating the database utilizing both IBM WatsonX Knowledge or open-source Milvus, and the second half reveals easy methods to run a Python program domestically to attach the bot to Slack, leveraging WatsonX.ai for clever responses to consumer queries.

By the top of this tutorial, you may have a completely useful Slack bot that enhances your staff’s means to entry and make the most of necessary info, boosting general productiveness.

Conditions

Earlier than you start, guarantee you’ve the next:

  • IBM Cloud account: Entry to IBM WatsonX.ai and WatsonX Knowledge for information retrieval and AI mannequin integration
  • Milvus vector database: Familiarity with Milvus for storing and querying vectorized information; you need to use both the open-source Milvus or IBM’s managed Milvus service.
  • Slack workspace: Administrator entry to configure and deploy a Slack bot inside your workspace
  • Programming information: Proficiency in Python, together with expertise with APIs, working with cloud companies, and dealing with surroundings variables

Step 1: Setting Up WatsonX.information and WatsonX Challenge

Set Up WatsonX.information

  1. Create an IBM Cloud account: Join at IBM Cloud in the event you do not have already got an account.
  2. Create a WatsonX.information occasion: Within the IBM Cloud catalog, seek for and create a WatsonX.information occasion by selecting up the plan and offering the mandatory particulars.

Set Up WatsonX Challenge

  1. Create a WatsonX Challenge: On the IBM Cloud Dashboard, navigate to the WatsonX dwelling web page and launch the watsonx.ai beneath capabilities. Create a sandbox venture.
  2. Receive Challenge ID and URL:
    • Navigate to the Handle web page of your WatsonX venture to find the Challenge ID.
    • Inside your newly created venture, beneath the “Manage” tab, choose “Services & integrations” on the left menu. 
    • Choose the blue “Associate service +” button. Select the accessible “Watson Machine Learning” service identify from the listing.
    • Determine the URL of the Watson Machine Studying occasion related together with your venture. This URL varies primarily based on the area the place your ML occasion is created and will probably be within the following format: https://.ml.cloud.ibm.com.
      • Dallas: https://us-south.ml.cloud.ibm.com
      • London: https://eu-gb.ml.cloud.ibm.com
      • Frankfurt: https://eu-de.ml.cloud.ibm.com
      • Tokyo: https://jp-tok.ml.cloud.ibm.com

Step 2: Setting Up Milvus Server

You’ll be able to arrange the Milvus server in two methods: utilizing IBM WatsonX.information or the open-source Milvus database.

Setting Up Milvus Utilizing IBM WatsonX.information

  1. Log in to the WatsonX.information Console.
  2. Navigate to Infrastructure Supervisor.
  3. Add Milvus Service:
    • Click on Add element and choose Add service.
    • Choose Milvus from the Kind listing.
  4. Configure the Milvus Service:
    • Show Identify: Enter the Milvus service identify.
    • Add Storage Bucket: Affiliate an exterior bucket or choose an IBM-managed bucket for the Starter dimension.
  5. Provision the Milvus Service: Click on Provision.

Create Knowledge Supply Connection to Milvus

  1. In Your WatsonX.ai Challenge:
    • Beneath the “Asset” tab, choose New asset +.
  2. Hook up with Knowledge Supply:
    • Select the tile Join to an information supply.
    • Seek for Milvus and click on Choose.
  3. Present Connection Particulars:
    • Title: Enter a title to your connection (e.g., “Milvus connection”).
    • Milvus Hostname, Port, Database Identify, Username, and Password:
      • Get the Milvus host and port info from the Infrastructure Supervisor (click on the Milvus service to open the Particulars web page).
      • Present the database identify and licensed consumer credentials to entry the Milvus occasion.

Setting Up Open-Supply Milvus Server

1. Allocate Extra Reminiscence to Docker

Enhance Docker reminiscence to not less than 8GB via Docker desktop settings.

2. Obtain Docker Compose Configuration

Create a listing and obtain the Docker Compose file:

mkdir milvus_compose cd milvus_compose wget https://github.com/milvus-io/milvus/releases/obtain/v2.2.8/milvus-standalone-docker-compose.yml -O docker-compose.yml

3. Run Milvus Utilizing Docker Compose

  • Begin Milvus:

    docker compose up -d

  • Confirm containers are operating:

    docker ps -a

Step 3: Making a Slack Utility

Making a Slack Utility

  • Navigate to Slack API.
  • Click on on “Create App” -> “From Scratch”.
  • Present an app identify and choose the workspace the place you wish to deploy your bot.
  • Beneath your Slack software settings, navigate to “OAuth & Permissions.”
  • Click on on “Add an OAuth Scope” and add “channels:history” and “chat:write” as bot token scopes.

Receive Tokens

  1. Get the SLACK_TOKEN from “OAuth & Permissions.”
  2. Get the SIGNING_SECRET from “Basic Information.”

Step 4: Setting Up the Challenge and Operating the Utility

Clone the Repository and Set up Dependencies:

Clone the repository:

git clone https://github.com/PhaniDivi-613/doc-assistant

Navigate to the venture listing and set up the required modules:

cd doc-assistant
pip set up -r necessities.txt

Setup the Atmosphere:

Create an .env file within the venture listing and populate it with the next values collected in earlier steps:

PROJECT_ID=
PROJECT_URL=
IC_API_KEY=
SLACK_TOKEN=
SIGNING_SECRET=

Populate the Database With Runbooks:

  1. Place all runbooks or information switch paperwork within the knowledge_source folder.
  2. Populate the database by operating the populate_db.pyscript:
python populate_db.py --opensource-milvus  # Use this flag if utilizing open-source Milvus
python populate_db.py  # Use this if utilizing IBM watsonx.information

Run Your Python App and Create a Tunnel With Ngrok:

Begin your Python Flask software:

python3 app.py --opensource-milvus  # If utilizing open-source Milvus
python3 app.py  # If utilizing IBM watsonx.information

In a brand new terminal window, create a tunnel utilizing ngrok:

Copy the forwarding URL from the ngrok terminal output.

Replace Slack Configuration

  1. In your Slack software settings, navigate to “Event Subscriptions.”
  2. Replace the “Request URLs” discipline together with your ngrok URL adopted by /events-endpoint.
  3. Add bot consumer occasions:
    • message.channels
    • message.channels
  4. Save the modifications in your Slack software settings.

Work together With Your App

  1. Invite your bot to the Slack channel the place you need it to function.
  2. Within the Slack channel, ship a message to set off the bot. For instance:
    @dev-assistant The right way to get atracker account settings utilizing CLI?
  3. Await the bot to course of your request and generate a response.

Conclusion

By following these steps, you’ve efficiently arrange a Slack software built-in with a Milvus database for information administration. Now you can work together together with your bot in Slack, check its performance, and expertise its AI-powered capabilities. This setup permits for environment friendly question dealing with and clever responses primarily based on the supplied runbooks and information sources.

Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Exit mobile version