Hello,
We’re encountering a problem in our custom-built application designed to facilitate student enrolment at our school.
We have created a “Lead status” property that should be updated automatically as the student progresses through the process.
Hubspot support has pointed us to this forum.
When the student is in “Lead status: Invited Interview” and books a meeting slot, his or her status should automatically change to “Booked Interview”.
However, in some cases, we can see on the student’s contact form that the meeting has been scheduled, but the status is still “Invited Interview”.
We think the problem is not due to the code on our side, as we’ve run multiple tests and the triggers for the status change are correct (being in “Invited Interview” && having the hs_meting_outcome set to “Scheduled” or “Rescheduled”.
For the students on whom it didn’t work, as soon as they reconnected to their application, their status changed to Booked Interview. This shows that we believe the problem stems from an overload of the Hubspot API at the time of form submission.
Here is some additional information:
The endpoint used
define(‘HB_API1_PROPS’, ‘/contacts/v1/contact/email/’);
HubSpot’s raw request to the API
define(‘HB_API_URL’, ‘https://api.hubapi.com’ );
define(‘HB_API_TOKEN’, ‘pat-eu1-3a48423[Information redacted]’ );
define(‘HB_API_HEADER’, [“Authorization”=>"Bearer ".HB_API_TOKEN, “Content-Type”=>“application/json”]);
And here’s the code that handles the change of status from “Invited Interview” to “Booked Interview”:
// Change Lead Status to “Booked Interview” under certain conditions (Reminder: Invited Interview is a status to be decided manually by Forward)
if($userProps->hs_lead_status->value == ‘Invited Interview’ && preg_match(“/(scheduled|rescheduled)/i”, $interviewMeetOutcome) ){
update_user_meta($user->ID, “hs_lead_status$slugHubs”, ‘Booked Interview’);
$argsHubs = array( “body” => wp_json_encode([“properties”=>[“hs_lead_status”=> ‘Booked Interview’]]), “method”=>‘PATCH’, “headers”=>HB_API_HEADER );
wp_safe_remote_post( HB_API_URL.HB_API_USERS.$userHubsID, $argsHubs );
}
Do you have any idea where the problem might be coming from?
Thank you for your help!