Is there any way to implement DialogFlow-cx directly with React native App as DialogFlow ES version does? I am trying with the REST API also But not working.
I want to Call the Dialogflow CX API from my React-Native App.But I am getting 404, I have downloaded the private key as a JSON file from the service Account also. Here is a sample code that I have tried
let data = {
"queryInput": {
"text": {
"text": "Hi!"
},
"languageCode": "en"
},
"queryParams": {
"timeZone": "Asia/Colombo"
}
}
fetch(DEFAULT_BASE_URL this.projectId "/locations/" this.location "/agent/" this.agentId "/sessions/" this.sessionId ":detectIntent", {
method: "POST",
headers: {
'Content-Type': 'application/json; charset=utf-8',
'Authorization': 'Bearer ' this.accessToken,
'charset': "utf-8"
},
body: JSON.stringify(data)
})
.then(function (response) {
console.log("RESPONSE=== ");
console.log(response);
// var json = response.json().then(onResult)
})
.catch(onError);
};
CodePudding user response:
I changed the agent to agents in URL and it worked. Here is a reference doc From Google https://cloud.google.com/dialogflow/cx/docs/quick/api