Skip to content

Example: Create a Report

You:

create a report about Jeff's sales last month

A sales report for Jeff for last month has been generated.

Sidekick:

The new report has been generated. Feel free to download it at your convenience!

php
/**
 * Create a report with specified parameters.
 *
 * Write detailed instructions for the AI to learn
 * how to create a report with the specified parameters.
 *
 * @param string $person Name of the person to create the report for.
 * @param string $topic Topic of the report (ie: "sales").
 * @param string $timeframe Timeframe for the report to include.
 * @return SkillResponse
 */
public static function createReport(string $person, string $topic, string $timeframe): SkillResponse
{
    /**
     * Write your custom implementation for creating a report.
     * 
     * For example, determine which user is being referenced
     * and generate a relevant report spanning the given timeframe.
     */

    // If validation fails
    if (!$valid) {
        // Return error message
        return new SkillResponse([
            'success' => false,
            'message' => "Unable to generate a {$topic} report about {$person} spanning {$timeframe}."
        ]);
    }

    // Return success message
    return new SkillResponse([
        'success' => true,
        'message' => "Successfully generated a {$topic} report about {$person} spanning {$timeframe}.",
//        'response' => '(any data you want to send back to the API for further processing)'
    ]);
}

How to Add Skills

The snippet above is just an example (obviously). See the AddSkillsEvent for more detailed instructions.