Skip to content

Commit 64b2800

Browse files
authored
Compile example project (#736)
I found example project cannot be compiled by tsc, so this change fixes it and adds a build script to check there is no error in CI.
1 parent b873ad6 commit 64b2800

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.github/workflows/test.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,10 @@ jobs:
4444
run: export NODE_OPTIONS=--max-old-space-size=6144; npm test
4545
- name: Test building docs
4646
run: export NODE_OPTIONS=--openssl-legacy-provider; npm run docs:build
47+
- name: Test building examples
48+
run: |
49+
cd examples/echo-bot-ts
50+
npm run build-sdk
51+
npm install
52+
npm run build
53+
cd -

examples/echo-bot-ts/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@ const client = new messagingApi.MessagingApiClient(clientConfig);
2828
// Create a new Express application.
2929
const app: Application = express();
3030

31+
const isTextEvent = (event: any): event is webhook.MessageEvent & { message: webhook.TextMessageContent } => {
32+
return event.type === 'message' && event.message && event.message.type === 'text';
33+
};
34+
3135
// Function handler to receive the text.
3236
const textEventHandler = async (event: webhook.Event): Promise<MessageAPIResponseBase | undefined> => {
3337
// Process all variables here.
34-
if (event.type !== 'message' || !event.message || event.message.type !== 'text') {
38+
if (!isTextEvent(event)) {
3539
return;
3640
}
3741

0 commit comments

Comments
 (0)