Skip to content

Commit

Permalink
Add option to send message directly to phone number AWS SNS
Browse files Browse the repository at this point in the history
  • Loading branch information
TheZoker committed Jan 27, 2025
1 parent 6dd90c8 commit 3271c8d
Showing 1 changed file with 52 additions and 1 deletion.
53 changes: 52 additions & 1 deletion packages/nodes-base/nodes/Aws/AwsSns.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,32 @@ export class AwsSns implements INodeType {
},
},
},
{
displayName: 'Target',
name: 'target',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Topic',
value: 'topic',
description: 'Publish to a topic',
action: 'Publish to a topic',
},
{
name: 'Phone',
value: 'phone',
description: 'Publish to a phone number',
action: 'Publish to a phone number',
},
],
default: 'topic',
displayOptions: {
show: {
operation: ['publish'],
},
},
},
{
displayName: 'Topic',
name: 'topic',
Expand Down Expand Up @@ -159,9 +185,24 @@ export class AwsSns implements INodeType {
displayOptions: {
show: {
operation: ['publish', 'delete'],
target: ['topic'],
},
},
},
{
displayName: 'Number',
name: 'number',
type: 'string',
displayOptions: {
show: {
target: ['phone'],
},
},
default: '',
placeholder: '+123456789',
required: true,
description: 'The number where the message is published to',
},
{
displayName: 'Subject',
name: 'subject',
Expand Down Expand Up @@ -300,13 +341,23 @@ export class AwsSns implements INodeType {
const topic = this.getNodeParameter('topic', i, undefined, {
extractValue: true,
}) as string;
const number = this.getNodeParameter('number', i, undefined, {
extractValue: true,
}) as string;
const target = this.getNodeParameter('mode', 0);

const params = [
'TopicArn=' + topic,
'Subject=' + encodeURIComponent(this.getNodeParameter('subject', i) as string),
'Message=' + encodeURIComponent(this.getNodeParameter('message', i) as string),
];

if (target === 'topic') {
params.push('TopicArn=' + topic)
}
if (target === 'phone') {
params.push('PhoneNumber=' + number)
}

const responseData = await awsApiRequestSOAP.call(
this,
'sns',
Expand Down

0 comments on commit 3271c8d

Please sign in to comment.