UNPKG

africastalking

Version:
74 lines (63 loc) 1.52 kB
import Africastalking from '../index.js' async function main () { const AT = Africastalking({ username: 'muchbeerapi', apiKey: 'db489491b8129638d600fe5ce2ac24ed99b8056567e670655ce9e7d0a96ed857' }) let re = await AT.APPLICATION.fetchAccount() console.log(re) const chat = AT.WHATSAPP const waNumber = '+255699997990' const phoneNumber = '+254718769882' re = await chat.createTemplate({ waNumber, name: 'amazing_offer', language: 'en', category: 'UTILITY', components: { header: { type: 'HEADER', format: 'TEXT', text: 'Offer {{1}}', example: { header_text: '12345678' } }, body: { type: 'BODY', text: '{{1}}, Get your free drink if you order using code {{2}}', example: { body_text: [ 'John', '12345678' ] } }, footer: { type: 'FOOTER', text: 'Thank you for using our service.' }, buttons: { type: 'BUTTONS', buttons: [ { type: 'PHONE_NUMBER', text: 'Contact Us', phone_number: '+08987654321' }, { type: 'URL', text: 'Talk to A Representative', url: 'https://coolurl.fake/contact/{{1}}', example: [ 'id' ] } ] } } }) console.log(re) console.log(re) } main().catch((ex) => console.error(ex))