Chatbots - Data

The data for the initial system message is crucial as it serves as instructions for the chatbot's operation.

Sources

Dynamic data can be incorporated into the system message. We currently support the following data sources:

  • Text: A simple text field.
  • Query: A query to the WordPress database.
  • Post title: The title of a post.
  • Post content: The content of a post.
  • Bricks content: The content of a Bricks page. (if Bricks is installed)
  • Elementor content: The content of an Elementor page. (if Elementor is installed)
  • Oxygen content: The content of an Oxygen page. (if Oxygen is installed)
  • Postmeta: Metadata associated with a post.
  • Taxonomy: A post's taxonomy.
  • Term: A term within a taxonomy.
  • User: User data.
  • Usermeta: Metadata associated with a user.

To use custom data sources, use the sleekAi/chatbot/source filter.


            add_filter('sleekAi/chatbot/sources', function ($data) {
      $data[] = [
        'id'    => 'customSource',
        'label' => 'Custom Source',
        'value' => functionToGetCustomData(),
      ];

      return $data;
    });

      
Copy

Variables

Data query results are stored in variables. For instance, you could save the title of a post as postTitle. In the system message, you can reference the variable using curly braces: {postTitle}. This will dynamically replace {postTitle} with the actual title of the specified post when the system message is sent.

Meta Keys

For data types like postmeta and usermeta that return an object, you must define a meta-key. This key specifies which object value to retrieve.

For instance, to fetch the current user's email, select the user data source and set the meta-key to data.user_email.

System Message

The system message, which is the first message received by the chatbot, should be a clear instruction to guide its behavior. All previously defined data variables can be included in this message.