11import { z } from 'zod' ;
2- import { SirenClient , ProviderCode } from '@trysiren/node' ;
2+ import { SirenClient , ProviderCode , RecipientChannel } from '@trysiren/node' ;
33import { Context } from '../configuration' ;
44import type { Tool } from '../tools' ;
55
66const 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")' ) ,
7+ recipient_value : z
8+ . string ( )
9+ . describe (
10+ 'Identifier for the recipient (e.g., Slack user ID, email address)'
11+ ) ,
12+ channel : z
13+ . nativeEnum ( RecipientChannel )
14+ . describe (
15+ 'The channel to send the message through (e.g., "SLACK", "EMAIL")'
16+ ) ,
917 template_identifier : z . string ( ) . describe ( 'Awesome template path/identifier' ) ,
10- template_variables : z . record ( z . any ( ) ) . optional ( ) . describe ( 'Variables for the template' ) ,
18+ template_variables : z
19+ . record ( z . any ( ) )
20+ . optional ( )
21+ . describe ( 'Variables for the template' ) ,
1122 provider_name : z . string ( ) . optional ( ) . describe ( 'Provider integration name' ) ,
12- provider_code : z . nativeEnum ( ProviderCode ) . optional ( ) . describe ( 'Provider integration code' ) ,
23+ provider_code : z
24+ . nativeEnum ( ProviderCode )
25+ . optional ( )
26+ . describe ( 'Provider integration code' ) ,
1327} ) ;
1428
1529export const sendAwesomeTemplate = async (
@@ -18,13 +32,16 @@ export const sendAwesomeTemplate = async (
1832 params : z . infer < typeof sendAwesomeSchema >
1933) => {
2034 try {
35+ const messagePayload = {
36+ recipientValue : params . recipient_value ,
37+ channel : params . channel ,
38+ templateIdentifier : params . template_identifier ,
39+ templateVariables : params . template_variables ,
40+ providerName : params . provider_name ,
41+ providerCode : params . provider_code ,
42+ } ;
2143 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
44+ messagePayload
2845 ) ;
2946 return { notificationId } ;
3047 } catch ( error ) {
@@ -39,7 +56,8 @@ export const sendAwesomeTemplate = async (
3956const tool = ( context : Context ) : Tool => ( {
4057 method : 'send_awesome_template' ,
4158 name : 'Send Awesome Template Message' ,
42- description : 'Send a message using an awesome template identifier via a chosen channel' ,
59+ description :
60+ 'Send a message using an awesome template identifier via a chosen channel' ,
4361 parameters : sendAwesomeSchema ,
4462 actions : {
4563 messaging : {
@@ -49,4 +67,4 @@ const tool = (context: Context): Tool => ({
4967 execute : sendAwesomeTemplate ,
5068} ) ;
5169
52- export default tool ;
70+ export default tool ;
0 commit comments