Guest User

Untitled

a guest
Oct 20th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import Twilio from 'twilio'
  2.  
  3. const account_sid = process.env.ACCOUNT_SID;
  4. const auth_token = process.env.AUTH_TOKEN;
  5. const from_number = process.env.FROM_PHONENUMBER
  6. const country_code = process.env.COUNTRY_CODE
  7. const twilio = Twilio(account_sid, auth_token)
  8. class Sms {
  9. static async Send (to: string, body: string): Promise<JSON> {
  10. try {
  11. const sms = await twilio.messages.create({
  12. body: body,
  13. from: from_number, // '+19094432574',
  14. to: `+${country_code}${to}`
  15. });
  16. return Promise.resolve(sms.toJSON())
  17. } catch (e) {
  18. throw e
  19. }
  20. }
  21. }
  22. export default Sms
Add Comment
Please, Sign In to add comment