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.
Make the endpoint
Section titled “Make the endpoint”-
Make a project folder.
-
In the folder, run
npm init -y. npm makes the filepackage.json. -
Run
npm pkg set type=module. Node.js then readsimportin the.jsfiles. -
Run
npm install express. -
Make the file
server.jswith 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); -
Start the server with
node server.js. -
Make the server available at your public HTTPS URL.
Connect the Button
Section titled “Connect the Button”- Make a Workflow button. See Make a Workflow button.
- Type the URL of the endpoint in Button URL, for example
https://example.com/oneclick. - Turn on Messaging. The user then sees the message of the endpoint.
- Click Save.
- 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.
Read the data
Section titled “Read the data”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.
Answer in time
Section titled “Answer in time”- 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.
Accept only requests from OneClick
Section titled “Accept only requests from OneClick”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.