Skip to content

Instantly share code, notes, and snippets.

@AnthonyLzq
Created January 24, 2023 04:03
Show Gist options
  • Save AnthonyLzq/47d963d4a2fadc59cc7ab0774609c833 to your computer and use it in GitHub Desktop.
Save AnthonyLzq/47d963d4a2fadc59cc7ab0774609c833 to your computer and use it in GitHub Desktop.
Script to send a Whatsapp message with Twilio
import { client } from './twilio'
const sendPhotoThroughWhatsapp = async (
imageUrl: string,
phoneNumber: string
) => {
await client.messages.create({
from: `whatsapp:${process.env.TWILIO_PHONE_NUMBER}`, // Celular propio que le compramos a Twilio
to: `whatsapp:${phoneNumber}`,
body: 'This may be interesting for you.', // ``Template'' que creamos
mediaUrl: [imageUrl]
})
console.log('Image sent')
}
export { sendPhotoThroughWhatsapp }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment