trainMessage method
Train the intent with a message (text that the bot will respond to the users).
{message} is the message you want to train the intent with.
training a message doesn't delete the previous messages. Instead, it will add the new message to the list.
Implementation
Future<void> trainMessage({
required String message,
}) async {
try {
Uri url = Uri.parse("${GetIt.I<BotnoiClient>().endpoint}/developer/platform-api/training/mapping");
http.Response response = await http.post(
url,
headers: _getHeader,
body: jsonEncode({
"bot_id": _bot.id,
"intent": _intent.name,
"message": message,
}),
);
if (response.statusCode == 200) {
GetIt.I<BotnoiClient>().finishedSuccessfully();
return;
}
GetIt.I<BotnoiClient>().finishedFailed();
GetIt.I<BotnoiClient>().error.add(response.reasonPhrase ?? "ERROR");
} catch (e) {
GetIt.I<BotnoiClient>().finishedFailed();
GetIt.I<BotnoiClient>().error.add(e.toString());
}
}