askBot static method
Implementation
static Future<void> askBot(String receiverId, String receiverType, String botId, String question, {Map? configuration, required Function(String conversationSummary) onSuccess, required Function(CometChatException e) onError}) async{
try{
if(receiverId.isEmpty){
onError(CometChatException(ErrorCode.errorInvalidReceiverId, ErrorMessage.errorMessageInvalidReceiverId, ErrorMessage.errorMessageInvalidReceiverId));
}else if(receiverType.isEmpty){
onError(CometChatException(ErrorCode.errorInvalidReceiverType, ErrorMessage.errorMessageInvalidReceiverType, ErrorMessage.errorMessageInvalidReceiverType));
}else if(botId.isEmpty){
onError(CometChatException(ErrorCode.errorEmptyBotID, ErrorMessage.errorEmptyBotID, ErrorMessage.errorEmptyBotID));
}else if(question.isEmpty){
onError(CometChatException(ErrorCode.errorEmptyAskBotQuestion, ErrorMessage.errorEmptyBotID, ErrorMessage.errorEmptyBotID));
}else{
final arguments = {
"receiverId": receiverId,
"receiverType": receiverType,
"configuration": configuration,
"question": question,
"botId": botId
};
final result = await channel.invokeMethod('askBot', arguments);
String stringResult = result;
onSuccess(stringResult);
}
} on PlatformException catch (e) {
debugPrint("Error: $e");
onError(CometChatException(e.code, e.details, e.message));
} catch (e) {
debugPrint("Error: $e");
onError(CometChatException(ErrorCode.errorUnhandledException, e.toString() , e.toString()));
}
}