Dialogflow V2 API call Javascript

Viewed 112

I have a question for you guys. In Dialogflow API V1 I've used the following code to connect my chatbot widget to Dialogflow API V1:

function send(query) {
  var text = query;
  $.ajax({
    type: "POST",
    url: baseUrl + "query?v=20180101",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    headers: {
      "Authorization": "Bearer " + accessToken
    },
    data: JSON.stringify({ query: text, lang: "en", sessionId: "somerandomthing" }),
    success: function(data) {
      setResponse(data);
    }
  });
}

This is not working anymore, and I can't get it to work when I try to connect it to V2 - even when I read the specified docs for V2 -. Do you guys have an example for me how I can fix it? I've tried different solutions, but none of them work for me: eg.: Dialogflow V2 API

Maybe I can try to call the REST API? I don't feel comfortable using Node.js, because of the fact that I don't know how to do programming in that language. Thanks for your help.

0 Answers
Related