Integrations / Slack

Slack logo

Team chat · Slash command + incoming webhook

Slack + Sendjade

Send WhatsApp messages from Slack, and post incoming WhatsApp messages into a channel.

Live API · real-phone check pending

What you can automate

  • Let support reply to customers with a slash command
  • Post new WhatsApp messages into #support
  • Alert a channel when a number disconnects

Before you start

  • A Sendjade account with a connected instance (status Authorized). See Getting started.
  • Your **idInstance** (shown on the instance page in the console) and **apiTokenInstance** (shown once when you created the instance; press Generate new token if you lost it). Use a spare number while testing.
  • A Slack workspace where you can create an app, and a place to host a small Node server.

Set it up

  1. WhatsApp to Slack

    Create a Slack Incoming Webhook URL, register this server as a Sendjade webhook endpoint (event message.received), and verify every delivery before trusting it.

    forward.mjs
    import crypto from 'node:crypto';
    
    // Returns true only for a genuine, recent Sendjade delivery. `raw` is the exact request body string.
    function verifySendjade(raw, header, secret) {
      const parts = Object.fromEntries((header || '').split(',').map((p) => p.trim().split('=')));
      const t = Number(parts.t);
      if (!t || !parts.v1 || Math.abs(Date.now() / 1000 - t) > 300) return false;       // stale: possible replay
      const expected = crypto.createHmac('sha256', secret).update(t + '.' + raw).digest('hex');
      return parts.v1.length === expected.length && crypto.timingSafeEqual(Buffer.from(parts.v1), Buffer.from(expected));
    }
    
    import express from 'express';
    const app = express();
    
    app.post('/sendjade', express.raw({ type: 'application/json' }), async (req, res) => {
      const raw = req.body.toString('utf8');
      if (!verifySendjade(raw, req.get('X-Sendjade-Signature'), process.env.SENDJADE_WEBHOOK_SECRET)) return res.sendStatus(401);
      res.sendStatus(200);
    
      const { event, data } = JSON.parse(raw);
      if (event === 'message.received') {
        await fetch(process.env.SLACK_WEBHOOK_URL, {
          method: 'POST',
          headers: { 'Content-Type': 'application/json' },
          body: JSON.stringify({ text: 'WhatsApp from ' + (data.senderName || data.chatId) + ': ' + data.text }),
        });
      }
    });
    app.listen(8081);
  2. Slack to WhatsApp

    Create a slash command (for example /wa) that posts to your server. Verify Slack's signature, then call Sendjade. Slack expects a reply within 3 seconds, so answer first and send in the background.

    slash.mjs
    import express from 'express';
    import crypto from 'node:crypto';
    const app = express();
    app.use(express.urlencoded({ extended: true, verify: (req, _res, buf) => { req.raw = buf.toString(); } }));
    
    app.post('/slack/wa', async (req, res) => {
      const ts = req.get('X-Slack-Request-Timestamp');
      const sig = 'v0=' + crypto.createHmac('sha256', process.env.SLACK_SIGNING_SECRET).update('v0:' + ts + ':' + req.raw).digest('hex');
      const given = req.get('X-Slack-Signature') || '';
      if (Math.abs(Date.now() / 1000 - Number(ts)) > 300 || given.length !== sig.length || !crypto.timingSafeEqual(Buffer.from(given), Buffer.from(sig))) return res.sendStatus(401);
    
      const [to, ...rest] = req.body.text.split(' '); // /wa 2348012345678 Your order is ready
      res.json({ response_type: 'ephemeral', text: 'Queued for ' + to });
      await fetch('https://api.sendjade.com/waInstance' + process.env.SENDJADE_ID_INSTANCE + '/sendMessage/' + process.env.SENDJADE_TOKEN_INSTANCE, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ chatId: to.replace(/\D/g, ''), message: rest.join(' ') }),
      });
    });
    app.listen(8082);

Test it

In Slack run `/wa <your number> test`. The message should arrive on your phone.

Troubleshooting

Slack shows "dispatch_failed" or a timeout

Your server must answer within 3 seconds and be reachable over HTTPS. The example replies first and sends in the background.

Nothing arrives in Slack

Check the webhook's delivery log in Sendjade (status codes and errors per attempt) and that your endpoint is public HTTPS.

I get 401 unauthorized

The idInstance or token in the URL is wrong. Copy both again from the console. Generating a new token makes the old one stop working immediately.

I get 409 instance_not_connected

The instance is not Authorized yet. Open it in the console, press Connect and scan the QR code.

I get 400 invalid_chat_id

Use international format with digits only, e.g. 2348012345678 (or 2348012345678@c.us). Remove spaces, dashes and the leading zero of the local number.

I get 422 recipient_opted_out

That person replied STOP (or was added to the opt-out list). Sendjade refuses to message them. Remove the number from Opt-outs only if they asked to hear from you again.

I get 429 daily_limit_reached or rate_limited

The number reached its 24-hour sending cap (default 500) or you are calling too fast. The cap protects your number from restriction. Slow down, and raise the cap only if your volume is genuine.

Ask AI to help me integrate Slack

Copy this prompt into ChatGPT, Claude or any assistant. It already knows Sendjade’s API, so the answer matches our endpoints.

The prompt is plain text that you copy yourself. Never paste real keys into an assistant; use placeholders.