Runs every 1 hrs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const axios = require("axios");
// Your Telnyx API Key
const apiKey = "your_api_key";
// Function to send SMS
async function sendSMS(to, from) {
try {
const response = await axios.post(
"https://api.telnyx.com/v2/messages",
{
from: from, // Your Telnyx phone number
to: to, // Recipient's phone number
text: "Hello World",
},
{
headers: {
"Authorization": `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
},
);
console.log(`Message sent with ID: ${response.data.data.id}`);
} catch (error) {
console.error(`Failed to send message: ${error.response ? error.response.data : error.message}`);
}
}
// Usage
sendSMS("+1234567890", "+0987654321"); // Replace with actual phone numbers
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
September 3, 2024