Skip to content

Example: Send an Email

You:

email Doug to remind him about tomorrow's meeting

Email sent to doug@example.com with the subject "Reminder about tomorrow's meeting".

Sidekick:

I've sent a reminder email to Doug. Would you like assistance with anything else?

php
/**
 * Send an email message to a specified User.
 *
 * Write detailed instructions for the AI to learn
 * how to send an email to the specified user.
 *
 * @param string $user Name of the user to send the email to.
 * @param string $subject Subject line for the outgoing email.
 * @param string $body Message body for the outgoing email.
 * @return SkillResponse
 * @throws Exception
 */
public static function sendEmailMessage(string $user, string $subject, string $body): SkillResponse
{
    /**
     * Write your custom implementation for sending an email message.
     * 
     * For example, determine which user is being referenced
     * and send them an email with the provided subject and body.
     */

    // If validation fails, throw an exception
    if (!$valid) {
        throw new Exception("Unable send an email to {$user} with the subject {$subject}.");
    }

    // Return success message
    return new SkillResponse([
        'success' => true,
        'message' => "Successfully sent an email to {$user} with the subject {$subject}.",
//        '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.