Paradiz Web Chat

Endpoint
Bearer Token

Вставь шорткод [paradiz_web_chat] на страницу бронирования.

admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('paradiz_web_chat_nonce') ]); } public function render_shortcode() { wp_enqueue_script('paradiz-web-chat'); ob_start(); ?>
Помощник Парадиз

Здравствуйте! Помогу с подбором номера и бронированием.

'Пустой вопрос']); $endpoint = get_option(self::OPT_ENDPOINT, ''); $token = get_option(self::OPT_TOKEN, ''); if (!$endpoint || !$token) wp_send_json_error(['message' => 'Не настроены endpoint/token']); $resp = wp_remote_post($endpoint, [ 'timeout' => 45, 'headers' => [ 'Content-Type' => 'application/json', 'Authorization' => 'Bearer ' . $token ], 'body' => wp_json_encode(['question' => $question]) ]); if (is_wp_error($resp)) { wp_send_json_error(['message' => $resp->get_error_message()]); } $body = json_decode(wp_remote_retrieve_body($resp), true); if (!is_array($body) || empty($body['ok'])) { wp_send_json_error(['message' => $body['error'] ?? 'Ошибка upstream']); } wp_send_json_success(['answer' => $body['answer'] ?? '']); } } new ParadizWebChat();