louislam / uptime-kuma

A fancy self-hosted monitoring tool
https://uptime.kuma.pet
MIT License
56.31k stars 5.06k forks source link

Adding Twilio to notifications selections #2964

Closed SomeGuru closed 1 year ago

SomeGuru commented 1 year ago

⚠️ Please verify that this feature request has NOT been suggested before.

🏷️ Feature Request Type

New Notification

🔖 Feature description

Adding in Twilio as a SMS gateway for users to get the messages from the uptime-kuma.

They offer a few different APIs at https://www.twilio.com/docs/usage/api. It would be nice if able to convert to your vue.js code.

a sample of JAVA turned vue.js code would look similar to this, I would assume. JAVA Code:

// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Message message = Message.creator(
                new com.twilio.type.PhoneNumber("+15558675310"),
                new com.twilio.type.PhoneNumber("+15017122661"),
                "This is the ship that made the Kessel Run in fourteen parsecs?")
            .create();

        System.out.println(message.getSid());
    }
}

Converted to Vue.JS

<script>
export default {
  data() {
    return {
      ACCOUNT_SID: process.env.TWILIO_ACCOUNT_SID,
      AUTH_TOKEN: process.env.TWILIO_AUTH_TOKEN,
      phoneNumber1: "+15558675310",
      phoneNumber2: "+15017122661",
      messageBody: "This is the ship that made the Kessel Run in fourteen parsecs?",
    };
  },
  methods: {
    sendMessage() {
      const twilio = require('twilio')(this.ACCOUNT_SID, this.AUTH_TOKEN);

      twilio.messages
        .create({
          body: this.messageBody,
          from: this.phoneNumber1,
          to: this.phoneNumber2
        })
        .then(message => console.log(message.sid));
    },
  },
};
</script>

✔️ Solution

My users would benefit, I just would have to find a way to use the gateway properly to send the messages to approved phone numbers only. But still even if just to get the initial twilio messages to my phone would be a great thing.

❓ Alternatives

using the other provided, however then I cannot get to my cell sms to share with others that don't have the other applications on their phones.

📝 Additional Context

No response

Genc commented 1 year ago

@SomeGuru Currently, this feature is available in the latest version. Can you test it? If ok let's close issue

gaetanlord commented 1 year ago

I configure apprise to send sms message to twilio and it is working fine, see https://github.com/caronc/apprise/wiki#notification-services

Screenshot_2023-03-30_23-32-07

Genc commented 1 year ago

@gaetanlord Can you choose twilio from the dropdown list and try it? Not via Apprise. Uptime Kuma Version 1.21.1

gaetanlord commented 1 year ago

The only way I was able to make it work is via apprise.

On Fri, Mar 31, 2023 at 12:57 PM Ömer Faruk Genç @.***> wrote:

@gaetanlord https://github.com/gaetanlord Can you choose twilio from the dropdown list and try it? Not via Apprise. Uptime Kuma Version 1.21.1

— Reply to this email directly, view it on GitHub https://github.com/louislam/uptime-kuma/issues/2964#issuecomment-1492266201, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHSWGIJYK432CPEL6DPNYOTW64EJBANCNFSM6AAAAAAWEFSR5Y . You are receiving this because you were mentioned.Message ID: @.***>

-- Gaétan

Genc commented 1 year ago

@gaetanlord Why? If you have twilio account, you can try this way.

image

gaetanlord commented 1 year ago

I install it long time ago and it is working fine that way. You know, if it ain't broken don't fix it

On Sat, Apr 1, 2023, 13:06 Ömer Faruk Genç @.***> wrote:

@gaetanlord https://github.com/gaetanlord Why? If you have twilio account, you can try this way.

[image: image] https://user-images.githubusercontent.com/18603640/229304670-fca672f5-4dff-48b2-9a7e-49fff00de4e8.png

— Reply to this email directly, view it on GitHub https://github.com/louislam/uptime-kuma/issues/2964#issuecomment-1493047806, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHSWGIJVWUXVUID55YX2M6DW7BOAHANCNFSM6AAAAAAWEFSR5Y . You are receiving this because you were mentioned.Message ID: @.***>

Genc commented 1 year ago

@louislam Can we close this issue?

SyedAsadRazaDevops commented 1 year ago

@Genc and @gaetanlord However, my current version (1.20) doesn't have this feature. According to the official Uptime Kuma, the Twilio integration is available in version 1.21.

SyedAsadRazaDevops commented 1 year ago

@gaetanlord Why? If you have twilio account, you can try this way.

image

its greater with this new update, but there is still an issue how to add multiple numbers I try with "," but it still failed.

SyedAsadRazaDevops commented 1 year ago

ERROR

AxiosError: Request failed with status code 400 {"code":21211,"message":"Invalid 'To' Phone Number","status":400}

CommanderStorm commented 1 year ago

how to add multiple numbers

Where did you read that this is a feature that is supported by either uptime-kuma or twillio? The API docs don't say this is a feature.

One notification can, according to their API only contact one To field

Plese refrain from necroposting on closed issues, as this makes issue manaement harder. Instead open a help/... issue