I am trying to connect to dialogflow CX through the golang client, but I keep getting the error "failed to get discovery job for dialogflow.googleapis.com:443". This is my code:
import (
dialogflow "cloud.google.com/go/dialogflow/cx/apiv3"
"cloud.google.com/go/dialogflow/cx/apiv3/cxpb"
"golang.org/x/oauth2/google"
"google.golang.org/api/option"
)
....
func detectIntentText(
agentID string,
location string,
sessionID string,
text string,
languageCode string) ([]*cxpb.ResponseMessage, error) {
// This is my service account key
credentials = "{"type": "service_account", "project_id"......"universe_domain", "googleapis.com"}"
jwtConfig, err := google.JWTConfigFromJSON(
[]byte(credentials),
"https://www.googleapis.com/auth/dialogflow"
)
if err != nil {
return nil, err
}
sessionClient, err := dialogflow.NewSessionsClient(ctx, option.WithTokenSource(jwtConfig.TokenSource(ctx)))
if err != nil {
return nil, err
}
...
And this is the error I get upon calling NewSessionsClient
:
level="error" msg="finished unary call with code Internal" error="rpc error: code =
Internal desc = failed to build resolver: failed to get discovery job for
dialogflow.googleapis.com:443: discovery: invalid addr \"dialogflow.googleapis.com:443\",
invalid endpoint \"443\"" grpc.code="Internal" grpc.context.UUID="7643ccb6-60b7-4468-
82f4-4983ab646886"
What am I doing wrong?