Skip to content

Receive a Workflow button press

This page is for admins who make Buttons.

A Workflow button sends the data of a Pipedrive record to a URL. In this guide, you make an endpoint on a Node.js server that gets this request. The endpoint reads the data and sends a message back to the user.

You need:

  • Node.js 18 or later and the package express.
  • A public HTTPS URL for your server.
  1. Make a project folder.

  2. In the folder, run npm init -y. npm makes the file package.json.

  3. Run npm pkg set type=module. Node.js then reads import in the .js files.

  4. Run npm install express.

  5. Make the file server.js with this code:

    import express from 'express';
    const app = express();
    app.use(express.json());
    app.post('/oneclick', (req, res) => {
    const userId = req.header('X-oc-user-id');
    const companyId = req.header('X-oc-company-id');
    const { identifier, resource, selectedIds, fields } = req.body;
    console.log({ userId, companyId, identifier, resource, selectedIds, fields });
    res.json({ message: 'The data is received', message_type: 'success' });
    });
    app.listen(3000);
  6. Start the server with node server.js.

  7. Make the server available at your public HTTPS URL.

  1. Make a Workflow button. See Make a Workflow button.
  2. Type the URL of the endpoint in Button URL, for example https://example.com/oneclick.
  3. Turn on Messaging. The user then sees the message of the endpoint.
  4. Click Save.
  5. Press the Button in the Panel of a deal. The server writes the data to the log, and the user sees The data is received.

The body has the ID of the Button in identifier and the record in resource and selectedIds. For all keys, see The data that the Button sends.

Use the headers X-oc-user-id and X-oc-company-id to find the user and the company. OneClick sets these headers on its server. The same values in the body come from the browser of the user, so do not use them for access control.

A person who calls your endpoint directly can also send these headers. Thus, use them only after you check the secret header. See Check the secret header. For all headers, see The headers of the request.

  • With Messaging, send the answer in 10 seconds. After 10 seconds, the user sees Request time out.
  • With Wait for response, send the answer in 30 seconds.
  • Send a status code from 200 to 299 for a success.

OneClick sends each press one time only. It does not send the request again after an error. If the work takes more time, answer at once and send a message later. See Custom messages.

The request has no signature. To make sure that the request comes from your Button, send a secret header and check it. See Check the secret header.