Programming a chat bot
-
Hey everyone. Okay I have gotten myself to a point and then need help past that. I am working on a website that has woocommerce and giga.ai chat bot for facebook installed.
I am working on an add action for giga.ai to be able to look up the order status of a customer’s order. However, I have sequential order numbers for woocommerce installed.
so for this to work, you would need to look up the customers order number that they get from the site to get the “post id” which is the true order number. Then use that order number to look up the order status.
add_action('giga_pre_seed', function ($bot) { $bot->answers('@order', function ($bot, $lead_id, $input) { // You use $wpdb object so you'll need to use global variable global $wpdb; $order_number_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_value=%s", $input)); $order_status_id = $wpdb->get_var($wpdb->prepare("SELECT post_status from $wpdb->post WHERE ID=%d", $order_number_id)); $bot->says($order_status_id); }); });so the code works to get the first part (order_number_id) with out issues. it returns the proper post_id. The issue comes just below that when I try to use the order_number_id to retrieve the order status from the wp_post table.
any help you can offer will be greatly appreciated.
The topic ‘Programming a chat bot’ is closed to new replies.