Skip to content

Commit 5cfa5f4

Browse files
committed
fix: trigger release
Signed-off-by: sarthakjdev <jsarthak448@gmail.com>
1 parent 79a882c commit 5cfa5f4

7 files changed

Lines changed: 55 additions & 52 deletions

File tree

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
export const WHATSAPP_BUSINESS_ACCOUNT_ID = process.env.WHATSAPP_BUSINESS_ACCOUNT_ID
2-
export const WHATSAPP_API_ACCESS_TOKEN = process.env.WHATSAPP_API_ACCESS_TOKEN
3-
export const WHATSAPP_PHONE_NUMBER_ID = process.env.WHATSAPP_PHONE_NUMBER_ID
4-
export const WHATSAPP_WEBHOOK_SECRET = process.env.WHATSAPP_WEBHOOK_SECRET
1+
export const WHATSAPP_BUSINESS_ACCOUNT_ID =
2+
process.env.WHATSAPP_BUSINESS_ACCOUNT_ID;
3+
export const WHATSAPP_API_ACCESS_TOKEN = process.env.WHATSAPP_API_ACCESS_TOKEN;
4+
export const WHATSAPP_PHONE_NUMBER_ID = process.env.WHATSAPP_PHONE_NUMBER_ID;
5+
export const WHATSAPP_WEBHOOK_SECRET = process.env.WHATSAPP_WEBHOOK_SECRET;
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export default async function (message) {
2-
console.log('TextMessage event:', message)
3-
await message.reply({
4-
message: new TextMessage({
5-
text: 'Hello, World!'
6-
})
7-
})
2+
console.log("TextMessage event:", message);
3+
await message.reply({
4+
message: new TextMessage({
5+
text: "Hello, World!",
6+
}),
7+
});
88
}
Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
1-
import 'dotenv/config'
2-
import {whatsappClient} from './utils/client'
3-
import {readdirSync} from 'fs'
4-
import {TextMessage} from 'wapi.js'
5-
1+
import "dotenv/config";
2+
import { whatsappClient } from "./utils/client";
3+
import { readdirSync } from "fs";
4+
import { TextMessage } from "wapi.js";
65

76
function loadEventListeners() {
8-
readdirSync(`${__dirname}/src/events/`)
9-
.filter((file) => file.endsWith('.js'))
10-
.map((file) => client.on(file.split('.js')[0], require(`${__dirname}/events/${file}`)))
7+
readdirSync(`${__dirname}/src/events/`)
8+
.filter((file) => file.endsWith(".js"))
9+
.map((file) =>
10+
client.on(file.split(".js")[0], require(`${__dirname}/events/${file}`))
11+
);
1112
}
1213

13-
async function init(){
14-
loadEventListeners()
15-
await client.initiate()
16-
// send a message to a number
17-
await whatsappClient.message.send({
18-
message: new TextMessage({ text: 'hello, world!' }),
19-
phoneNumber: '<replace-me>'
20-
})
14+
async function init() {
15+
loadEventListeners();
16+
await client.initiate();
17+
// send a message to a number
18+
await whatsappClient.message.send({
19+
message: new TextMessage({ text: "hello, world!" }),
20+
phoneNumber: "<replace-me>",
21+
});
2122
}
2223

23-
process.on('unhandledRejection', (error) => {
24-
console.error('Unhandled promise rejection:', error)
25-
})
24+
process.on("unhandledRejection", (error) => {
25+
console.error("Unhandled promise rejection:", error);
26+
});
2627

27-
init.catch(error => console.error(error))
28+
init.catch((error) => console.error(error));
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
import { Client } from '@wapijs/wapi.js'
1+
import { Client } from "@wapijs/wapi.js";
22
import {
3-
WHATSAPP_API_ACCESS_TOKEN,
4-
WHATSAPP_BUSINESS_ACCOUNT_ID,
5-
WHATSAPP_PHONE_NUMBER_ID,
6-
WHATSAPP_WEBHOOK_SECRET
7-
} from '../constant'
3+
WHATSAPP_API_ACCESS_TOKEN,
4+
WHATSAPP_BUSINESS_ACCOUNT_ID,
5+
WHATSAPP_PHONE_NUMBER_ID,
6+
WHATSAPP_WEBHOOK_SECRET,
7+
} from "../constant";
88

99
if (
10-
!WHATSAPP_API_ACCESS_TOKEN ||
11-
!WHATSAPP_BUSINESS_ACCOUNT_ID ||
12-
!WHATSAPP_PHONE_NUMBER_ID ||
13-
!WHATSAPP_WEBHOOK_SECRET
10+
!WHATSAPP_API_ACCESS_TOKEN ||
11+
!WHATSAPP_BUSINESS_ACCOUNT_ID ||
12+
!WHATSAPP_PHONE_NUMBER_ID ||
13+
!WHATSAPP_WEBHOOK_SECRET
1414
) {
15-
throw new Error('Configs not defined!')
15+
throw new Error("Configs not defined!");
1616
}
1717

1818
export const whatsappClient = new Client({
19-
apiAccessToken: WHATSAPP_API_ACCESS_TOKEN,
20-
businessAccountId: WHATSAPP_BUSINESS_ACCOUNT_ID,
21-
phoneNumberId: WHATSAPP_PHONE_NUMBER_ID,
22-
port: 8080,
23-
webhookEndpoint: '/webhook',
24-
webhookSecret: WHATSAPP_WEBHOOK_SECRET
25-
})
19+
apiAccessToken: WHATSAPP_API_ACCESS_TOKEN,
20+
businessAccountId: WHATSAPP_BUSINESS_ACCOUNT_ID,
21+
phoneNumberId: WHATSAPP_PHONE_NUMBER_ID,
22+
port: 8080,
23+
webhookEndpoint: "/webhook",
24+
webhookSecret: WHATSAPP_WEBHOOK_SECRET,
25+
});
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { type TextMessageEvent } from 'wapi.js'
1+
import { type TextMessageEvent } from '@wapijs/wapi.js'
22

33
export default async function (message: TextMessageEvent) {
44
console.log(message)
5-
await message.reply({
6-
5+
await message.reply({
6+
77
})
88
}

packages/create-wapi-bot/template/typescript/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { whatsappClient } from "./utils/client.js"
2-
import { TextMessage } from 'wapi.js'
2+
import { TextMessage } from '@wapijs/wapi.js'
33
import { readdir } from 'node:fs/promises'
44

55

packages/wapi.js/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
dist
22
.eslintrc.js
3+

0 commit comments

Comments
 (0)