ballerinax/azure.qnamaker Ballerina library

1.5.1

Overview

This is a generated connector for Azure QnA Maker API v4 OpenAPI specification. The Azure QnA Maker API is a cloud-based Natural Language Processing (NLP) service that allows you to create a natural conversational layer over your data. It is used to find the most appropriate answer for any input from your custom knowledge base (KB) of information. QnA Maker is commonly used to build conversational client applications, which include social media applications, chat bots, and speech-enabled desktop applications.

This module supports Azure QnA Maker API v4.

Prerequisites

Before using this connector in your Ballerina application, complete the following:

Quickstart

To use this connector in your Ballerina application, update the .bal file as follows:

Step 1: Import connector

Import the ballerinax/azure.qnamaker module into the Ballerina project.

Copy
import ballerinax/azure.qnamaker;

Step 2: Create a new connector instance

You can now make the connection configuration using Ocp-Apim-Subscription-Key.

You can do this step in two ways. You can use any one of this.

  • Option 1 : Configure API Keys in ballerina file directly.

    Copy
    ker:ApiKeysConfig apiKeyConfig = {
    cpApimSubscriptionKey:"<AZURE_API_KEY>"
    ubscriptionKey: "<Subscription Key>"
    
    
    ker:Client myClient = check new Client(apiKeyConfig, serviceUrl = "https://<REGION>.api.cognitive.microsoft.com/qnamaker/v4.0");
  • Option 2 : Configure API Keys in Config.toml file and configure it in ballerina file, using configurables.

    1. Set up API Keys in Config.toml as shown below.
    [apiKeyConfig]
    ocpApimSubscriptionKey = "<AZURE_API_KEY>"
    subscriptionKey = "<Subscription Key>"
    
    1. Configure the client in ballerina file as shown below.
    Copy
    configurable ApiKeysConfig & readonly apiKeyConfig = ?;
    
    qnamaker:Client myClient = check new Client(apiKeyConfig, serviceUrl = "https://<REGION>.api.cognitive.microsoft.com/qnamaker/v4.0");

Step 3: Invoke connector operation

  1. Now you can use the operations available within the connector. Note that they are in the form of remote operations.

    Following is an example on how to get Knowledgebase Details from API.

    Get Knowledgebase Details

    Copy
    public function main() returns error? {
    
        qnamaker:KnowledgebaseDTO res = check baseClient->getKnowledgebaseDetail(kID);
    
    }
  2. Use bal run command to compile and run the Ballerina program.

Import

import ballerinax/azure.qnamaker;Copy

Metadata

Released date: 12 months ago

Version: 1.5.1

License: Apache-2.0


Compatibility

Platform: any

Ballerina version: 2201.4.1

GraalVM compatible: Yes


Pull count

Total: 0

Current verison: 0


Weekly downloads


Source repository


Keywords

IT Operations/Cloud Services

Cost/Freemium

Vendor/Microsoft


Contributors

Other versions

See more...