Title: Getting chatbot&#8217;s last message
Last modified: May 15, 2024

---

# Getting chatbot’s last message

 *  Resolved [mhyaoming](https://wordpress.org/support/users/mhyaoming/)
 * (@mhyaoming)
 * [2 years ago](https://wordpress.org/support/topic/getting-chatbots-last-message/)
 *     ```wp-block-code
       function start_ticket_thread($reply, $query)
   
       {
   
           // First we'll check if the user is asking to create a ticket.
   
           $last_message = $query->get_message();
   
           $expected_question = 'Create a ticket to support.';
   
           if ($last_message == $expected_question) {
   
               $reply->set_reply('Please start the reply with (NEW_TICKET) followed by the subject title, subject type (general/technical) and a description.');
   
           }
   
           return $reply;
   
       }
   
       add_filter('mwai_ai_reply', 'new_ticket_reply', 10, 2);
       ```
   
 * Hello I have this code to set a custom reply to a user when he wants to send 
   a ticket to support using the chatbot and I want to make another filter which
   checks whether the last message returned by the chatbot is “Please start the 
   reply with (NEW_TICKET) followed by the subject title, subject type (general/
   technical) and a description.”, may I know how do I do this?

Viewing 1 replies (of 1 total)

 *  Plugin Support [Val Meow](https://wordpress.org/support/users/valwa/)
 * (@valwa)
 * [2 years ago](https://wordpress.org/support/topic/getting-chatbots-last-message/#post-17765631)
 * Hey [@mhyaoming](https://wordpress.org/support/users/mhyaoming/)! 👋
 * You might be interested in using Function Calling for this kind of use case, 
   which can be easier than juggling between filters. [Interactive & Static Functions (Function Calling) – AI Engine | Meow Apps](https://docs.meowapps.com/features--tutorials/qxAxYBjw7r1TyR9xEeNgEg/interactive--static-functions-function-calling/6hYFU3T5eyzq5xVCSeXEt3)
   allows the AI to decide when to execute the function, fitting everything into
   one declaration.
 * Otherwise, you can use reply and query filters to create your own logic: [API & Filters | Meow Apps](https://meowapps.com/ai-engine/api/)

Viewing 1 replies (of 1 total)

The topic ‘Getting chatbot’s last message’ is closed to new replies.

 * ![](https://ps.w.org/ai-engine/assets/icon-256x256.png?rev=3431928)
 * [AI Engine - The Chatbot, AI Framework & MCP for WordPress](https://wordpress.org/plugins/ai-engine/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ai-engine/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ai-engine/)
 * [Active Topics](https://wordpress.org/support/plugin/ai-engine/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ai-engine/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ai-engine/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Val Meow](https://wordpress.org/support/users/valwa/)
 * Last activity: [2 years ago](https://wordpress.org/support/topic/getting-chatbots-last-message/#post-17765631)
 * Status: resolved