ChatGPT 4-omni (ProTalk) + WordPress + Notion
In this case, we will show how to make a seller of goods or services in a Telegram bot directly from your WordPress site and collect orders in a convenient database in Notion
Step #1: Preparing WordPress
Let's prepare your WordPress site so that our bot can receive products in the required categories. To do this, add the following code to the `functions.php` file in your theme settings:
add_action('rest_api_init', function () {
register_rest_route('myshop/v1', '/products', array(
'methods' => 'GET',
'callback' => 'get_products_info',
'permission_callback' => '__return_true'
));
});
function get_products_info($request) {
$category = $request->get_param('category');
$args = array(
'status' => 'publish',
'limit' => -1
);
if ($category) {
$args['category'] = array($category);
}
$products = wc_get_products($args);
$data = array();
foreach ($products as $product) {
$data[] = array(
'id' => $product->get_id(),
'name' => $product->get_name(),
'price' => $product->get_price(),
'regular_price' => $product->get_regular_price(),
'sale_price' => $product->get_sale_price(),
'stock_status' => $product->get_stock_status(),
'stock_quantity' => $product->get_stock_quantity(),
'categories' => wp_list_pluck($product->get_category_ids(), 'name'),
'permalink' => get_permalink($product->get_id()),
'image_url' => wp_get_attachment_url($product->get_image_id()),
);
}
return new WP_REST_Response($data, 200);
}
If you want to make sure that no one except the bot can access the site, you can add a password check, like this:
add_action('rest_api_init', function () {
register_rest_route('myshop/v1', '/products', array(
'methods' => 'GET',
'callback' => 'get_products_info',
'permission_callback' => 'check_api_password'
));
});
function check_api_password($request) {
$api_password = 'your_secure_password_here'; // Замените на ваш пароль
$provided_password = $request->get_param('api_password');
if ($provided_password && $provided_password === $api_password) {
return true;
} else {
return new WP_Error('rest_forbidden', 'Неверный пароль API', array('status' => 401));
}
}
function get_products_info($request) {
$category = $request->get_param('category');
$args = array(
'status' => 'publish',
'limit' => -1
);
if ($category) {
$args['category'] = array($category);
}
$products = wc_get_products($args);
$data = array();
foreach ($products as $product) {
$data[] = array(
'id' => $product->get_id(),
'name' => $product->get_name(),
'price' => $product->get_price(),
'regular_price' => $product->get_regular_price(),
'sale_price' => $product->get_sale_price(),
'stock_status' => $product->get_stock_status(),
'stock_quantity' => $product->get_stock_quantity(),
'categories' => wp_list_pluck($product->get_category_ids(), 'name'),
'permalink' => get_permalink($product->get_id()),
'image_url' => wp_get_attachment_url($product->get_image_id()),
);
}
return new WP_REST_Response($data, 200);
}
Step #2: Preparing Notion
There are a lot of videos on YouTube about working in Notion, even in Russian, so I'll give you a link to the one I received. sample for our bot in Notion.
Step #3: Creating a Telegram Bot on the ProTalk Platform
Here is a link to a guide on creating a Telegram bot on the ProTalk platform:
And the final role of the bot:
Ты - опытная и дружелюбная менеджер по продаже светильников. Твоя цель - обеспечить клиентов качественными консультациями и помочь им сделать правильный выбор.
Твоя задача - помочь клиентам выбрать подходящие светильники на сайте [https://svetaluks.ru](https://svetaluks.ru/) и успешно завершить продажу.
Когда клиент определится с выбором ты должна спросить его имя и номер телефона, после чего отправить эти данные в таблицу Notion: [https://www.notion.so/0b27ddc833864c558376d2537ea11ddf?v=b7c69c8af2294ae8857c04bc86f6b86d&pvs=4](https://www.notion.so/0b27ddc833864c558376d2537ea11ddf?pvs=21)
Поля для записи заявки:
```markdown
“Клиент” - это заголовок, сюда запиши имя клиента
“Телефон” - текстовое поле, сюда запиши телефон клиента
“Заказ” - тектовое поле, сюда запиши заказ клиента
"Сумма" - числовое поле, сюда запиши сумму заказа
```
Используй эти категории для поиска светильников:
"childrens-table-lamps" - детские настольные светильники.
Токен для записи в Notion : “secret_EPGE2uRL85XXXXXXXXXXXXXXXXXXXXXXXXX”
Не выходи из своей роли.
By the way, we also moved the role itself to Notion, like this:
As a result, we get a bot like this:
We have connected two functions to the bot:
Step #4: Test the Bot
Additionally, we can enable the following settings for the bot:
And then the following behavior of the bot will become possible:
Results
Based on the given case, the idea of ”packaging” AI companies ready for replication in the form of a Notion template arises, which will contain:
Roles of all AI employees
Knowledge Bases in Notion Tables
Databases of applications (leads) from bots
If you have any other ideas on how to use the AI bots bundle with Notion, write about them in the comments or to me at Telegram.