Product Update22 November 20268 min read

Sign Your Customers In to Your Help Desk Automatically

Your customers already sign in to your app. Helpdesk auto-login lets your server vouch for them, so the Decuga help desk opens with no emailed code and no second sign-in.

The second sign-in nobody wants

A customer who is signed in to your product opens the help area and is asked for their email address. They type it, wait for an email, copy a six-digit code and paste it, and only then see the requests they sent yesterday. They proved who they are to your app a minute ago. Asking again is friction, and some of them will skip the help desk instead. The Decuga helpdesk portal has always worked this way, because it is built for anyone, with no account. If your customers are already signed in to your own app, there is a better way: let your app say who they are. That is helpdesk auto-login.

How it works

Your server, not your web page, asks Decuga for a session for one person, using a project API key. Decuga gives back the same session a customer gets by entering a code. Your page hands it to the SDK, and the widget opens with the customer's requests and their company's requests, with no sign-in step and no sign-out button. Nothing new is invented on the Decuga side: it is the portal's own session, so what the customer can do is exactly what they could do after signing in the usual way.

From your app to their requests

The API key never leaves your server. Only the session goes to the browser.

  1. 1Customer

    Already signed in to your app, and opens the help page.

  2. 2Your server

    Checks who they are, then asks Decuga for a session with the API key.

  3. 3Decuga

    Finds or creates the customer, and returns a session.

  4. 4The widget

    Gets the session from your page and shows their requests.

When the session is about to end, the SDK asks your server for a new one

Step one: one call from your server

You add one route to your server. It checks the person is signed in to your app, then calls Decuga with their email, and optionally their name and your own id for their company. The call is a single POST to the customer sessions endpoint of the public API, and any language can make it. It does not send the customer an email, and it can be made on every page load: Decuga finds the same customer each time, or creates one if they are new.

  • ✓email is required; the person is found by it, or made a customer of the project if they are new
  • ✓name is used only for a new customer, so a name your team has edited is never overwritten
  • ✓companyExternalId is your own id for their company, the same one you use in the Companies API
  • ✓The answer is the session: a token, when it expires, and who the person is. Pass all of it to the browser
The call, with curl
curl -X POST https://decuga.com/api/v1/projects/$PROJECT_ID/customer-sessions \
  -H "Authorization: Bearer $DECUGA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"email": "[email protected]", "name": "Meera Rao", "companyExternalId": "globex-1042"}'

Step two: hand the session to the SDK

The browser packages gain one option, session. Give it the session your server returned, or better, a function that fetches one from your server. The SDK calls the function when it needs a session and again when the one it has is about to end, so a page that stays open for hours keeps working. We did not make a new SDK for the server side: it is one HTTP call, and a package that held an API key could only ever be used correctly or dangerously. The existing packages stay browser-only and never see the key.

You useWhere the session option goes
Web components or any frameworknew DecugaClient({ projectId, session }), then assign it to the element's client
ReactThe session prop of DecugaProvider
VueThe session option of createDecuga
Your own screensThe same client, with the headless hooks and composables

What the customer sees

They see the help centre as if they had signed in with a code, minus the parts that no longer make sense. There is no email field to fill in to see their requests and no code. There is no Sign out button, because your app decides who is signed in. They see the forms kept for signed-in customers, the requests they have sent, and, when they belong to a company, a second list with that company's requests. They can open a request, read the replies, reply, and attach files up to the limits of the portal. If your server cannot give a session, the widget says they could not be signed in and does not fall back to an emailed code that you chose not to use.

Companies, with your own id

Most of the value for a business customer is seeing the company's requests, not only their own. You decide the company with companyExternalId, the externalId you give companies in the Companies API, so you use your own id everywhere and never need Decuga's. When it is given it decides the company, even if the customer's email domain matches another, and a customer who was in another company is moved to it. If no company has that id, the call fails with a 404 and nobody is created, so a wrong id cannot create a stray customer.

What Decuga trusts, and what you must do

Auto-login moves trust from an emailed code to your server. Decuga signs in whoever your server names, with no further check, so the call must only be made for people your app has already signed in. Three rules keep it safe.

  • ✓Treat the session token as a secret of one person: give it to their browser only, and never log it or put it in a URL
  • ✓Ask for a session only after you have signed the person in yourself
  • ✓If a key may have leaked, delete it under Integrations, API Keys and make a new one

Keep the key on your server

The project API key acts as the person who created it, who must be able to manage the service desk. It must never be in a web page, a mobile app or a repository others can read. The call does not allow cross-origin requests, so a browser cannot make it.

What it does not do yet

It is on the Business plan and above, because project API keys are. A session lasts 30 days, the same as one made with an emailed code, and cannot be ended early, so a key that leaked can be stopped from making new sessions but not from the ones already given. A fixed session object cannot be renewed, so use a function if pages stay open for long. And the SDKs are in beta and not yet on npm. The guide has the exact request and response, the errors, and examples for a Node server, the web components, React and Vue.

Ready to try Decuga?

Start free - no account or credit card required. One week free trial of the Business plan.

Start free trial