|
| 1 | +# Share links demo |
| 2 | + |
| 3 | +It is often useful for an agent to share a link with a customer to start a Cobrowse session. |
| 4 | + |
| 5 | +This demo shows two ways to do that using the Cobrowse Agent SDK. |
| 6 | + |
| 7 | +Use session links when you wish to start a Cobrowse session immediately. The agent shares a link to their current session with the customer. The customer clicks on the link and joins the Cobrowse session immediately. These links automatically expire after 15 minutes. |
| 8 | + |
| 9 | +When the agent wants to schedule a Cobrowse session later, they should share a device link instead. Device links tag the customer so the agent can use the smart connect feature to connect when the customer comes online. |
| 10 | + |
| 11 | +This example uses the Cobrowse Agent SDK, Vite, React and Typescript. |
| 12 | + |
| 13 | +## Running the demo |
| 14 | + |
| 15 | +```sh |
| 16 | +npm install |
| 17 | +npm run dev |
| 18 | +``` |
| 19 | + |
| 20 | +## Sharing a link to a session |
| 21 | + |
| 22 | +The agent starts a session and then shares a link with the |
| 23 | +customer so they can join the session. |
| 24 | + |
| 25 | +On the customer side, the web page should check for the session id |
| 26 | +and use that to get the session: |
| 27 | + |
| 28 | +```js |
| 29 | +if (CobrowseIO.currentSession == null) { |
| 30 | + const searchParams = new URLSearchParams(window.location.search) |
| 31 | + const session = searchParams.get('session_id') |
| 32 | + if (session) { |
| 33 | + CobrowseIO.getSession(session); |
| 34 | + } |
| 35 | +} |
| 36 | +``` |
| 37 | + |
| 38 | +Sessions automatically expire after 15 minutes if the customer |
| 39 | +does not join. |
| 40 | + |
| 41 | +## Scheduling a Cobrowse session later |
| 42 | + |
| 43 | +The agent shares a link with the customer that will uniquely |
| 44 | +identify the customer. The agent can use the Smart Connect button |
| 45 | +to start a session when the customer comes online. |
| 46 | + |
| 47 | +On the customer side, the web page should check for the meeting id |
| 48 | +and tag the device so the agent can identify the customer. |
| 49 | + |
| 50 | +```js |
| 51 | +if (CobrowseIO.currentSession == null) { |
| 52 | + const searchParams = new URLSearchParams(window.location.search) |
| 53 | + const meeting_id = searchParams('meeting_id') |
| 54 | + if (meeting_id) CobrowseIO.customData['meeting_id'] = meeting_id |
| 55 | +} |
| 56 | +``` |
| 57 | + |
| 58 | +Your Cobrowse.io account must have device registration enabled to work. |
0 commit comments