first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import type {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
IHttpRequestMethods,
|
||||
IRequestOptions,
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
/**
|
||||
* Make an API request to seven
|
||||
*
|
||||
* @param {IHookFunctions | IExecuteFunctions} this
|
||||
* @param {object | undefined} data
|
||||
*/
|
||||
export async function sms77ApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions,
|
||||
method: IHttpRequestMethods,
|
||||
endpoint: string,
|
||||
body: IDataObject,
|
||||
qs: IDataObject = {},
|
||||
): Promise<any> {
|
||||
const options: IRequestOptions = {
|
||||
headers: {
|
||||
SentWith: 'n8n',
|
||||
},
|
||||
qs,
|
||||
uri: `https://gateway.seven.io/api${endpoint}`,
|
||||
json: true,
|
||||
method,
|
||||
};
|
||||
|
||||
if (Object.keys(body).length) {
|
||||
options.form = body;
|
||||
}
|
||||
|
||||
const response = await this.helpers.requestWithAuthentication.call(this, 'sms77Api', options);
|
||||
|
||||
if (response.success !== '100') {
|
||||
throw new NodeApiError(this.getNode(), response as JsonObject, {
|
||||
message: 'Invalid sms77 credentials or API error!',
|
||||
});
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"node": "n8n-nodes-base.sms77",
|
||||
"nodeVersion": "1.0",
|
||||
"codexVersion": "1.0",
|
||||
"categories": ["Communication"],
|
||||
"resources": {
|
||||
"credentialDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/credentials/sms77/"
|
||||
}
|
||||
],
|
||||
"primaryDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.sms77/"
|
||||
}
|
||||
]
|
||||
},
|
||||
"alias": ["SMS", "Sms77"]
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
import {
|
||||
NodeConnectionTypes,
|
||||
type IDataObject,
|
||||
type IExecuteFunctions,
|
||||
type INodeExecutionData,
|
||||
type INodeType,
|
||||
type INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { sms77ApiRequest } from './GenericFunctions';
|
||||
|
||||
export class Sms77 implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'seven',
|
||||
name: 'sms77',
|
||||
icon: 'file:seven.svg',
|
||||
group: ['transform'],
|
||||
version: 1,
|
||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||
description: 'Send SMS and make text-to-speech calls',
|
||||
defaults: {
|
||||
name: 'seven',
|
||||
},
|
||||
usableAsTool: true,
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
credentials: [
|
||||
{
|
||||
name: 'sms77Api',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
options: [
|
||||
{
|
||||
name: 'SMS',
|
||||
value: 'sms',
|
||||
},
|
||||
{
|
||||
name: 'Voice Call',
|
||||
value: 'voice',
|
||||
},
|
||||
],
|
||||
default: 'sms',
|
||||
},
|
||||
|
||||
// operations
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['sms'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Send',
|
||||
value: 'send',
|
||||
description: 'Send SMS',
|
||||
action: 'Send an SMS',
|
||||
},
|
||||
],
|
||||
default: 'send',
|
||||
},
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['voice'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Send',
|
||||
value: 'send',
|
||||
description: 'Converts text to voice and calls a given number',
|
||||
action: 'Convert text to voice',
|
||||
},
|
||||
],
|
||||
default: 'send',
|
||||
},
|
||||
{
|
||||
displayName: 'From',
|
||||
name: 'from',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: '+4901234567890',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['send'],
|
||||
resource: ['sms'],
|
||||
},
|
||||
},
|
||||
description:
|
||||
'The caller ID displayed in the receivers display. Max 16 numeric or 11 alphanumeric characters.',
|
||||
},
|
||||
{
|
||||
displayName: 'To',
|
||||
name: 'to',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: '+49876543210, MyGroup',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['send'],
|
||||
resource: ['sms', 'voice'],
|
||||
},
|
||||
},
|
||||
description:
|
||||
'The number of your recipient(s) separated by comma. Can be regular numbers or contact/groups from seven.',
|
||||
},
|
||||
{
|
||||
displayName: 'Message',
|
||||
name: 'message',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['send'],
|
||||
resource: ['sms', 'voice'],
|
||||
},
|
||||
},
|
||||
description: 'The message to send. Max. 1520 characters',
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Option',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['send'],
|
||||
resource: ['sms'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Delay',
|
||||
name: 'delay',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Pick a date for time delayed dispatch',
|
||||
},
|
||||
{
|
||||
displayName: 'Foreign ID',
|
||||
name: 'foreign_id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'MyCustomForeignID',
|
||||
description: 'Custom foreign ID returned in DLR callbacks',
|
||||
},
|
||||
{
|
||||
displayName: 'Flash',
|
||||
name: 'flash',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
|
||||
description: "Send as flash message being displayed directly the receiver's display",
|
||||
},
|
||||
{
|
||||
displayName: 'Label',
|
||||
name: 'label',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'MyCustomLabel',
|
||||
description: 'Custom label used to group analytics',
|
||||
},
|
||||
{
|
||||
displayName: 'Performance Tracking',
|
||||
name: 'performance_tracking',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description:
|
||||
'Whether to enable performance tracking for URLs found in the message text',
|
||||
},
|
||||
{
|
||||
displayName: 'TTL',
|
||||
name: 'ttl',
|
||||
type: 'number',
|
||||
default: 2880,
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
},
|
||||
description:
|
||||
'Custom time to live specifying the validity period of a message in minutes',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Option',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['send'],
|
||||
resource: ['voice'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'From',
|
||||
name: 'from',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: '+4901234567890',
|
||||
description:
|
||||
'The caller ID. Please use only verified sender IDs, one of your virtual inbound numbers or one of our shared virtual numbers.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
for (let i = 0; i < this.getInputData().length; i++) {
|
||||
const resource = this.getNodeParameter('resource', i);
|
||||
const operation = this.getNodeParameter('operation', i);
|
||||
let responseData;
|
||||
try {
|
||||
if (resource === 'sms') {
|
||||
if (operation === 'send') {
|
||||
const from = this.getNodeParameter('from', i) as string;
|
||||
const to = this.getNodeParameter('to', i) as string;
|
||||
const text = this.getNodeParameter('message', i) as string;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
const body = {
|
||||
from,
|
||||
to,
|
||||
text,
|
||||
...options,
|
||||
};
|
||||
responseData = await sms77ApiRequest.call(this, 'POST', '/sms', body);
|
||||
}
|
||||
}
|
||||
|
||||
if (resource === 'voice') {
|
||||
if (operation === 'send') {
|
||||
const to = this.getNodeParameter('to', i) as string;
|
||||
const text = this.getNodeParameter('message', i) as string;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
const body = {
|
||||
to,
|
||||
text,
|
||||
...options,
|
||||
};
|
||||
responseData = await sms77ApiRequest.call(this, 'POST', '/voice', body);
|
||||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(responseData)) {
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
} else if (responseData !== undefined) {
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ error: error.message });
|
||||
continue;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"debug": {
|
||||
"type": "string"
|
||||
},
|
||||
"messages": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"parts": {
|
||||
"type": "integer"
|
||||
},
|
||||
"sender": {
|
||||
"type": "string"
|
||||
},
|
||||
"success": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"udh": {
|
||||
"type": "null"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"sms_type": {
|
||||
"type": "string"
|
||||
},
|
||||
"success": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"version": 3
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 252 176"><linearGradient id="a" x1="32.71" x2="115.06" y1="19.46" y2="67.11" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#01d468"/><stop offset=".1" stop-color="#15d875"/><stop offset=".41" stop-color="#50e59b"/><stop offset=".67" stop-color="#7befb7"/><stop offset=".88" stop-color="#96f5c9"/><stop offset="1" stop-color="#a0f7cf"/></linearGradient><path fill="url(#a)" d="m101.45 57-6.78 9.2-84.6-43.03C2.42 20.3.4 14.54 1.03 10.07 1.92 4.52 6.8.68 12.9.68h16.91l2.04 5.52-2.04 6.19H14.49l86.96 44.6z"/><linearGradient id="b" x1="110.13" x2="248.26" y1="44.67" y2="-35.11" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#01d468"/><stop offset=".26" stop-color="#22de7b"/><stop offset=".76" stop-color="#5ef29d"/><stop offset="1" stop-color="#75f9ab"/></linearGradient><path fill="url(#b)" d="M251.48 9.47c-1.1-3.28-4.5-8.79-15.24-8.79H29.82V12.4h37.16c1.72 0 3.38.03 4.99.11 3.88.16 7.43.5 10.66.97l.14.02c18.07 2.1 32.42 7.17 34.7 15.32a6.3 6.3 0 0 1 .21 3.66l-.02.15c-.67 3-2.98 6.66-6.49 11.44l-83.3 110.3a12.51 12.51 0 0 0-1.74 13.37 12.8 12.8 0 0 0 11.5 7.09 13.55 13.55 0 0 0 7.4-2.23l.87-.58c.17-.11.34-.24.48-.38l199-147.66c7.94-5.4 6.92-11.93 6.1-14.5zm-12.93 4.82L38.52 162.73c-.65.46-1.64.46-1.85.03-.1-.19.04-.6.41-1.04l82.63-109.56c3.73-4.94 7.6-10.04 9.57-15.46 3.01-8.32.98-15.9-5.74-21.36a37.5 37.5 0 0 0-4.14-2.95h117.06c2.22 0 3.26.31 3.71.52-.23.3-.7.76-1.62 1.38"/></svg>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
Reference in New Issue
Block a user