PatInt Posted December 30, 2021 Share Posted December 30, 2021 Hi there I use ActiveCampaign (AC) for marketing and PM. I have a webhook that creates a contact in AC, when a new client account is created. Just First, Last and Email currently. The hook also Tags the contact with [WHMCS], so I know where they came from. I would like to Tag them with the service they order/subscribe to. I looked into Provisioning modules, but some are obfuscated, so I can't get access to the module details, so didn't pursue that any further, but I can't see a hook that would provide this info either. I'm happy to run an update query via cron, to update contacts in AC, once a day, if that's what is needed. I would happily outsource this as my PHP skills are not at that level. So my question is - does anyone have any thoughts on the best way that this could be achieved? Thanks 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted December 30, 2021 Share Posted December 30, 2021 (edited) You can use AcceptOrder, get the order via API, iterate through the order items and each should have service id . Tthough don't recall right off if order items have service ids and if not you can get the invoice and the line items there do have the service ids. Edited December 30, 2021 by steven99 0 Quote Link to comment Share on other sites More sharing options...
string Posted December 31, 2021 Share Posted December 31, 2021 (edited) The AfterModuleCreate hook could be used too. It returns all relevant data. And there is also AfterModuleTerminate, which can be used to remove the tags from AC when the service is terminated. For domains, you can use PreDomainRegister / PreDomainTransfer. However, there is no hook that is executed when a domain has expired or transferred out. I guess it would be the best to do it via a cronjob, also because manual status changes are not captured at "AfterModuleTerminate", as the terminate module function is not triggered and a combination of serveral hooks would be necessary. A cronjob would ensure that the data in AC is always correct. Edited December 31, 2021 by string 0 Quote Link to comment Share on other sites More sharing options...
PatInt Posted January 3, 2022 Author Share Posted January 3, 2022 On 31/12/2021 at 5:11 PM, string said: The AfterModuleCreate hook could be used too. It returns all relevant data. And there is also AfterModuleTerminate, which can be used to remove the tags from AC when the service is terminated. For domains, you can use PreDomainRegister / PreDomainTransfer. However, there is no hook that is executed when a domain has expired or transferred out. I guess it would be the best to do it via a cronjob, also because manual status changes are not captured at "AfterModuleTerminate", as the terminate module function is not triggered and a combination of serveral hooks would be necessary. A cronjob would ensure that the data in AC is always correct. Thanks for the reply. I've added the AfterModuleCreate and AfterModuleTerminate hooks, but I'm missing something when extracting the array data. In the code below, I've shown the details I use to compile the AC $post array. This format works for my WHMCS ClientAdd hook, that captures accounts created without purchases, so I know the code is good there. What am I missing? Thanks add_hook('AfterModuleTerminate', 1, function($vars) { $myserviceid = "Service ID: " . $vars['serviceid']; $myuserid = "User ID: " . $vars['userid']; $mypid = "P ID: " . $vars['pid']; $myserverid = "Server ID: " . $vars['serverid']; $mydomain = "Domain: " . $vars['domain']; $mynodtype = "Mod Type: " . $vars['moduletype']; $email = "clientsdetails: " . $vars['clientsdetails'][2]; $firstname = "clientsdetails: " . $vars['clientsdetails'][0]; $lastname = "clientsdetails: " . $vars['clientsdetails'][1]; $post = array( 'email' => $email, 'first_name' => $firstname, 'last_name' => $lastname, 'tags' => $myserviceid, // assign to lists: 'p[2]' => 2, // example list ID (REPLACE '123' WITH ACTUAL LIST ID, IE: p[5] = 5) 'status[2]' => 1, // 1: active, 2: unsubscribed (REPLACE '123' WITH ACTUAL LIST ID, IE: status[5] = 1) // use the folowing only if status=1 'instantresponders[2]' => 1, // set to 0 to if you don't want to sent instant autoresponders 'p[1]' => 1, // some additional lists? 'status[1]' => 1, // some additional lists? 'instantresponders[1]' => 1, // set to 0 to if you don't want to sent instant autoresponders ); 0 Quote Link to comment Share on other sites More sharing options...
PatInt Posted January 3, 2022 Author Share Posted January 3, 2022 5 hours ago, PatInt said: Thanks for the reply. I've added the AfterModuleCreate and AfterModuleTerminate hooks, but I'm missing something when extracting the array data. In the code below, I've shown the details I use to compile the AC $post array. This format works for my WHMCS ClientAdd hook, that captures accounts created without purchases, so I know the code is good there. What am I missing? Thanks add_hook('AfterModuleTerminate', 1, function($vars) { $myserviceid = "Service ID: " . $vars['serviceid']; $myuserid = "User ID: " . $vars['userid']; $mypid = "P ID: " . $vars['pid']; $myserverid = "Server ID: " . $vars['serverid']; $mydomain = "Domain: " . $vars['domain']; $mynodtype = "Mod Type: " . $vars['moduletype']; $email = "clientsdetails: " . $vars['clientsdetails'][2]; $firstname = "clientsdetails: " . $vars['clientsdetails'][0]; $lastname = "clientsdetails: " . $vars['clientsdetails'][1]; $post = array( 'email' => $email, 'first_name' => $firstname, 'last_name' => $lastname, 'tags' => $myserviceid, // assign to lists: 'p[2]' => 2, // example list ID (REPLACE '123' WITH ACTUAL LIST ID, IE: p[5] = 5) 'status[2]' => 1, // 1: active, 2: unsubscribed (REPLACE '123' WITH ACTUAL LIST ID, IE: status[5] = 1) // use the folowing only if status=1 'instantresponders[2]' => 1, // set to 0 to if you don't want to sent instant autoresponders 'p[1]' => 1, // some additional lists? 'status[1]' => 1, // some additional lists? 'instantresponders[1]' => 1, // set to 0 to if you don't want to sent instant autoresponders ); Sorry - that's not correct. $email = $vars['clientsdetails'][2]; $firstname = $vars['clientsdetails'][0]; $lastname = $vars['clientsdetails'][1]; Is what the vars look like 0 Quote Link to comment Share on other sites More sharing options...
FutureX Posted September 24, 2023 Share Posted September 24, 2023 After you have this data how do you send it via webhook to another app? I'm trying to send client info to FluentCRM via webhook so they get added to that mailing list, etc. Thanks! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.