HubSpot Ideas

Candice1

Close Conversation through workflow

Automatically close a conversation inbox message workflow

 

8 Replies
CMcKay
Top Contributor

You should be able to accomplish this with a custom code action.

1stClaas
Contributor

We are looking for the same thing.
Imagine you have a form on your landing page and make it optional to add contact details (for us also information without contact is useful to stock statistics).
Now, whenever someone sends in a form we want the conversation to be closed automatically to avoid unnecessary work.

Bildschirmfoto 2022-05-23 um 16.19.09.png

Bildschirmfoto 2022-05-23 um 16.14.40.png

Bildschirmfoto 2022-05-23 um 16.13.58.png

   

CMcKay
Top Contributor

Here's a custom code action I built out and tested.

const http = require('https');

exports.main = async (event, callback) => {

  /*****
    How to use secrets
    Secrets are a way for you to save API keys and set them as a variable to use anywhere in your code
    Each secret needs to be defined like the example below
  *****/

  const HAPIKEY = process.env.Hapi;

  const hs_thread_id = event.inputFields['hs_thread_id'];
  
  //close the conversation/thread
var options = {
  "method": "PATCH",
  "hostname": "api.hubapi.com",
  "port": null,
  "path": "/conversations/v3/conversations/threads/"+hs_thread_id,
  "headers": {
    "accept": "application/json",
    "content-type": "application/json"
  }
};

var closeThread;
  
var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
    closeThread = body.toString(); 
  });
});

req.write(JSON.stringify({status: 'CLOSED', archived: true}));
req.end();


  callback({
    outputFields: {
      closeThread: closeThread
    }
  });
}

 

Here's what the inputs look like: 

CMcKay_0-1653318896159.png

 

The auth token is for one of your private app tokens (NOT HAPIKEY). 

 

Let me know if you have any questions

AvS-K
Participant

Really nice idea. We're waiting for this.

froettgen
HubSpot Employee

+1

Luc_LC
Member

+1

M_Fischer
Member

+1

YoelTorresM
Member

+1