File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# @photon-ai/whatsapp-business
22
3- To install dependencies:
3+ TypeScript SDK for the WhatsApp Business API via Photon's Spectrum gRPC gateway.
4+
5+ ## Installation
46
57``` bash
6- bun install
8+ bun add @photon-ai/whatsapp-business
79```
810
9- To run:
11+ ## Quick start
1012
11- ``` bash
12- bun run src/index.ts
13+ ``` ts
14+ import { createClient } from " @photon-ai/whatsapp-business" ;
15+
16+ const client = createClient ({
17+ accessToken: process .env .WA_ACCESS_TOKEN ! ,
18+ phoneNumberId: process .env .WA_PHONE_NUMBER_ID ! ,
19+ appSecret: process .env .WA_APP_SECRET ! ,
20+ });
21+
22+ // Send a text message
23+ await client .messages .send ({
24+ to: " +1234567890" ,
25+ text: { body: " Hello from the SDK!" },
26+ });
27+
28+ // Subscribe to inbound events
29+ const stream = client .events .subscribe ();
30+ for await (const event of stream ) {
31+ console .log (event );
32+ }
33+
34+ await client .close ();
1335```
1436
15- This project was created using ` bun init ` in bun v1.3.5. [ Bun] ( https://bun.com ) is a fast all-in-one JavaScript runtime.
37+ ## Development
38+
39+ ``` bash
40+ bun install # install dependencies
41+ bun run generate # regenerate protobuf types
42+ bun run build # generate + bundle with tsup
43+ bun run check # type-check
44+ bun run lint # lint with Biome
45+ bun run lint:fix # auto-fix lint issues
46+ bun test # run tests
47+ ```
You can’t perform that action at this time.
0 commit comments