Webhook calls into Suite?

Hi y’all!

So I’m trying to write up a webhook from Stripe that will call into my SuiteCRM instance and create a new user. I have basic testing right now where the webhook calls and fires just a mail.php file within SuiteCRM which then sends an email to me saying it worked. However, it seems I can’t get access to anything really within the SuiteCRM file system such as beans to create the user and such. I’ve seen a few references to Webhooks, though most are setting them up to call from within SuiteCRM to another app using a webhook. Can I use it this way, or do I have to go API route? If I can, what’s missing to be able to create a bean record. I have built a few Logic hooks and such, so I know my way around actually creating the record, just not sure what’s missing… Assuming something simple, an include, or creating as a custom entry point possible? Any help would be appreciated!

Thanks

See the docs for custom entry-points. Or use a custom API call (a bit harder to do).

I may have found another solution… Still testing it for functionality and reliability though.

From within my webhook file that receives the payload, I’m creating a connection to the database and just inserting a record into a custom module’s table. From there, I’ll have to build out a scheduler to monitor these records, add in a status (new, processed, duplicate, etc) and build out the logic around it. First pass - if user doesn’t exist, create new user, assign appropriate role, email new user with login info, etc. Though later ideas will include checking current subscription level for customer and updating if need be.

As of now - the webhook file just uses php and a new Mysqli connection to the database and does correctly insert a record so I think it’s a workable path.

Thank you

Custom entry-points are easy to do and bring you all the advantages of working with SuiteCRM objects - the database objects, Beans, all the libraries, etc. Plus, security is handled.

I don’t see a reason to do vanilla PHP when a much better option is right there for you to use, it will only take you 5 minutes to make your PHP a registered entry-point.

1 Like

I didn’t spend as much time as I should have on that part of the documentation then! I will have to revisit it for sure to check it out. Thank you for the follow up and pointing out the benefits.

1 Like

okay then so now I’m going to bug ya again.

Followed docs: Created custom entry point in custom/Extension/Ext/EntryPointRegistry file named webhook_entry.php which contains

<?php
  $entry_point_registry['webhooks'] = array(
      'file' => 'custom/WebHooks/webhooktest.php',
      'auth' => false,
  );

Did a rebuild, and I see the file as expected after rebuild in custom/application/Ext/EntryPointRegistry, file named entry_point_registry.ext.php which contains my expected custom entry point.

in my webhooktest.php file I tried both with and without

if(!defined('sugarEntry') || !sugarEntry) die($status = 'Not A Valid Entry Point');

$GLOBALS['log']->debug('Test_WebHooks work!' );

Now when I call from Stripe to the webhook, nothing happens. if I comment out anything for Global or SuiteCRM related coding (sugarEntry), then it works as expected, but it’s still seeming that it’s not set as a valid entry point.

Only thing different than docs - no mention aside from your comments on another post about auth => false, but all other examples have it as true… From what I’m seeing, if auth=>false, it should just skip over authorization.

Also - I’m running all of these tests currently just logging out status and data to a file it writes. I’ve toyed with phpStorm a bit, but never fully set it up… Any good, free IDE/debugger options out there to dig into so I can step through this and see where it’s breaking? :slight_smile:

Much appreciated!

Your url will be
Crm url/index.php?entryPoint=webhooks

Is this the url your are using to call the entrypoint ?

1 Like

My call is coming from a webhook on Stripe that is calling to the /custom/WebHooks/webhooktest.php file.

Should it be calling to url/index.php?entryPoint=webhooks instead you’re saying?

Yes the url that stripe is calling should the like the one that I mentioned

1 Like

That was it! Thank you

Are the webhooks both ways?
Like when I add a lead/contact are webhooks fired?
Or are there better ways doing that?

Hello Jobst,

to dispatch a webhook from the CRM, you’d either need to

  • develop it by yourself (logic hook when your conditions are being triggered + custom code

  • install a webhook addon and setup the workflows accordingly (watch out - there is an issue when installing it on PHP8.3 and the code might have room for improvements)
    https://www.youtube.com/watch?v=djq2036cARM

  • another idea: @digital-boss/n8n-nodes-billrun-suitecrm - npm - unfortunately, I couldn’t get it working on a current version of n8n and the developers didn’t respond.

The webook plugin is rather expensive.
Paul Stevens has a video using N8N with webhooks.

Yeah, logic hook might be the way but also “entry points”.

@jobst I’m not sure I understand your question, maybe it’s better if you just outline what you’re trying to achieve.

When mentioning SuiteCRM custom entry-points, I am assuming some other system is triggering them; the other system calls into SuiteCRM.

If you need it the other way around - SuiteCRM calls other system, then yeah, do it from a logic hook if there is one for the event your trying to catch (record creations are obvious cases where we do have hooks).

1 Like

Wrote this is a hurry while knocking off.
Should have taken more time to explain.
I have enough information now to move on.
thanks

1 Like