简体   繁体   中英

webhook not working in API.ai

I have the following custom javascript code for API.AI. I have implemented a simple webhook in php to receive data on certain action. Whenever I check in API.AI console it is working fine. But with the following code it gives Webhook call failed. Error: Webhooks can be used with version '20150415' or greater. Webhook call failed. Error: Webhooks can be used with version '20150415' or greater. error. Please help.

         $.ajax({
                type: "POST",
                url: baseUrl + "query",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                headers: {
                    "Authorization": "Bearer " + accessToken
                },

                data: JSON.stringify({query: text, lang: "en", sessionId: "<?php echo uniqid();?>", v:"20170712"}),
                success: function(data,url) {
                    console.log(url);
                    prepareResponse(data);
                },
                error: function(text) {
            console.log(text);
                    respond(messageInternalError);
                }
            });

As qnguyen mention in a comment you must have ?v=20150910 in your url. For example: https://api.dialogflow.com/v1/query?v=20150910

See https://dialogflow.com/docs/reference/agent/query for more info

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM