Phase 4: Fix Response status method and implement WhatsApp incoming messages webhook
This commit is contained in:
@@ -149,6 +149,8 @@ class WhatsAppController extends BaseController
|
|||||||
// 1. Find or create the contact in the CRM
|
// 1. Find or create the contact in the CRM
|
||||||
$contact = \App\Models\Contact::findByPhone($session['company_id'], $msgData['phone']);
|
$contact = \App\Models\Contact::findByPhone($session['company_id'], $msgData['phone']);
|
||||||
if (!$contact) {
|
if (!$contact) {
|
||||||
|
|
||||||
|
|
||||||
// Determine a fallback name
|
// Determine a fallback name
|
||||||
$contactName = !empty($msgData['name']) ? $msgData['name'] : 'WA-' . substr($msgData['phone'], -4);
|
$contactName = !empty($msgData['name']) ? $msgData['name'] : 'WA-' . substr($msgData['phone'], -4);
|
||||||
\App\Models\Contact::createSecure([
|
\App\Models\Contact::createSecure([
|
||||||
|
|||||||
@@ -16,6 +16,11 @@ class Response
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function status(int $code): self
|
||||||
|
{
|
||||||
|
return $this->setStatusCode($code);
|
||||||
|
}
|
||||||
|
|
||||||
public function getStatusCode(): int
|
public function getStatusCode(): int
|
||||||
{
|
{
|
||||||
return $this->statusCode;
|
return $this->statusCode;
|
||||||
|
|||||||
Reference in New Issue
Block a user