Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
PHP Fatal error
On Calling he website http://localhost/api.ai/webhook
it returns {"status":{"code":405,"errorType":"Method Not Allowed"},"speech":"An error occurred."}
Php error log shows: PHP Fatal error: Class 'ApiAi\Model\Query' not found in x:\xxxxxx\api_ai_webhook\src\ApiAi\Model\Webhook\Request.php on line 17
Comment | File | Size | Author |
---|---|---|---|
#4 | cahtbotAPI.png | 10.1 KB | tkrishnapriya |
Comments
Comment #2
tkrishnapriya CreditAttribution: tkrishnapriya as a volunteer and commentedComment #3
gambryIt looks like the ApiAi library is not found. Did you include it either by installing the module through composer or in any other way?
Comment #4
tkrishnapriya CreditAttribution: tkrishnapriya as a volunteer commentedI am adding image attachments in support where i have included all libraries that is installed and enabled. But in-fact i have not used composer to do so. Is composer vital in installing those modules. I don’t receive proper json response on call to localhost/api.ai/webhook. And i am unable to use Entity Collection interface as well and it returns
[php7:notice] [pid 5188:tid 1784] [client ::1:53600] Uncaught PHP Exception UnexpectedValueException: “In order to use the api.ai remote entity push, you need to add your developer token to settings.php. E.g. $settings[‘api_ai_webhook_developer_token’] = ‘your token here’.
modules\\api_ai_webhook\\src\\Plugin\\ChatbotApiEntities\\PushHandler\\ApiAiPushHandler.php line 142, referer: config/service/chatbot-api-entity-collection/add
Comment #5
gambryHi @tkrishnapriya . The ones in your image are the modules, no the PHP libraries required.
If you check the main page of this module, it says:
Check Installing modules' Composer dependencies and also Using Composer to manage Drupal site dependencies for some approaches on how to handle this.
External dependencies is a Drupal thing, not Chatbot related, so by learning this you will be ready next time a module requires external dependencies.
RE: Entities, please follow what the error is saying, so get your developer key from Dialogflow and add them to the settings.php as explained.
Comment #6
tkrishnapriya CreditAttribution: tkrishnapriya as a volunteer commentedHi, Correct i didn't include iboldurev/api-ai-php php library earlier , but now i have used composer to get the libaray. Now i have iboldurev/api-ai-php php folder is at root of my drupal installation in vendor folder i.e. drupal/vendor/iboldurev/api-ai-php php. But still facing the same issue.
{"status":{"code":405,"errorType":"Method Not Allowed"},"speech":"An error occurred."}
Any other issue that might be the cause. What else do i needd to provide for your reference for better understanding the issue here with me.
Comment #7
tkrishnapriya CreditAttribution: tkrishnapriya as a volunteer commentedNow i am able to add entities and added developer key from Dialogflow and add them to the settings.php.
Comment #8
tkrishnapriya CreditAttribution: tkrishnapriya as a volunteer commentedStill i have iboldurev/api-ai-php php folder is at root of my drupal installation in vendor folder i.e. drupal/vendor/iboldurev/api-ai-php php. But still facing the same issue.
{"status":{"code":405,"errorType":"Method Not Allowed"},"speech":"An error occurred."}
Entity collections are added in Drupal as of now but still it is not pushed to Dialogflow console after running cron also
Comment #9
gambry@tkrishnapriya you may have
composer require iboldurev/api-ai-php
without specifying the version.The owner of the library changed the namespace root from ApiAi to Dialogflow, so unless you don't require version 0.2.5 you will keep getting that error. There is an issue to upgrade to the new package: #2919447: Migrate to iboldurev/dialogflow package
If that's the case please try
composer require iboldurev/api-ai-php:0.2.5
.You need to give more info about this:
- Are you using Dialogflow API V1?
- Any error in the logs?
Comment #10
tkrishnapriya CreditAttribution: tkrishnapriya as a volunteer commentedHi, Actually i had installed iboldurev/dialogflow library, after your comments i installed iboldurev/api-ai-php so both were available. And now i have precisely made it to iboldurev/api-ai-php:0.2.5 and iboldurev/dialogflow is also there.
Regarding Entity collection, I have been using Diglogflow V1 only.
Now as of now i am not seeing any error logs. I am unable to find the flaw.
I find the JSON response being returned by api_ai_webhook\src\EventSubscriber\ResponseEventSubscriber.php
Comment #11
gambrySo is this now working as expected I presume?
Let's fix this issue first, and then we move to the other one.
RE the Entities all you need is really the Entities in drupal and the developer key on settings.php, and after the configuration entities should me pushed on cron.
If this is not working I'm afraid you have to dig and debug a bit more and tell me what's going on. I've build a bot last week and didn't have any issue so I'm quite confident things are working.
Comment #12
tkrishnapriya CreditAttribution: tkrishnapriya as a volunteer commentedYeah, i have precisely made it to iboldurev/api-ai-php:0.2.5 but on accessing the http://localhost/api.ai/webhook i get the JSON response
{"status":{"code":405,"errorType":"Method Not Allowed"},"speech":"An error occurred."}
Which is coming from the location api_ai_webhook\src\EventSubscriber\ResponseEventSubscriber.php
Comment #13
tkrishnapriya CreditAttribution: tkrishnapriya as a volunteer commentedI have re followed all steps and while trying to add entity collection I am seeing in error logs
Uncaught PHP Exception Drupal\Core\Entity\EntityStorageException: "Error getting list of existing remote IDs for Chatbot API entity collection Languages on API.ai" at \modules\api_ai_webhook\src\Plugin\ChatbotApiEntities\PushHandler\ApiAiPushHandler.php line 213.
I am unable to figure out what i am missing. If a elaborated steps for just a sample demo will be very helpful to proceed to play around it.
Comment #14
gambryYou need to report the error too. If the error is still "Class 'ApiAi\Model\Query' not found" the class is not found. So either the class is still missing from the file system (unlikely) or you are not auto-loading the class correctly (most likely).
Before this error watchdog should have another log entry with more info.
The error is due something wrong with the request, out of my mind the only things I can think of are Dialogflow agent is not setup for V1 (I know you said it is, but please double check) or the entered developer key value is not correct.
Comment #15
gambryWorth mentioning you can only POST to /api.ai/webhook , and you should post a valid JSON only (you can get it from Dialogflow console).
Comment #16
tkrishnapriya CreditAttribution: tkrishnapriya as a volunteer commentedHi, Everything is working fine now i followed the steps afresh.
I am having two issues:
1. But Synonyms are being added as separate entity or term to the API.ai console. What do i need to do to make synonyms for a term to be not treated as separate term.
2. When testing the in Console with intent message : "Can you fix my boiler"
I am asked to enter Account ID : after entering abc123 dummy characters it did not return nothing "Not Available"
where as in Diagnostic Info, I see this:
"status": {
"code": 206,
"errorType": "partial_content",
"errorDetails": "Webhook call failed. Error: Request timeout."
},
Comment #17
gambryThey should not be treated as separated entities, unless you've configured to do so. Check your configuration
You are probably using the example agent I made for the DrupalCampLondon presentation. You may need to enable the module
drupalcamp_london
.Also be aware that is an example module, I'm confident it works but I'm not 100% sure it does on every environment out of the box.
As your issue now looks like fixed and yours are integration issues (outside the scope of this issue or module) I'm closing this one.
Feel free to open new issue related to this module, but please make sure first they actually belong to here, or to Chatbot API, or your configuration.
Thanks for helping by using the module!
Comment #18
tkrishnapriya CreditAttribution: tkrishnapriya as a volunteer commentedYes Sure it can closed. I am able to communicate with Dialogflow. Thanks for coping and replying.
Comment #19
apaderno