0 purchases
slang bfsi assistant
Slang BFSI Assistant #
Install the Slang BFSI Assistant package #
Run the below command to install the required packages inside your code repo.
flutter pub add slang_retail_assistant
Once done, run the command 'dart pub get' and ensure Slang assistant is added to the dependencies.
dependencies:
slang_bfsi_assistant: ^2.0.2
copied to clipboard
Code Integration #
Initialization #
The next step is to initialize the SDK with the keys you obtained after creating the Assistant in the Slang console.
NOTE
This should ideally be done inside the main method.
import 'package:slang_bfsi_assistant/slang_bfsi_assistant.dart';
//Obtain the AssistantId and APIKey for the given assistant
var assistantConfig = AssistantConfiguration()
..assistantId = "<AssistantId>"
..apiKey = "<APIKey>";
//Initialize the SDK using the configurations specified above
SlangBFSIAssistant.initialize(assistantConfig);
copied to clipboard
NOTE
Before releasing the app to public, make sure the environment variable is set to production. default is set to stage
var assistantConfig = AssistantConfiguration()
..assistantId = "<AssistantId>"
..apiKey = "<APIKey>"
..environment = AssistantEnvironment.production //Set this to .production
copied to clipboard
Show the Trigger (microphone icon) #
NOTE
One can call "show" and "hide" methods as required to control the visibility of the Assistant
SlangBFSIAssistant.getUI().showTrigger() // There is a corresponding hideTrigger too if needed
copied to clipboard
NOTE
The trigger is sticky, which means that it will show up on all Activities after it is made visible. To prevent the trigger from showing up on specific activities, you will need to call: SlangBFSIAssistant.getUI().hideTrigger()
Implement Actions #
Last but not the least, the app needs to implement the Actions associated with the various User Journeys supported by the Assistant. This can be done as shown below
SlangBFSIAssistant.setOnStockSearchListener(
(stockInfo, searchUserJourney) => {
//Use stockInfo to perform the stock search operation.
print(stockInfo.name),
print(stockInfo.bseCode),
print(stockInfo.nseCode),
print(stockInfo.isinNumber),
print(stockInfo.customId),
print(stockInfo.action),
print(stockInfo.utterance),
});
copied to clipboard
The OnStockSearchListener callback #
(stockInfo, searchUserJourney)
Sample Utterances that could trigger the transaction Info #
"Show me TCS Stock"
"Show me Infosys Stock"
StockInfo Parameter #
The StockInfo contains the breakdown of the original stock search request. Its structure is as described below:
// When the user searches for something like
// Show me TCS Stock
// This is how the StockInfo parameter would be populated
{
"name": "Tata Consultancy Services Limited"
"bseCode": "TCS",
"nseCode": "TCS",
"isinNumber": "INE467B01029",
"customId": "CustomID001",
"action": "search",
"utterance": "Show me TCS Stock"
}
copied to clipboard
NOTE
Action includes :
"search"
"buy"
"sell"
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.