ng-whatsapp-cloud-api v0.0.2
NgWhatsappCloudApi
Unofficial Angular wrapper for the WhatsApp Cloud API
Features supported
- Sending messages
- Sending Media (images, audio, video and ducuments)
- Sending location
- Sending template messages
Installation
First you need to install the npm module:
npm install ng-whatsapp-cloud-api --saveSetting up
To get started using this package, you will need TOKEN and TEST WHATSAPP NUMBER (the library works either with a production phone number, if you have one) which you can get from the Facebook Developer Portal
Here are steps to follow for you to get started:
- Go to your apps
- create an app
- Select Business >> Business
- It will prompt you to enter basic app informations
- It will ask you to add products to your app a. Add WhatsApp Messenger
- Right there you will see a your TOKEN and TEST WHATSAPP NUMBER and its phone_number_id
- Lastly verify the number you will be using for testing on the To field.
Authentication
To authenticate your application, you need to specify the YOUR_META_WHATSAPP_APP_ACCESS_TOKEN and the YOUR_PHONE_NUMBER_ID of your application.
Usage
1. Import the NgWhatsappCloudApiModule:
Finally, you can use ngx-translate in your Angular project. You have to import NgWhatsappCloudApiModule.forRoot() in the root NgModule of your application.
The forRoot static method is a convention that provides and configures services at the same time.
Make sure you only call this method in the root module of your application, most of the time called AppModule.
This method allows you to configure the NgWhatsappCloudApiModule by specifying a loader, a parser and/or a missing translations handler.
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {NgWhatsappCloudApiModule} from 'ng-whatsapp-cloud-api';
@NgModule({
imports: [
BrowserModule,
NgWhatsappCloudApiModule.forRoot({
phoneNumberId: 'YOUR_PHONE_NUMBER_ID',
token: 'YOUR_META_WHATSAPP_APP_ACCESS_TOKEN'
})
],
bootstrap: [AppComponent]
})
export class AppModule { }2. Init the NgWhatsappCloudApiService for your application:
import {Component} from '@angular/core';
import {NgWhatsappCloudApiService} from 'ng-whatsapp-cloud-api';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'whatsapp-cloud-api';
constructor(private wapi: NgWhatsappCloudApiService) {}
send() {
this.wapi.sendMessage("hello world", "554xxxxxxxxxx");
}
}Contributing
Contribute to make more improvement and fix bugs.
License
The MIT License (MIT). Please see License File for more information.