Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Twilio from 'twilio'
- const account_sid = process.env.ACCOUNT_SID;
- const auth_token = process.env.AUTH_TOKEN;
- const from_number = process.env.FROM_PHONENUMBER
- const country_code = process.env.COUNTRY_CODE
- const twilio = Twilio(account_sid, auth_token)
- class Sms {
- static async Send (to: string, body: string): Promise<JSON> {
- try {
- const sms = await twilio.messages.create({
- body: body,
- from: from_number, // '+19094432574',
- to: `+${country_code}${to}`
- });
- return Promise.resolve(sms.toJSON())
- } catch (e) {
- throw e
- }
- }
- }
- export default Sms
Add Comment
Please, Sign In to add comment