picked 0.0.115 → 0.0.116-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -122,6 +122,10 @@ Each organization that installs a public app gets its own installation, with its
122
122
  and its own data. The author of the app does not get access to a project until a person on
123
123
  that project installs the app.
124
124
 
125
+ Picked makes its own apps on the same platform. Examples are the
126
+ [Vercel app](/reference/apps/vercel), the [Zoho CRM app](/reference/apps/zoho-crm), and the
127
+ [Google apps](/reference/apps/google).
128
+
125
129
  ## Apps, external APIs and MCP connections
126
130
 
127
131
  A project can also connect to other services without an app.
@@ -55,9 +55,10 @@ Serve the page with `page` from `@picked/app-kit/server`. `page` sets the
55
55
  `content-security-policy` header to `frame-ancestors` with the origins that you give.
56
56
  Therefore, only the dashboard can show the page in an `iframe`.
57
57
 
58
- Give `page` the `frameAncestors` that `readAppEnvironment` returns. It reads them from
59
- `PICKED_DASHBOARD_ORIGINS`. With no origins, `page` sends `frame-ancestors 'none'`, and the
60
- dashboard cannot show the page.
58
+ Give `page` the origins that `dashboardOrigins()` from `readAppEnvironment` gives. They are
59
+ `PICKED_DASHBOARD_ORIGINS`, or, when it is not set, the origins in the
60
+ [app config of Picked](/reference/apps/environment#app-config-of-picked). With no origins,
61
+ `page` sends `frame-ancestors 'none'`, and the dashboard cannot show the page.
61
62
 
62
63
  ```ts [src/server.ts]
63
64
  import { readFile } from 'node:fs/promises'
@@ -65,7 +66,7 @@ import { createAppHandler, json, page, readAppEnvironment } from '@picked/app-ki
65
66
  import { frameScript, serve } from '@picked/app-kit/node'
66
67
 
67
68
  const port = process.env.APP_PORT ?? '4103'
68
- const { pickedKeys, frameAncestors } = readAppEnvironment(process.env, port)
69
+ const { pickedKeys, dashboardOrigins } = readAppEnvironment(process.env, port)
69
70
 
70
71
  const handler = createAppHandler({
71
72
  pickedKeys,
@@ -73,7 +74,7 @@ const handler = createAppHandler({
73
74
  const { pathname } = new URL(request.url)
74
75
  if (pathname === '/') {
75
76
  const html = await readFile(new URL('./home.html', import.meta.url), 'utf8')
76
- return page(html, { frameAncestors })
77
+ return page(html, { frameAncestors: await dashboardOrigins() })
77
78
  }
78
79
  if (pathname === '/app-kit/frame.js') return frameScript()
79
80
  return json({ error: 'not_found' }, 404)
@@ -197,8 +198,9 @@ no token, or when the token is not from Picked or is expired. Otherwise it retur
197
198
  fields of the token, for example `userId`, `installationId` and `projectId`.
198
199
  [Session tokens](/reference/apps/protocol#session-tokens) gives each field.
199
200
 
200
- A session token expires after 10 minutes. To get a new token, call `connect()` again. The
201
- dashboard sends a new token each time.
201
+ A session token expires after 10 minutes. On a page that stays open, use
202
+ [`keepConnected`](/reference/apps/app-kit#keepconnected): it gets a new token before the
203
+ old token expires.
202
204
 
203
205
  Do not use the IDs in the URL or in the body of a request from the page. Use the IDs in
204
206
  the session.
@@ -240,7 +242,7 @@ If the dashboard cannot show the page, it shows one of these messages:
240
242
  | `This app's page can't be shown: its address is not a valid URL.` | The `url` of the slot is not a valid URL. |
241
243
 
242
244
  If the `iframe` stays empty, look at the console of the browser. A `frame-ancestors` error
243
- tells you that `PICKED_DASHBOARD_ORIGINS` does not have the origin of the dashboard.
245
+ tells you that the dashboard origins of the app do not have the origin of the dashboard.
244
246
 
245
247
  ## Related
246
248
 
@@ -0,0 +1,100 @@
1
+ ---
2
+ type: how-to
3
+ layout: docs
4
+ ---
5
+
6
+ # How to connect Google Ads, Google Analytics or Google Tag Manager
7
+
8
+ This guide shows you how to connect a Picked project to a Google account. Three apps can make
9
+ this connection: Google Ads, Google Analytics and Google Tag Manager. The steps are the same
10
+ for the three apps. Only the setting in step 4 is different.
11
+
12
+ :::info
13
+ At this time, these apps only keep the connection and test it. They do not read data from
14
+ Google into Picked.
15
+ :::
16
+
17
+ These apps are not the Picked GTM template. To send ecommerce events from Google Tag Manager
18
+ to Picked, see [How to install the GTM template](/how-to/install-the-gtm-template).
19
+
20
+ Before you start, you need:
21
+
22
+ - A Picked project, and permission to install apps on it.
23
+ - A Google account that can open the Google Ads account, the Google Analytics property or
24
+ the Tag Manager container.
25
+ - The ID that the app asks for in step 4.
26
+
27
+ ## 1. Install the app
28
+
29
+ Install the app with the name **Google Ads**, **Google Analytics** or **Google Tag Manager**
30
+ on your project. The app asks for no access to the data of your project. See
31
+ [How to install an app](/how-to/apps/install-an-app).
32
+
33
+ ## 2. Open the app
34
+
35
+ 1. In the project, open **Apps**.
36
+ 2. Under **Installed**, click **Open** on the app.
37
+
38
+ The dashboard shows the page of the app. The page has the name of the app as its title.
39
+
40
+ ## 3. Connect the Google account
41
+
42
+ 1. Click the **Connect** button of the app, for example **Connect Google Ads**.
43
+ 2. In the new window, sign in to Google.
44
+ 3. Accept all of the access that the app asks for.
45
+
46
+ The new window closes. The status line shows `Connected <email>`. The page shows
47
+ `Connected as <email>`.
48
+
49
+ If the new window stays open, close it. The status line shows
50
+ `The connection window closed. If you finished connecting there, it shows here`, and the
51
+ page shows the connection.
52
+
53
+ If your browser stops the new window, the page shows `Allow pop-ups to connect`. Let the
54
+ dashboard open new windows. Then click the button again. For other messages, see
55
+ [Google apps](/reference/apps/google#sign-in-messages).
56
+
57
+ ## 4. Save the setting
58
+
59
+ The setting fields show after you connect. Enter the setting of your app:
60
+
61
+ - **Google Ads**: In **Customer ID**, enter the ID of the Google Ads account, for example
62
+ `123-456-7890`. If the Google account gets to this account through a manager account,
63
+ enter the ID of the manager account in **Manager account ID**.
64
+ - **Google Analytics**: In **Property ID**, enter the ID of the Google Analytics 4 property,
65
+ for example `250000001`. The property settings in Google Analytics show this ID.
66
+ - **Google Tag Manager**: In **Container ID**, enter the ID of the web container, for
67
+ example `GTM-XXXXXXX`.
68
+
69
+ Click **Save settings**. The page shows `Settings saved`.
70
+
71
+ If the value is not correct, the page shows the problem. See
72
+ [Google apps](/reference/apps/google#settings-messages).
73
+
74
+ ## 5. Test the connection
75
+
76
+ Click **Test connection**.
77
+
78
+ The status line shows `Connected to <name> (<ID>)`. Under the message, the page shows each
79
+ account, property or container that the Google account can open.
80
+
81
+ If the page shows a different message, see [Google apps](/reference/apps/google#test-messages).
82
+
83
+ ## Remove the connection
84
+
85
+ Click `Disconnect` on the app page.
86
+
87
+ The app tells Google to revoke its access. The status line shows `Disconnected`, and the
88
+ page shows the **Connect** button again. The saved setting stays. To connect again, follow
89
+ step 3.
90
+
91
+ When you remove the app from the project, the app also tells Google to revoke its access. See
92
+ [How to upgrade or uninstall an app](/how-to/apps/upgrade-or-uninstall-an-app).
93
+
94
+ ## Related
95
+
96
+ - [Google apps](/reference/apps/google): the Google scopes, the settings, the tool and the
97
+ messages of the three apps.
98
+ - [How to use an app tool in a workflow](/how-to/apps/use-an-app-tool-in-a-workflow): add the
99
+ `check_connection` tool of the app to a workflow.
100
+ - [About apps](/explanation/apps).
@@ -53,7 +53,7 @@ to [How to store data for an installation](/how-to/apps/store-data-for-an-instal
53
53
  ## 2. Add a button that opens the authorization window
54
54
 
55
55
  On the page, call `authorizeInPopup` from a `click` handler. Give it the session token from
56
- `connect`. To send a value to your server, such as a region that the person chose, give it
56
+ `keepConnected`. To send a value to your server, such as a region that the person chose, give it
57
57
  as `params`.
58
58
 
59
59
  ```html [src/home.html]
@@ -70,18 +70,17 @@ as `params`.
70
70
  <button id="connect" type="button">Connect CRM</button>
71
71
  <p id="status"></p>
72
72
  <script type="module">
73
- import { authorizeInPopup, autoResize, connect } from '/app-kit/frame.js'
73
+ import { authorizeInPopup, autoResize, keepConnected } from '/app-kit/frame.js'
74
74
 
75
- let context = await connect()
75
+ const connection = await keepConnected()
76
76
  autoResize()
77
77
 
78
78
  document.getElementById('connect').addEventListener('click', async () => {
79
79
  const result = await authorizeInPopup({
80
- sessionToken: context.sessionToken,
80
+ sessionToken: connection.context().sessionToken,
81
81
  params: { region: document.getElementById('region').value },
82
82
  })
83
83
  document.getElementById('status').textContent = result.message
84
- context = await connect()
85
84
  })
86
85
  </script>
87
86
  </body>
@@ -95,16 +94,22 @@ The session token does not go in an address.
95
94
  Do not put an `await` before `authorizeInPopup` in the handler. The browser can stop a new
96
95
  window that does not come directly from a click.
97
96
 
98
- A session token expires 10 minutes after Picked makes it. With an expired session token, the
99
- result is `Sign in again`. After each result, the handler calls `connect()` again. The
100
- dashboard then sends a new session token for the next click.
97
+ With an expired session token, the result is `Sign in again`.
98
+ [`keepConnected`](/reference/apps/app-kit#keepconnected) gets a new session
99
+ token before the token expires. The handler reads `connection.context()` when the person
100
+ clicks. The handler then has a session token that is not expired, and it does not wait for
101
+ the token.
101
102
 
102
- `connect()` works only in the `iframe` of the dashboard, so the page must open in Picked.
103
+ `keepConnected()` works only in the `iframe` of the dashboard, so the page must open in Picked.
103
104
 
104
105
  Some services separate the new window from your page. The window then stays open and
105
- shows the result. `authorizeInPopup` returns when the person comes back to your page. Read
106
- the connection from your server again after `authorizeInPopup` returns, and show it. The
107
- results of `authorizeInPopup` are in
106
+ shows the result. `authorizeInPopup` returns when the person comes back to your page.
107
+
108
+ Give
109
+ `authorizeInPopup` a `connected` function that reads the connection from your server. It
110
+ returns a message when the connection exists, or `null`. Then `authorizeInPopup` waits up to
111
+ 30 seconds for the connection that the window saves. Read the connection from your server
112
+ again after `authorizeInPopup` returns, and show it. The results of `authorizeInPopup` are in
108
113
  [`authorizeInPopup`](/reference/apps/app-kit#authorizeinpopup).
109
114
 
110
115
  ## 3. Return the authorization URL
@@ -305,3 +310,5 @@ set the label again.
305
310
  why the state carries the session token, and why a cookie binds the flow to one browser.
306
311
  - [How to store data for an installation](/how-to/apps/store-data-for-an-installation) —
307
312
  secret labels.
313
+ - [How to send leads to Zoho CRM](/how-to/apps/connect-zoho-crm) — an app that keeps the
314
+ OAuth client of each customer in labels of the installation.
@@ -0,0 +1,101 @@
1
+ ---
2
+ type: how-to
3
+ layout: docs
4
+ ---
5
+
6
+ # How to deploy to Vercel when you publish
7
+
8
+ This guide shows you how to connect a Picked project to your Vercel account. After you
9
+ connect, Picked deploys the Vercel projects that you choose each time the project publishes
10
+ a workspace.
11
+
12
+ Before you start, you need:
13
+
14
+ - A Picked project, and permission to install apps on it.
15
+ - A Vercel account or a Vercel team that holds the sites to deploy.
16
+
17
+ ## 1. Install the Vercel app
18
+
19
+ Install the app with the name **Vercel** on your project. The app asks for no access to the
20
+ data of your project. See [How to install an app](/how-to/apps/install-an-app).
21
+
22
+ ## 2. Open the app
23
+
24
+ On the apps page of the project, under **Installed**, click **Open** next to **Vercel**.
25
+
26
+ The dashboard shows the page of the app.
27
+
28
+ ## 3. Connect Vercel
29
+
30
+ 1. Click **Connect Vercel**.
31
+ 2. In the new window, sign in to Vercel if Vercel asks you.
32
+ 3. Choose the Vercel team or the personal account that holds your sites.
33
+ 4. Approve the Picked Vercel Integration.
34
+
35
+ The new window closes. The status line shows `Connected to Vercel`. The page shows
36
+ `Connected to Vercel team <team ID>`, or `Connected to Vercel personal account`, then the
37
+ integration configuration, for example `(configuration icfg_…)`.
38
+
39
+ If the new window stays open, close it. The status line shows
40
+ `The connection window closed. If you finished connecting there, it shows here`, and the
41
+ page shows the connection.
42
+
43
+ If the page shows
44
+ `Picked’s Vercel Integration is not configured on this deployment, so it cannot connect.`,
45
+ you cannot connect from this Picked environment.
46
+
47
+ ## 4. Choose the projects to deploy
48
+
49
+ 1. Under **Projects to deploy**, choose each Vercel project that Picked must deploy.
50
+ 2. Click **Save projects**.
51
+
52
+ The page shows `Saved the projects to deploy`. Under **Deploy now**, the page shows a
53
+ **Deploy &lt;project&gt;** button for each project that you chose.
54
+
55
+ Each time that a workspace in this project publishes, Picked deploys each project that you
56
+ chose one time. See
57
+ [Vercel app](/reference/apps/vercel#deployments) for what a deployment does.
58
+
59
+ ## 5. Deploy at a different time
60
+
61
+ To deploy a project from the app page:
62
+
63
+ 1. Under **Deploy now**, click **Deploy &lt;project&gt;**.
64
+ 2. Read the status line. It shows `<project>: deploying`, or the reason for a failure.
65
+
66
+ To deploy from the publish modal, publish a workspace. When the workspace is published, click
67
+ **Deploy &lt;project&gt;** in the `Deploy to Vercel` card of the modal. See
68
+ [How to publish a workspace](/how-to/publish-a-workspace).
69
+
70
+ To deploy from a workflow, add the `Vercel: Trigger Vercel deploy` tool to the workflow. See
71
+ [How to use an app tool in a workflow](/how-to/apps/use-an-app-tool-in-a-workflow).
72
+
73
+ ## 6. Check the deployments
74
+
75
+ The `Recent deploys` table on the app page shows the last deployments. The `Started by`
76
+ column shows `manual`, `publish` or `workflow`. The `Result` column shows `Deploying`, or
77
+ `Failed:` and the reason.
78
+
79
+ ## 7. Open Picked from Vercel
80
+
81
+ 1. In the Vercel dashboard, open **Integrations**.
82
+ 2. Open the configuration of the Picked integration.
83
+
84
+ Vercel sends you to the Vercel app page of the Picked project that holds this configuration.
85
+ If more than one project holds it, the dashboard asks you to choose the project.
86
+
87
+ ## 8. Remove the connection
88
+
89
+ 1. On the app page, click `Disconnect`.
90
+ 2. In the Vercel dashboard, open **Integrations**.
91
+ 3. Remove the Picked integration from the account or the team.
92
+
93
+ Step 1 removes the Vercel token, the team, the configuration and the chosen projects from
94
+ Picked. The integration stays on your Vercel account until you do steps 2 and 3.
95
+
96
+ ## Related
97
+
98
+ - [Vercel app](/reference/apps/vercel): the slots, the tool, the event, the limits and the
99
+ messages of the app.
100
+ - [How to upgrade or uninstall an app](/how-to/apps/upgrade-or-uninstall-an-app).
101
+ - [About apps](/explanation/apps).
@@ -0,0 +1,105 @@
1
+ ---
2
+ type: how-to
3
+ layout: docs
4
+ ---
5
+
6
+ # How to send leads to Zoho CRM
7
+
8
+ This guide shows you how to connect a Picked project to your Zoho CRM account. After you
9
+ connect, the workflows of the project can make leads in Zoho CRM.
10
+
11
+ The app uses an OAuth client that you make in Zoho. Picked does not give the client.
12
+
13
+ Before you start, you need:
14
+
15
+ - A Picked project, and permission to install apps on it.
16
+ - A Zoho CRM account, and permission to add a client in the Zoho API Console.
17
+ - The data center of your Zoho CRM account. See
18
+ [Data centers](/reference/apps/zoho-crm#data-centers).
19
+
20
+ ## 1. Install the Zoho CRM app
21
+
22
+ Install the app with the name **Zoho CRM** on your project. The app asks for no access to the
23
+ data of your project. See [How to install an app](/how-to/apps/install-an-app).
24
+
25
+ ## 2. Open the app
26
+
27
+ On the apps page of the project, under **Installed**, click **Open** next to **Zoho CRM**.
28
+
29
+ The dashboard shows the page of the app.
30
+
31
+ ## 3. Find the address for Zoho
32
+
33
+ On the app page, find the URL after `Redirect URI:`. It ends with `/oauth/callback`. Zoho
34
+ sends you back to this URL after you connect.
35
+
36
+ ## 4. Make an OAuth client in Zoho
37
+
38
+ 1. Open the Zoho API Console of your data center, for example `api-console.zoho.com`,
39
+ `api-console.zoho.eu` or `api-console.zoho.com.au`.
40
+ 2. Add a `Server-based Application`.
41
+ 3. Set the URL from step 3 as the authorized redirect address of the client.
42
+ 4. Record the client ID and the client secret that Zoho gives.
43
+
44
+ ## 5. Save the client in Picked
45
+
46
+ 1. On the app page, enter the client ID in **Client ID**.
47
+ 2. Enter the client secret in **Client secret**.
48
+ 3. Click **Save client**.
49
+
50
+ The page shows `Saved your Zoho OAuth client`, and
51
+ `Client ID <client ID>, client secret set`. The page does not show the secret again.
52
+
53
+ ## 6. Connect Zoho CRM
54
+
55
+ 1. In `Zoho data centre`, choose the data center of your Zoho account.
56
+ 2. Click **Connect Zoho CRM**.
57
+ 3. In the new window, sign in to Zoho if Zoho asks you.
58
+ 4. Accept the access that the app asks for.
59
+
60
+ The new window closes. The status line shows `Connected to <organization>`. The page shows
61
+ `Connected to <organization> through <accounts server>`.
62
+
63
+ If the new window stays open, close it. The status line shows
64
+ `The connection window closed. If you finished connecting there, it shows here`, and the
65
+ page shows the connection.
66
+
67
+ ## 7. Test the connection
68
+
69
+ Click **Test connection**.
70
+
71
+ The status line shows `Connected to <organization>`. If it shows a different message, see
72
+ [Zoho CRM app](/reference/apps/zoho-crm#messages).
73
+
74
+ ## 8. Add the tool to a workflow
75
+
76
+ Add the `Zoho CRM: Create Zoho lead` tool to a workflow. Set **Last name**. You can also set
77
+ **First name**, **Email** and **Company**. See
78
+ [How to use an app tool in a workflow](/how-to/apps/use-an-app-tool-in-a-workflow).
79
+
80
+ A test run of the workflow does not make a lead. The tool returns `test-run` as the Zoho lead
81
+ ID.
82
+
83
+ ## Replace the OAuth client
84
+
85
+ 1. On the app page, click **Replace client**.
86
+ 2. Enter the new client ID and client secret.
87
+ 3. Click **Save client**.
88
+ 4. Connect again, as in step 6.
89
+
90
+ The new client removes the connection. See
91
+ [New client](/reference/apps/zoho-crm#new-client).
92
+
93
+ ## Remove the connection
94
+
95
+ Click `Disconnect` on the app page.
96
+
97
+ The client stays in Picked. To connect again, go to step 6. See
98
+ [Removal of the connection](/reference/apps/zoho-crm#removal-of-the-connection).
99
+
100
+ ## Related
101
+
102
+ - [Zoho CRM app](/reference/apps/zoho-crm): the tools, the data centers, the Zoho scopes and
103
+ the messages of the app.
104
+ - [How to upgrade or uninstall an app](/how-to/apps/upgrade-or-uninstall-an-app).
105
+ - [About apps](/explanation/apps).
@@ -110,11 +110,14 @@ Make `vercel.json`:
110
110
  "framework": null,
111
111
  "buildCommand": "npm run build",
112
112
  "outputDirectory": "public",
113
- "rewrites": [{ "source": "/:path*", "destination": "/api?__path=/:path*" }]
113
+ "rewrites": [
114
+ { "source": "/", "destination": "/api?__path=/" },
115
+ { "source": "/:path*", "destination": "/api?__path=/:path*" }
116
+ ]
114
117
  }
115
118
  ```
116
119
 
117
- The rewrite sends each path to the function, with the path in `__path`.
120
+ The rewrites send each path to the function, with the path in `__path`. The `/:path*` rule does not match `/`, so the first rule sends `/`.
118
121
  `withRewrittenPath` puts the path back in the URL of the request. So the handler gets
119
122
  `/lifecycle`, `/tools/<name>` and the other paths of the
120
123
  [App protocol](/reference/apps/protocol).
@@ -43,19 +43,39 @@ Get the ID for each environment that you deploy to, in one of these ways:
43
43
  - **From the dashboard.** In the organization, open **Apps**, then open the app. **App ID**
44
44
  shows the ID. Click **Copy the app ID** to copy it.
45
45
 
46
- Keep the ID in the configuration of your server for that environment. In this guide, it is
47
- the environment variable `PICKED_APP_ID`, which your server reads.
46
+ Set the ID as `PICKED_APP_ID` in the environment of your server for that Picked environment.
47
+ [`readAppEnvironment`](/reference/apps/app-kit#readappenvironment) returns it as `appId`.
48
48
 
49
- ## 3. Build the link
49
+ ## 3. Get the dashboard origin
50
50
 
51
- Call `installationLinkUrl` with the origin of the dashboard, the app ID, and the label:
51
+ `dashboardOrigins()` from `readAppEnvironment` gives the dashboard origins. The first origin is
52
+ the main dashboard of the Picked environment. Without `PICKED_DASHBOARD_ORIGINS`, the origins
53
+ come from the [app config of Picked](/reference/apps/environment#app-config-of-picked).
54
+
55
+ When you set `PICKED_DASHBOARD_ORIGINS`, write the main dashboard first, for example:
56
+
57
+ ```text
58
+ PICKED_DASHBOARD_ORIGINS=https://dashboard.picked.app,https://*.picked.app,https://dashboard.convincely.com
59
+ ```
60
+
61
+ Refer to [App environment variables](/reference/apps/environment) for the value in each
62
+ Picked environment.
63
+
64
+ ## 4. Build the link
65
+
66
+ Call `installationLinkUrl` with the dashboard origin, the app ID, and the label:
52
67
 
53
68
  ```ts
54
- import { installationLinkUrl } from '@picked/app-kit/server'
69
+ import { installationLinkUrl, readAppEnvironment } from '@picked/app-kit/server'
70
+
71
+ const { dashboardOrigins, appId } = readAppEnvironment(process.env, process.env.APP_PORT ?? '4103')
72
+ const [dashboardOrigin] = await dashboardOrigins()
73
+ if (dashboardOrigin === undefined || appId === null)
74
+ throw new Error('Set PICKED_APP_ID, and let the app read the dashboard origins')
55
75
 
56
76
  const url = installationLinkUrl({
57
- dashboardOrigin: 'https://dashboard.picked.app',
58
- appId: process.env.PICKED_APP_ID ?? '',
77
+ dashboardOrigin,
78
+ appId,
59
79
  namespace: 'crm',
60
80
  key: 'account_id',
61
81
  value: 'acct_4821',
@@ -76,32 +96,47 @@ The link has this shape:
76
96
  - The app ID, the namespace or the key has a format that Picked does not accept.
77
97
  - `dashboardOrigin` is not a URL.
78
98
 
79
- ## 4. Send the person to the link
99
+ ## 5. Send the person to the link
80
100
 
81
101
  Put the link on your site, or redirect to it. For example, the Vercel app answers the
82
102
  Configuration URL of its Vercel integration. Vercel opens that URL with a
83
103
  `configurationId`. The app redirects to the installation that holds that ID in its
84
- `vercel.configuration_id` label. This code is a short form of it:
104
+ `vercel.configuration_id` label. When it cannot make the link, it shows a page with a link to
105
+ the dashboard. This code is a short form of it:
85
106
 
86
107
  ```ts [src/server.ts]
87
- import { installationLinkUrl, json } from '@picked/app-kit/server'
108
+ import { installationLinkUrl, page, readAppEnvironment } from '@picked/app-kit/server'
109
+
110
+ const { dashboardOrigins, appId } = readAppEnvironment(process.env, process.env.APP_PORT ?? '4103')
88
111
 
89
112
  async function configure(request: Request): Promise<Response> {
90
113
  const configurationId = new URL(request.url).searchParams.get('configurationId') ?? ''
91
- if (!/^icfg_\w{1,64}$/.test(configurationId)) return json({ error: 'not_found' }, 404)
92
-
93
- const location = installationLinkUrl({
94
- dashboardOrigin: 'https://dashboard.picked.app',
95
- appId: process.env.PICKED_APP_ID ?? '',
96
- namespace: 'vercel',
97
- key: 'configuration_id',
98
- value: configurationId,
99
- })
100
- return new Response(null, { status: 302, headers: { location, 'cache-control': 'no-store' } })
114
+ const [dashboardOrigin] = await dashboardOrigins()
115
+ if (/^icfg_\w{1,64}$/.test(configurationId) && dashboardOrigin !== undefined && appId !== null) {
116
+ const location = installationLinkUrl({
117
+ dashboardOrigin,
118
+ appId,
119
+ namespace: 'vercel',
120
+ key: 'configuration_id',
121
+ value: configurationId,
122
+ })
123
+ return new Response(null, { status: 302, headers: { location, 'cache-control': 'no-store' } })
124
+ }
125
+
126
+ const home =
127
+ dashboardOrigin === undefined
128
+ ? ''
129
+ : `<a href="${new URL('/', dashboardOrigin).href}">Open Picked</a>`
130
+ return page(
131
+ `<!doctype html><title>Picked</title><p>Open the app on your project in Picked. ${home}</p>`,
132
+ {
133
+ frameAncestors: [],
134
+ },
135
+ )
101
136
  }
102
137
  ```
103
138
 
104
- ## 5. Know what the person sees
139
+ ## 6. Know what the person sees
105
140
 
106
141
  The dashboard looks for the installations of the app that hold the label with that value.
107
142
  It keeps only the installations in projects where the person has `organization_apps/read`.
@@ -132,3 +167,4 @@ The person sees no match in these conditions:
132
167
  write the label.
133
168
  - [How to deploy an app](/how-to/apps/deploy-an-app) — get the app ID from
134
169
  `picked app deploy`.
170
+ - [Vercel app](/reference/apps/vercel) — the Configuration URL of the Vercel app.
@@ -148,9 +148,10 @@ const response = await fetch('/api/leads', {
148
148
  })
149
149
  ```
150
150
 
151
- A session token expires 10 minutes after Picked makes it. To get a new one, call `connect()`
152
- again. [How to add a page to the dashboard](/how-to/apps/add-a-page-to-the-dashboard) shows
153
- the full page.
151
+ A session token expires 10 minutes after Picked makes it. On a page that stays open, use
152
+ [`keepConnected`](/reference/apps/app-kit#keepconnected), which gets a new token before the
153
+ old token expires. [How to add a page to the dashboard](/how-to/apps/add-a-page-to-the-dashboard)
154
+ shows the full page.
154
155
 
155
156
  ## 5. Call the API outside a request
156
157
 
@@ -145,4 +145,6 @@ modal after Picked publishes the workspace. The Vercel app of Picked shows a
145
145
  - [App manifest](/reference/apps/manifest#events) — the `events` field.
146
146
  - [How to store data for an installation](/how-to/apps/store-data-for-an-installation) —
147
147
  labels of an installation.
148
+ - [Vercel app](/reference/apps/vercel) — an app that deploys to Vercel when a workspace
149
+ publishes.
148
150
  - [How to publish a workspace](/how-to/publish-a-workspace) — what Picked does when it publishes a workspace.
@@ -10,6 +10,13 @@ how to use the output of the tool in a later node. Before you start, an app with
10
10
  tools must be installed on the project. Refer to
11
11
  [How to install an app](/how-to/apps/install-an-app).
12
12
 
13
+ The examples use the **Create Zoho lead** tool of the
14
+ [Zoho CRM app](/reference/apps/zoho-crm). For the tools of the apps from Picked, refer to:
15
+
16
+ - [Vercel app](/reference/apps/vercel)
17
+ - [Zoho CRM app](/reference/apps/zoho-crm)
18
+ - [Google apps](/reference/apps/google)
19
+
13
20
  ## 1. Find the name of the tool
14
21
 
15
22
  1. In the project switcher, choose **Apps**.
@@ -68,15 +68,15 @@ the trigger that matches. Then set the options below.
68
68
 
69
69
  ## Options
70
70
 
71
- | Option | Description |
72
- | --- | --- |
73
- | **Project ID** | The ID of your Picked project. Find it in the [Picked Dashboard](https://dashboard.picked.app). |
74
- | **Event** | The ecommerce event to track, for example `add_to_cart` or `purchase`. |
75
- | **Send ecommerce data** | Turn this on to send the data from GA4 Enhanced Ecommerce to Picked. Turn it on for every ecommerce event. |
76
- | **GA4 Enhanced Ecommerce Data** | The GTM variable that holds the data from GA4 Enhanced Ecommerce. Use the data layer variable from step 2. |
77
- | **Additional data** | An optional GTM variable, for more metadata with the event. |
78
- | **User ID** | An optional GTM variable that holds your own ID for the visitor, for example a customer ID. Picked uses it to find the same visitor on different devices and on your different sites. Picked sends it only with the event of this tag. |
79
- | **Hash the user ID** | On by default. Picked sends `sha256:` and a SHA-256 hash of the project ID and the user ID, and not the user ID. Use the same setting on each site. |
71
+ | Option | Description |
72
+ | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
73
+ | **Project ID** | The ID of your Picked project. Find it in the [Picked Dashboard](https://dashboard.picked.app). |
74
+ | **Event** | The ecommerce event to track, for example `add_to_cart` or `purchase`. |
75
+ | **Send ecommerce data** | Turn this on to send the data from GA4 Enhanced Ecommerce to Picked. Turn it on for every ecommerce event. |
76
+ | **GA4 Enhanced Ecommerce Data** | The GTM variable that holds the data from GA4 Enhanced Ecommerce. Use the data layer variable from step 2. |
77
+ | **Additional data** | An optional GTM variable, for more metadata with the event. |
78
+ | **User ID** | An optional GTM variable that holds your own ID for the visitor, for example a customer ID. Picked uses it to find the same visitor on different devices and on your different sites. Picked sends it only with the event of this tag. |
79
+ | **Hash the user ID** | On by default. Picked sends `sha256:` and a SHA-256 hash of the project ID and the user ID, and not the user ID. Use the same setting on each site. |
80
80
 
81
81
  ![The options on a Picked Ecommerce tag](/gtm/gtm-tag.png)
82
82