Skip to content

Commit

Permalink
#added Whatsapp Business Phone number (You can use it check if its te…
Browse files Browse the repository at this point in the history
…st number or live number and multi numbers) ##v1.1.2##

Signed-off-by: Trynos Muchemwa <trynosmuch@gmail.com>
  • Loading branch information
PrinceTirah committed Oct 18, 2023
1 parent 4c43912 commit f284a42
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "trysoftwacloudapi",
"version": "1.1.1",
"version": "1.1.2",
"description": "TrySoft Whatsapp Cloud Api Wrapper",
"main": "dist/index.js",
"scripts": {
Expand Down
2 changes: 0 additions & 2 deletions src/createBot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ export const createBot: ICreateBot = (fromPhoneNumberId, accessToken, opts) => {
on: (event, cb) => {
// eslint-disable-next-line
const token = PubSub.subscribe(`bot-${fromPhoneNumberId}-${event}`, function(_, data) {
// eslint-disable-next-line
data['wab_pid'] = fromPhoneNumberId;
// eslint-disable-next-line
cb(data)
});
Expand Down
1 change: 1 addition & 0 deletions src/createBot.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { PubSubEvent } from './utils/pubSub';

export interface Message {
wab_pid: string;
wab_number: string;
from: string;
name: string | undefined;
id: string;
Expand Down
4 changes: 4 additions & 0 deletions src/startExpressServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const startExpressServer = (
...rest
} = req.body.entry[0].changes[0].value.messages[0];
const fromPhoneNumberId = req.body.entry[0].changes[0].value.metadata.phone_number_id;
const fromPhoneNumber = req.body.entry[0].changes[0].value.metadata.display_phone_number;

let event: PubSubEvent | undefined;
let data: FreeFormObject | undefined;
Expand Down Expand Up @@ -119,10 +120,13 @@ export const startExpressServer = (
const name = req.body.entry[0].changes[0].value.contacts?.[0]?.profile?.name ?? undefined;
// eslint-disable-next-line
const wab_pid = fromPhoneNumberId;
// eslint-disable-next-line
const wab_number = fromPhoneNumber;

if (event && data) {
const payload: Message = {
wab_pid,
wab_number,
from,
name,
id,
Expand Down

0 comments on commit f284a42

Please sign in to comment.