private function getContacts()
    {
        try {
            //Get whatsapp's Groups this user belongs to.
            $this->waGroupList = [];
            $this->getGroupList();
            if (is_array($this->waGroupList)) {
                $this->contacts = array_merge($this->contacts, $this->waGroupList);
            }

            //Get contacts from google if gmail account configured.
            $googleContacts = [];
            if (isset($this->config[$this->from]['email'])) {
                $email = $this->config[$this->from]['email'];

                if (stripos($email, 'gmail') !== false || stripos($email, 'googlemail') !== false) {
                    $google = new GoogleContacts();
                    $googleContacts = $google->getContacts($this->config, $this->from);
                    if (is_array($googleContacts)) {
                        $this->contacts = array_merge($this->contacts, $googleContacts);
                    }
                }
            }

            if (isset($this->contacts)) {
                exit(json_encode([
                    'success'  => true,
                    'type'     => 'contacts',
                    'data'     => $this->contacts,
                    'messages' => $this->messages,
                ]));
            }
        } catch (Exception $e) {
            exit(json_encode([
                'success'  => false,
                'type'     => 'contacts',
                'errormsg' => $e->getMessage(),
            ]));
        }
    }