MCPcopy Index your code
hub / github.com/simstudioai/sim / normalizePollOptions

Function normalizePollOptions

apps/sim/tools/telegram/send_poll.ts:15–29  ·  view source on GitHub ↗

* Normalize poll options into a trimmed string array. Accepts an array, a JSON * array string, or a newline-separated string (the `json`-typed param can arrive * in any of these forms from block inputs or agent tool-calls).

(value: unknown)

Source from the content-addressed store, hash-verified

13 * in any of these forms from block inputs or agent tool-calls).
14 */
15function normalizePollOptions(value: unknown): string[] {
16 let items: unknown[] = []
17 if (Array.isArray(value)) {
18 items = value
19 } else if (typeof value === 'string') {
20 const trimmed = value.trim()
21 try {
22 const parsed = JSON.parse(trimmed)
23 items = Array.isArray(parsed) ? parsed : trimmed.split('\n')
24 } catch {
25 items = trimmed.split('\n')
26 }
27 }
28 return items.map((item) => String(item).trim()).filter(Boolean)
29}
30
31export const telegramSendPollTool: ToolConfig<TelegramSendPollParams, TelegramSendMessageResponse> =
32 {

Callers 1

send_poll.tsFile · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected