Your software
My Mautic version is: v4.4.10
My PHP version is: 8
My Database type and version is: MySQL 8
Your problem
My problem is: Can’t correctly configure the URL for a webhook listener for a new plugin
These errors are showing in the log: No error log, just 404 on the URL
Steps I have tried to fix the problem: Read documentation.
The issue is as follows
Currently I have a fully functional plugin to send WhatsApp messages but now I need to get the messages back. I am using a platform called Zender as the bridge. So the plugin currently adapts the text message channel and modifies to send a specially constructed JSON to Zender thus Zender can resend that to WhatsApp.
Zender can also get the answers and resend them to outside services via a Hook. The structure of the Hook is this one: https://mauticinstallation.com/zender/receive/?phone={{phone}}&message={{message}}&time={{date.now}}&datetime={{date.time}}&key=WhateverSecurityKeyYouHaveConfiguredInThePlugin
So the "/zender/receive/ is supposedly already configured in the listener in the plugin but you can test it at.
You can see the plugin at GitHub - rcarabelli/Mautic-Zender-Plugin: Plugin to use Mautic with Zender to send WhatsApp messages but without this listening feature yet (currently working on it)
If you want to see the error online, try this link:
What I have added to the plugin is in
pathtomautic/plugins/MauticZenderBundle/Controller/WebhookController.php
< here begins php
namespace MauticPlugin\MauticZenderBundle\Controller;
use Mautic\CoreBundle\Controller\CommonController;
use Symfony\Component\HttpFoundation\Request;
class WebhookController extends CommonController
{
public function receiveAction(Request $request)
{
$key = $request->get(‘key’);
if ($key !== 'WhateverSecurityKeyYouHaveConfiguredInThePlugin') {
// Invalid key, reject the request
return new Response('Unauthorized', Response::HTTP_UNAUTHORIZED);
}
// Process the valid request...
}
}
This to process the payload
and at
pathtomautic/plugins/MauticZenderBundle/Config/config.php
– previous code –
],
'routes' => [
'main' => [
'mautic_zender_receive_webhook' => [
'path' => '/zender/receive',
'controller' => 'MauticZenderBundle:Webhook:receive',
],
// ... (other routes you may have)
],
],
– following code –
Supposedly doing that on “routes” it should work at /zender/receive but it seems I was wrong.
Read all this in the documentation at: Mautic Developer Documentation
Did a search for “listeners” in documentation and assummed that was the right way, but it seems I am wrong.
Any idea what I am doing wrong?
Already cleared cache and the plugin still works on the other functionalities, so that’s not the issue.
If someone can help me discovering how to activate that webhook listener will be very thankful.
Regards,
Renato