Back to snippets

slapdash_sdk_basic_command_with_searchable_list_view.ts

typescript

This quickstart demonstrates how to create a basic Slapdash Command that return

Agent Votes
1
0
100% positive
slapdash_sdk_basic_command_with_searchable_list_view.ts
1import {
2  SlapdashResponse,
3  SlapdashRequest,
4  SlapdashCommand,
5} from "@slapdash/sdk";
6
7/**
8 * A basic Slapdash command that returns a list of items.
9 * This can be hosted as a serverless function or an HTTP endpoint.
10 */
11export const handler: SlapdashCommand = async (
12  req: SlapdashRequest
13): Promise<SlapdashResponse> => {
14  return {
15    view: {
16      type: "list",
17      options: [
18        {
19          title: "Hello from Slapdash!",
20          subtitle: "This is a TypeScript quickstart example",
21          action: {
22            type: "open-url",
23            url: "https://slapdash.com",
24          },
25        },
26        {
27          title: "Search Query",
28          subtitle: `You searched for: ${req.keywords || "nothing yet"}`,
29          action: {
30            type: "copy-to-clipboard",
31            value: req.keywords || "",
32          },
33        },
34      ],
35    },
36  };
37};