@@ -443,16 +443,24 @@ export class Signal implements INodeType {
443443 try {
444444 let response ;
445445 debug ( 'Signal Node: Executing with resource=%s, operation=%s' , resource , operation ) ;
446- if ( resource === 'message' && operation === 'send' ) {
447- const account = this . getNodeParameter ( 'account' , 0 ) as string ;
448- const recipient = this . getNodeParameter ( 'recipient' , 0 ) as string ;
449- const message = this . getNodeParameter ( 'message' , 0 ) as string ;
446+ if ( resource === "message" && operation === "send" ) {
447+ const account = this . getNodeParameter ( "account" , 0 ) as string ;
448+ const recipient = this . getNodeParameter ( "recipient" , 0 ) as string ;
449+ const message = this . getNodeParameter ( "message" , 0 ) as string ;
450+ // check if the value of recipient is a group based on if there are alphabetical characters in the string
451+ const isTargetAGroup = / [ a - z A - Z ] / . test ( recipient ) ;
450452
451- const requestBody = {
452- jsonrpc : '2.0' ,
453- method : 'send' ,
454- params : { account, recipient, message } ,
455- id : uuidv4 ( ) ,
453+ const requestBody = {
454+ jsonrpc : "2.0" ,
455+ method : "send" ,
456+ params : {
457+ account,
458+ message,
459+ //if value is group send with groupId prefix as required by Signal-cli, otherwise pass through as phone number via recipient
460+ [ isTargetAGroup ? "groupId" : "recipient" ] : recipient ,
461+ } ,
462+ id : uuidv4 ( ) ,
463+
456464 } ;
457465 debug ( 'Signal Node: Sending message with requestBody=%o' , requestBody ) ;
458466 response = await axios . post ( `${ url } ` , requestBody ) ;
0 commit comments