feat: add Signalwire integration
This commit is contained in:
3
packages/backend/src/apps/signalwire/actions/index.ts
Normal file
3
packages/backend/src/apps/signalwire/actions/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import sendSms from './send-sms';
|
||||||
|
|
||||||
|
export default [sendSms];
|
@@ -0,0 +1,50 @@
|
|||||||
|
import defineAction from '../../../../helpers/define-action';
|
||||||
|
|
||||||
|
export default defineAction({
|
||||||
|
name: 'Send an SMS',
|
||||||
|
key: 'sendSms',
|
||||||
|
description: 'Sends an SMS',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'From Number',
|
||||||
|
key: 'fromNumber',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
description:
|
||||||
|
'The number to send the SMS from. Include only country code. Example: 491234567890',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'To Number',
|
||||||
|
key: 'toNumber',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
description:
|
||||||
|
'The number to send the SMS to. Include only country code. Example: 491234567890',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Message',
|
||||||
|
key: 'message',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
description: 'The content of the message.',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const requestPath = `/api/laml/2010-04-01/Accounts/${$.auth.data.accountSid}/Messages`;
|
||||||
|
const messageBody = $.step.parameters.message;
|
||||||
|
|
||||||
|
const fromNumber = '%2B' + ($.step.parameters.fromNumber as string).trim();
|
||||||
|
const toNumber = '%2B' + ($.step.parameters.toNumber as string).trim();
|
||||||
|
|
||||||
|
const response = await $.http.post(
|
||||||
|
'https://' + $.auth.data.spaceName + '.' + $.auth.data.spaceRegion + 'signalwire.com' + requestPath,
|
||||||
|
`Body=${messageBody}&From=${fromNumber}&To=${toNumber}`
|
||||||
|
);
|
||||||
|
|
||||||
|
$.setActionItem({ raw: response.data });
|
||||||
|
},
|
||||||
|
});
|
1
packages/backend/src/apps/signalwire/assets/favicon.svg
Normal file
1
packages/backend/src/apps/signalwire/assets/favicon.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg id="a1100050-5390-497e-a7fa-2bb69ec95c7c" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 318.33 362.7"><defs><style>.a463a3b0-e95c-44d7-b809-5997966784eb{fill:#044ef4;}.b59fade4-5c2c-49f1-a6bf-917d1f195a19{fill:#f72a72;}</style></defs><path class="a463a3b0-e95c-44d7-b809-5997966784eb" d="M389.17,278c0,10.31-2.8,17.06-8.37,22.62q-50.07,49.95-100.19,99.85C269,412,252.06,412.54,240.55,402c-12.12-11.13-12.6-29.39-.75-41.47,15-15.34,30.32-30.47,45.56-45.63q27.47-27.3,55.06-54.45c8.91-8.75,20.84-11.07,31.77-6.1C383.3,259.36,388.79,268.25,389.17,278Z" transform="translate(-70.83 -46.81)"/><path class="a463a3b0-e95c-44d7-b809-5997966784eb" d="M70.84,172.94c.16-5.21,2.93-11.81,8.36-17.24q49.89-49.77,99.8-99.53c6.92-6.91,15.08-10.45,24.83-9.06,11.55,1.65,19.62,8.12,23.38,19.22s1.16,21.14-7,29.43q-23.87,24.21-48,48.1-26.22,26.07-52.58,52c-8.93,8.76-20.84,10.92-31.8,6.13C77.17,197.35,70.65,187.14,70.84,172.94Z" transform="translate(-70.83 -46.81)"/><path class="b59fade4-5c2c-49f1-a6bf-917d1f195a19" d="M93.68,210.69c3.79-.17,6.91-.08,10-.49a34.39,34.39,0,0,0,20.56-10.34c6.38-6.52,12.79-13,19.33-19.66,1.23,1.09,2,1.7,2.66,2.38q36.92,36.9,73.81,73.83c8.07,8.1,10.9,17.87,7.66,28.86-3.12,10.58-10.39,17.35-21.17,19.77-9.33,2.1-18.23.31-25.07-6.47C152.25,269.64,123.32,240.42,93.68,210.69Z" transform="translate(-70.83 -46.81)"/><path class="b59fade4-5c2c-49f1-a6bf-917d1f195a19" d="M366.57,246c-15-1.53-25.7,4.26-34.72,14.22-4.89,5.4-10.23,10.39-15.51,15.69-1.1-1-1.86-1.59-2.56-2.28q-36.94-36.93-73.86-73.89c-8.07-8.1-10.89-17.89-7.56-28.89,3.19-10.56,10.47-17.31,21.28-19.68,9.56-2.1,18.45,0,25.44,6.92q43,42.57,85.61,85.47C365.12,244,365.44,244.54,366.57,246Z" transform="translate(-70.83 -46.81)"/></svg>
|
After Width: | Height: | Size: 1.7 KiB |
65
packages/backend/src/apps/signalwire/auth/index.ts
Normal file
65
packages/backend/src/apps/signalwire/auth/index.ts
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
import verifyCredentials from './verify-credentials';
|
||||||
|
import isStillVerified from './is-still-verified';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
key: 'accountSid',
|
||||||
|
label: 'Project ID',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
readOnly: false,
|
||||||
|
value: null,
|
||||||
|
placeholder: null,
|
||||||
|
description:
|
||||||
|
'Log into your Signalwire account and find the Project ID',
|
||||||
|
clickToCopy: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'authToken',
|
||||||
|
label: 'API Token',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
readOnly: false,
|
||||||
|
value: null,
|
||||||
|
placeholder: null,
|
||||||
|
description: 'API Token in the respective project',
|
||||||
|
clickToCopy: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'spaceRegion',
|
||||||
|
label: 'Signalwire Region',
|
||||||
|
type: 'dropdown' as const,
|
||||||
|
required: true,
|
||||||
|
readOnly: false,
|
||||||
|
value: '',
|
||||||
|
placeholder: null,
|
||||||
|
description: 'Most people should choose the default, "US"',
|
||||||
|
clickToCopy: false,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: 'US',
|
||||||
|
value: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'EU',
|
||||||
|
value: 'eu-',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'spaceName',
|
||||||
|
label: 'Space Name',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
readOnly: false,
|
||||||
|
value: null,
|
||||||
|
placeholder: null,
|
||||||
|
description: 'Name of your Signalwire space that contains the project',
|
||||||
|
clickToCopy: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
verifyCredentials,
|
||||||
|
isStillVerified,
|
||||||
|
};
|
@@ -0,0 +1,9 @@
|
|||||||
|
import { IGlobalVariable } from '@automatisch/types';
|
||||||
|
import verifyCredentials from './verify-credentials';
|
||||||
|
|
||||||
|
const isStillVerified = async ($: IGlobalVariable) => {
|
||||||
|
await verifyCredentials($);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default isStillVerified;
|
@@ -0,0 +1,11 @@
|
|||||||
|
import { IGlobalVariable } from '@automatisch/types';
|
||||||
|
|
||||||
|
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||||
|
await $.http.get('https://' + $.auth.data.spaceName + '.' + $.auth.data.spaceRegion + 'signalwire.com' + '/api/laml/2010-04-01/Accounts');
|
||||||
|
|
||||||
|
await $.auth.set({
|
||||||
|
screenName: $.auth.data.accountSid,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default verifyCredentials;
|
@@ -0,0 +1,20 @@
|
|||||||
|
import { TBeforeRequest } from '@automatisch/types';
|
||||||
|
|
||||||
|
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||||
|
if (
|
||||||
|
requestConfig.headers &&
|
||||||
|
$.auth.data?.accountSid &&
|
||||||
|
$.auth.data?.authToken
|
||||||
|
) {
|
||||||
|
requestConfig.headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||||
|
|
||||||
|
requestConfig.auth = {
|
||||||
|
username: $.auth.data.accountSid as string,
|
||||||
|
password: $.auth.data.authToken as string,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestConfig;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default addAuthHeader;
|
0
packages/backend/src/apps/signalwire/index.d.ts
vendored
Normal file
0
packages/backend/src/apps/signalwire/index.d.ts
vendored
Normal file
20
packages/backend/src/apps/signalwire/index.ts
Normal file
20
packages/backend/src/apps/signalwire/index.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import defineApp from '../../helpers/define-app';
|
||||||
|
import addAuthHeader from './common/add-auth-header';
|
||||||
|
import auth from './auth';
|
||||||
|
import triggers from './triggers';
|
||||||
|
import actions from './actions';
|
||||||
|
|
||||||
|
export default defineApp({
|
||||||
|
name: 'Signalwire',
|
||||||
|
key: 'signalwire',
|
||||||
|
iconUrl: 'https://signalwire.com/favicon.svg',
|
||||||
|
authDocUrl: 'https://automatisch.io/docs/apps/signalwire/connection',
|
||||||
|
supportsConnections: true,
|
||||||
|
baseUrl: 'https://signalwire.com',
|
||||||
|
apiBaseUrl: '',
|
||||||
|
primaryColor: '044cf6',
|
||||||
|
beforeRequest: [addAuthHeader],
|
||||||
|
auth,
|
||||||
|
triggers,
|
||||||
|
actions,
|
||||||
|
});
|
3
packages/backend/src/apps/signalwire/triggers/index.ts
Normal file
3
packages/backend/src/apps/signalwire/triggers/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import receiveSms from './receive-sms';
|
||||||
|
|
||||||
|
export default [receiveSms];
|
@@ -0,0 +1,27 @@
|
|||||||
|
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||||
|
|
||||||
|
const fetchMessages = async ($: IGlobalVariable) => {
|
||||||
|
const toNumber = $.step.parameters.toNumber as string;
|
||||||
|
|
||||||
|
let response;
|
||||||
|
let requestPath = 'https://' + $.auth.data.spaceName + '.' + $.auth.data.spaceRegion + 'signalwire.com' + `/api/laml/2010-04-01/Accounts/${$.auth.data.accountSid}/Messages?To=${toNumber}`;
|
||||||
|
|
||||||
|
do {
|
||||||
|
response = await $.http.get(requestPath);
|
||||||
|
|
||||||
|
response.data.messages.forEach((message: IJSONObject) => {
|
||||||
|
const dataItem = {
|
||||||
|
raw: message,
|
||||||
|
meta: {
|
||||||
|
internalId: message.date_sent as string,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
$.pushTriggerItem(dataItem);
|
||||||
|
});
|
||||||
|
|
||||||
|
requestPath = 'https://' + $.auth.data.spaceName + '.' + $.auth.data.spaceRegion + 'signalwire.com' + response.data.next_page_uri;
|
||||||
|
} while (requestPath);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default fetchMessages;
|
@@ -0,0 +1,23 @@
|
|||||||
|
import defineTrigger from '../../../../helpers/define-trigger';
|
||||||
|
import fetchMessages from './fetch-messages';
|
||||||
|
|
||||||
|
export default defineTrigger({
|
||||||
|
name: 'Receive SMS',
|
||||||
|
key: 'receiveSms',
|
||||||
|
pollInterval: 15,
|
||||||
|
description: 'Triggers when a new SMS is received.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'To Number',
|
||||||
|
key: 'toNumber',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
description:
|
||||||
|
'The number to receive the SMS on. It should be a Signalwire number in your project.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
await fetchMessages($);
|
||||||
|
},
|
||||||
|
});
|
@@ -133,6 +133,16 @@ export default defineConfig({
|
|||||||
{ text: 'Connection', link: '/apps/scheduler/connection' },
|
{ text: 'Connection', link: '/apps/scheduler/connection' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
text: 'Signalwire',
|
||||||
|
collapsible: true,
|
||||||
|
collapsed: true,
|
||||||
|
items: [
|
||||||
|
{ text: 'Triggers', link: '/apps/signalwire/triggers' },
|
||||||
|
{ text: 'Actions', link: '/apps/signalwire/actions' },
|
||||||
|
{ text: 'Connection', link: '/apps/signalwire/connection' },
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
text: 'Slack',
|
text: 'Slack',
|
||||||
collapsible: true,
|
collapsible: true,
|
||||||
|
12
packages/docs/pages/apps/signalwire/actions.md
Normal file
12
packages/docs/pages/apps/signalwire/actions.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
favicon: /favicons/signalwire.svg
|
||||||
|
items:
|
||||||
|
- name: Send an SMS
|
||||||
|
desc: Sends an SMS
|
||||||
|
---
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import CustomListing from '../../components/CustomListing.vue'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<CustomListing />
|
16
packages/docs/pages/apps/signalwire/connection.md
Normal file
16
packages/docs/pages/apps/signalwire/connection.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Signalwire
|
||||||
|
|
||||||
|
:::info
|
||||||
|
This page explains the steps you need to follow to set up a Signalwire connection in Automatisch. If any of the steps are outdated, please let us know!
|
||||||
|
:::
|
||||||
|
|
||||||
|
1. Go to the Signalwire API page in your respective project (https://{space}.signalwire.com/credentials)
|
||||||
|
2. Copy **Project ID** and paste it to the **Project ID** field on the
|
||||||
|
Automatisch connection creation page.
|
||||||
|
3. Create/Copy **API Token** and paste it to the **API Token** field on the
|
||||||
|
Automatisch connection creation page.
|
||||||
|
4. Select your **Region** (US for most users).
|
||||||
|
5. Provide your **Space Name** from the URL and paste it to the **Space NAME** field on the
|
||||||
|
Automatisch connection creation page.
|
||||||
|
6. Click **Submit** button on Automatisch.
|
||||||
|
7. Now you can start using the new Signalwire connection!
|
12
packages/docs/pages/apps/signalwire/triggers.md
Normal file
12
packages/docs/pages/apps/signalwire/triggers.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
favicon: /favicons/signalwire.svg
|
||||||
|
items:
|
||||||
|
- name: Receive SMS
|
||||||
|
desc: Triggers when a new SMS is received.
|
||||||
|
---
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import CustomListing from '../../components/CustomListing.vue'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<CustomListing />
|
@@ -33,6 +33,7 @@ The build integrations section is best understood when read from beginning to en
|
|||||||
|
|
||||||
- [DeepL](https://github.com/automatisch/automatisch/tree/main/packages/backend/src/apps/deepl/auth/index.ts)
|
- [DeepL](https://github.com/automatisch/automatisch/tree/main/packages/backend/src/apps/deepl/auth/index.ts)
|
||||||
- [Twilio](https://github.com/automatisch/automatisch/tree/main/packages/backend/src/apps/twilio/auth/index.ts)
|
- [Twilio](https://github.com/automatisch/automatisch/tree/main/packages/backend/src/apps/twilio/auth/index.ts)
|
||||||
|
- [Signalwire](https://github.com/automatisch/automatisch/tree/main/packages/backend/src/apps/signalwire/auth/index.ts)
|
||||||
- [SMTP](https://github.com/automatisch/automatisch/tree/main/packages/backend/src/apps/smtp/auth/index.ts)
|
- [SMTP](https://github.com/automatisch/automatisch/tree/main/packages/backend/src/apps/smtp/auth/index.ts)
|
||||||
|
|
||||||
### Without authentication
|
### Without authentication
|
||||||
@@ -60,6 +61,7 @@ If you are developing a webhook-based trigger, you need to ensure that the webho
|
|||||||
- [Search tweets - Twitter](https://github.com/automatisch/automatisch/tree/main/packages/backend/src/apps/twitter/triggers/search-tweets/index.ts)
|
- [Search tweets - Twitter](https://github.com/automatisch/automatisch/tree/main/packages/backend/src/apps/twitter/triggers/search-tweets/index.ts)
|
||||||
- [New issues - Github](https://github.com/automatisch/automatisch/tree/main/packages/backend/src/apps/github/triggers/new-issues/index.ts)
|
- [New issues - Github](https://github.com/automatisch/automatisch/tree/main/packages/backend/src/apps/github/triggers/new-issues/index.ts)
|
||||||
- [Receive SMS - Twilio](https://github.com/automatisch/automatisch/tree/main/packages/backend/src/apps/twilio/triggers/receive-sms/index.ts)
|
- [Receive SMS - Twilio](https://github.com/automatisch/automatisch/tree/main/packages/backend/src/apps/twilio/triggers/receive-sms/index.ts)
|
||||||
|
- [Receive SMS - Signalwire](https://github.com/automatisch/automatisch/tree/main/packages/backend/src/apps/signalwire/triggers/receive-sms/index.ts)
|
||||||
- [New photos - Flickr](https://github.com/automatisch/automatisch/tree/main/packages/backend/src/apps/flickr/triggers/new-photos/index.ts)
|
- [New photos - Flickr](https://github.com/automatisch/automatisch/tree/main/packages/backend/src/apps/flickr/triggers/new-photos/index.ts)
|
||||||
|
|
||||||
### Pagination with ascending order
|
### Pagination with ascending order
|
||||||
|
@@ -17,6 +17,7 @@ Following integrations are currently supported by Automatisch.
|
|||||||
- [RSS](/apps/rss/triggers)
|
- [RSS](/apps/rss/triggers)
|
||||||
- [Salesforce](/apps/salesforce/triggers)
|
- [Salesforce](/apps/salesforce/triggers)
|
||||||
- [Scheduler](/apps/scheduler/triggers)
|
- [Scheduler](/apps/scheduler/triggers)
|
||||||
|
- [Signalwire](/apps/signalwire/triggers)
|
||||||
- [Slack](/apps/slack/actions)
|
- [Slack](/apps/slack/actions)
|
||||||
- [SMTP](/apps/smtp/actions)
|
- [SMTP](/apps/smtp/actions)
|
||||||
- [Stripe](/apps/stripe/triggers)
|
- [Stripe](/apps/stripe/triggers)
|
||||||
|
1
packages/docs/pages/public/favicons/signalwire.svg
Normal file
1
packages/docs/pages/public/favicons/signalwire.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg id="a1100050-5390-497e-a7fa-2bb69ec95c7c" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 318.33 362.7"><defs><style>.a463a3b0-e95c-44d7-b809-5997966784eb{fill:#044ef4;}.b59fade4-5c2c-49f1-a6bf-917d1f195a19{fill:#f72a72;}</style></defs><path class="a463a3b0-e95c-44d7-b809-5997966784eb" d="M389.17,278c0,10.31-2.8,17.06-8.37,22.62q-50.07,49.95-100.19,99.85C269,412,252.06,412.54,240.55,402c-12.12-11.13-12.6-29.39-.75-41.47,15-15.34,30.32-30.47,45.56-45.63q27.47-27.3,55.06-54.45c8.91-8.75,20.84-11.07,31.77-6.1C383.3,259.36,388.79,268.25,389.17,278Z" transform="translate(-70.83 -46.81)"/><path class="a463a3b0-e95c-44d7-b809-5997966784eb" d="M70.84,172.94c.16-5.21,2.93-11.81,8.36-17.24q49.89-49.77,99.8-99.53c6.92-6.91,15.08-10.45,24.83-9.06,11.55,1.65,19.62,8.12,23.38,19.22s1.16,21.14-7,29.43q-23.87,24.21-48,48.1-26.22,26.07-52.58,52c-8.93,8.76-20.84,10.92-31.8,6.13C77.17,197.35,70.65,187.14,70.84,172.94Z" transform="translate(-70.83 -46.81)"/><path class="b59fade4-5c2c-49f1-a6bf-917d1f195a19" d="M93.68,210.69c3.79-.17,6.91-.08,10-.49a34.39,34.39,0,0,0,20.56-10.34c6.38-6.52,12.79-13,19.33-19.66,1.23,1.09,2,1.7,2.66,2.38q36.92,36.9,73.81,73.83c8.07,8.1,10.9,17.87,7.66,28.86-3.12,10.58-10.39,17.35-21.17,19.77-9.33,2.1-18.23.31-25.07-6.47C152.25,269.64,123.32,240.42,93.68,210.69Z" transform="translate(-70.83 -46.81)"/><path class="b59fade4-5c2c-49f1-a6bf-917d1f195a19" d="M366.57,246c-15-1.53-25.7,4.26-34.72,14.22-4.89,5.4-10.23,10.39-15.51,15.69-1.1-1-1.86-1.59-2.56-2.28q-36.94-36.93-73.86-73.89c-8.07-8.1-10.89-17.89-7.56-28.89,3.19-10.56,10.47-17.31,21.28-19.68,9.56-2.1,18.45,0,25.44,6.92q43,42.57,85.61,85.47C365.12,244,365.44,244.54,366.57,246Z" transform="translate(-70.83 -46.81)"/></svg>
|
After Width: | Height: | Size: 1.7 KiB |
Reference in New Issue
Block a user