1+ import { z } from 'zod' ;
2+ import { SirenClient , ProviderCode } from '@trysiren/node' ;
3+ import { Context } from '../configuration' ;
4+ import type { Tool } from '../tools' ;
5+
6+ const sendAwesomeSchema = z . object ( {
7+ recipient_value : z . string ( ) . describe ( 'Identifier for the recipient (e.g., Slack user ID, email address)' ) ,
8+ channel : z . string ( ) . describe ( 'The channel to send the message through (e.g., "SLACK", "EMAIL")' ) ,
9+ template_identifier : z . string ( ) . describe ( 'Awesome template path/identifier' ) ,
10+ template_variables : z . record ( z . any ( ) ) . optional ( ) . describe ( 'Variables for the template' ) ,
11+ provider_name : z . string ( ) . optional ( ) . describe ( 'Provider integration name' ) ,
12+ provider_code : z . nativeEnum ( ProviderCode ) . optional ( ) . describe ( 'Provider integration code' ) ,
13+ } ) ;
14+
15+ export const sendAwesomeTemplate = async (
16+ sirenClient : SirenClient ,
17+ context : Context ,
18+ params : z . infer < typeof sendAwesomeSchema >
19+ ) => {
20+ try {
21+ const notificationId = await sirenClient . message . sendAwesomeTemplate (
22+ params . recipient_value ,
23+ params . channel ,
24+ params . template_identifier ,
25+ params . template_variables ,
26+ params . provider_name ,
27+ params . provider_code
28+ ) ;
29+ return { notificationId } ;
30+ } catch ( error ) {
31+ console . error ( 'Failed to send awesome template:' , error ) ;
32+ return {
33+ error : 'Failed to send awesome template' ,
34+ details : error instanceof Error ? error . message : String ( error ) ,
35+ } ;
36+ }
37+ } ;
38+
39+ const tool = ( context : Context ) : Tool => ( {
40+ method : 'send_awesome_template' ,
41+ name : 'Send Awesome Template Message' ,
42+ description : 'Send a message using an awesome template identifier via a chosen channel' ,
43+ parameters : sendAwesomeSchema ,
44+ actions : {
45+ messaging : {
46+ create : true ,
47+ } ,
48+ } ,
49+ execute : sendAwesomeTemplate ,
50+ } ) ;
51+
52+ export default tool ;
0 commit comments