Skip to content

Commit

Permalink
#added Whatsapp Business Phone number ID (You can use it check if its…
Browse files Browse the repository at this point in the history
… test number or live number) ##v1.1.1##

Signed-off-by: Trynos Muchemwa <trynosmuch@gmail.com>
  • Loading branch information
trysoft-team authored and PrinceTirah committed Jun 22, 2023
1 parent a7214f5 commit 4c43912
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 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.0",
"version": "1.1.1",
"description": "TrySoft Whatsapp Cloud Api Wrapper",
"main": "dist/index.js",
"scripts": {
Expand Down
8 changes: 7 additions & 1 deletion src/createBot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ export const createBot: ICreateBot = (fromPhoneNumberId, accessToken, opts) => {
return expressServer;
},
on: (event, cb) => {
const token = PubSub.subscribe(`bot-${fromPhoneNumberId}-${event}`, (_, data) => cb(data));
// 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)
});
return token;
},
unsubscribe: (token) => PubSub.unsubscribe(token),
Expand Down
1 change: 1 addition & 0 deletions src/createBot.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FreeFormObject } from './utils/misc';
import { PubSubEvent } from './utils/pubSub';

export interface Message {
wab_pid: string;
from: string;
name: string | undefined;
id: string;
Expand Down
3 changes: 3 additions & 0 deletions src/startExpressServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,12 @@ 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;

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

0 comments on commit 4c43912

Please sign in to comment.