Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

retrieve slack user message and post it to work notes

ujjwalababa
Tera Contributor

Hi All,

I am working on scheduled job creation to send message and retrieve the user response on that message....I have created a script include for that ...but not sure if i am using correct urls and methods here.

Could anyone please suggest me any changes here....also I want to retrieve the user response and post it as work notes for the specific record...also i need to testing steps how can I verify message getting posted over slack and getting fetched the user response on that..

All suggestions are welcome here,

Thank you in advance!

Script Include Name: SlackIntegration

Script:

var SlackIntegration = Class.create();
SlackIntegration.prototype = {
initialize: function() {},
sendMessage: function(channel, message) {
var headers = {
"Authorization": "Bearer YOUR_SLACK_API_TOKEN"
};
var payload = {
channel: channel,
text: message
};
var response = new sn_ws.RESTMessageV2();
response.setHttpMethod('post');
response.setEndpoint(url);
response.setRequestHeader('Content-Type', 'application/json');
response.setRequestBody(JSON.stringify(payload));
response.setRequestHeaderMap(headers);
var responseBody = response.execute();
// Process the response as needed
},
RetrieveMessage: function(channel, message) {
var headers = {
"Authorization": "Bearer YOUR_SLACK_API_TOKEN"
};
var payload = {
channel: channel,
text: message,
latest: "YOUR_TS_VALUE",
limit: 1,
inclusive: true
};
var response = new sn_ws.RESTMessageV2();
response.setHttpMethod('get');
response.setEndpoint(url);
response.setRequestHeader('Content-Type', 'application/json');
response.setRequestBody(JSON.stringify(payload));
response.setRequestHeaderMap(headers);
var responseBody = response.execute();
// Process the response as needed
},
type: 'SlackIntegration'
};
0 REPLIES 0