-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathpoll-create.ts
More file actions
42 lines (33 loc) · 1.24 KB
/
poll-create.ts
File metadata and controls
42 lines (33 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { createSDK, handleError } from "./utils";
const CHAT_GUID = process.env.CHAT_GUID || "any;-;+1234567890";
async function main() {
const sdk = createSDK();
sdk.on("ready", async () => {
console.log("Poll creation example...\n");
try {
console.log("Creating a poll...");
const pollMessage = await sdk.polls.create({
chatGuid: CHAT_GUID,
title: "",
options: [
"Option A - First choice",
"Option B - Second choice",
"Option C - Third choice",
"Option D - Fourth choice",
],
});
console.log("\n✓ Poll created successfully!");
console.log(`Poll message GUID: ${pollMessage.guid}`);
console.log(`Balloon Bundle ID: ${pollMessage.balloonBundleId}`);
if (pollMessage.payloadData) {
console.log(`\nPayload Data: ${JSON.stringify(pollMessage.payloadData, null, 2)}`);
}
} catch (error) {
handleError(error, "Failed to create poll");
}
await sdk.close();
process.exit(0);
});
await sdk.connect();
}
main().catch(console.error);