PHP code example of whilesmart / eloquent-agent-actions
1. Go to this page and download the library: Download whilesmart/eloquent-agent-actions library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
whilesmart / eloquent-agent-actions example snippets
use Whilesmart\AgentActions\Traits\HasAgentActions;
class Workspace extends Model
{
use HasAgentActions;
}
$workspace->agentActions()->create([
'action_type' => 'send_mail',
'payload' => ['to' => '[email protected]', 'subject' => 'Hi'],
'metadata' => ['agent_run_id' => 42],
'summary' => 'Email the customer',
'risk' => 'medium',
]);
$action->source()->associate($chatMessage)->save();
$action->source; // the chat message, resolved back through morphTo
use Whilesmart\AgentActions\Contracts\ActionHandler;
use Whilesmart\AgentActions\Models\AgentAction;
class SendMailHandler implements ActionHandler
{
public function type(): string
{
return 'send_mail';
}
public function execute(AgentAction $action): mixed
{
// ... send the mail, optionally return the created record
}
}