DialogflowGrpcCX.viaServiceAccount constructor
DialogflowGrpcCX.viaServiceAccount(
- ServiceAccount account
Creates a SessionsClient using a service account. From the service account it will get authentication and the Dialogflow project id. It uses a UUID to create a unique session
import 'package:dialogflow_grpc/v2.dart';
import 'package:dialogflow_grpc/generated/google/cloud/dialogflow/v2/session.pb.dart';
import 'package:dialogflow_grpc/dialogflow_auth.dart';
final serviceAccount = ServiceAccount.fromString(
'${(await rootBundle.loadString('assets/credentials.json'))}');
DialogflowGrpcV2 dialogflow = DialogflowGrpcV2.viaServiceAccount(serviceAccount);
Implementation
factory DialogflowGrpcCX.viaServiceAccount(ServiceAccount account) {
var projectId = account.projectId;
var uuid = Uuid().v4();
DialogflowAuth.session = 'projects/$projectId/agent/sessions/$uuid';
return DialogflowGrpcCX._(account.callOptions);
}