ServiceNow listener - servicenow

So preferably using GO or Python is there a way to listen to servicenow API so that whenever a ticket is assigned to my group, it can instantly trigger a local script? I have it set that some of our tasks in my group are completed with a local script, but there is nothing to trigger them. I tried using a websocket, but it redirected to https and some of the documentation seems to indicate that the ws protocol is not supported. Any thoughts?

create a service now business rule to post to an api
https://docs.servicenow.com/bundle/quebec-application-development/page/script/business-rules/concept/c_BusinessRules.html

Related

EWS - One or more subscriptions in the request reside on another Client Access server

I got this error when I'm using streaming subscription with impersonation.
After the connection opened and receive notification successfully for minutes, it just pops up a bunch of this for almost all subscriptions.
How can I avoid this error?
One or more subscriptions in the request reside on another Client Access server. GetStreamingEvents won't proxy in the event of a batch request., The Availability Web Service instance doesn't have sufficient permissions to perform the request
I need to keep the connection stable and avoid this error.
Sounds like you haven't use affinity https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-maintain-affinity-between-group-of-subscriptions-and-mailbox-server
Also if its a multi threaded application ExchangeService isn't thread safe and shouldn't be used across multiple threads.

Interact with slack bot without a public accessible server

For some security reasons that I can't have a public accessible server to receive data from slack.
So, this is what I'm planning to do:
Inbound message from slack: using RTM API
Outbound message to slack: using RTM API or Web API
Questions:
Any better alternatives?
Any restrictions? (AFAIK, buttons and drop downs can't work)
If Web API reach rate limit, can I use incoming webhook as a backup plan?
RTM only approach
Yes, that would work. With only the RTM API you are limited to:
receiving and responding to messages
Other RTM events.
You can't use any interactive functionality like:
Interactive components (buttons, menus, datepickers)
Dialogs
Rate limit on message posting
Using the webhook as "backup" to circumvent the rate limit is not an option, since the rate limit of posting max 1 message per second applies to all form of message posting.
From the documentation:
In general, apps may post no more than one message per second per
channel, whether a message is posted via chat.postMessage, an incoming
webhook, or one of the many other ways to send messages in to Slack.
Alternatives
You did not give any details about the reasons why your app can't expose an endpoint to the public Internet. But you might want to consider using a VPN tunnel like ngrok.
Yes! Socket Mode
There is a new alternative from slack, Socket Mode, which doesn't require a publicly accessible server.
Note: this is only for private apps.
With Socket Mode you have an API token and your server uses it to communicate with Slack's servers and create a two way socket connection. This means your Slack Bot's code can run on a machine behind a firewall and not require any inbound ports to be opened.
Slack message delivery requires an acknowledgement once you get the message, or else they may retry to deliver it.
Limitations
Socket Mode has two main limitations:
Apps using Socket Mode are not currently allowed in the public Slack App Directory.
Socket Mode is only available for apps using new, granular permissions. If you created your app on or after December of 2019, good news: your app already uses the new permissions. Otherwise, you may have to migrate your classic Slack app to use granular permissions before turning on Socket Mode.

Interactive messages on slack without external service

I'm working on a simple slack bot which is supposed to ask simple questions (yes/no) and based on answers perform some actions. AFAIU I should be using interactive messages for this. The problem is that it's supposed that slack will then call some external URL with the result, but for security reasons, I can't expose any service externally.
I was hoping I can just receive some event (using Events API) from Slack that user choose one of the options and simply read it directly using API. Unfortunately I can't find anything like that.
Is possible to use interactive messages without exposing external service to the world?
Yes. If you build a bot with the Real Time Messaging API you do not need to expose an endpoint to the public Internet.
With the RTM API you open a connection to Slack (which can be from behind a firewall) and maintain that connection. There is no call-back from Slack.
However, the RTM API will only enable you to create a chat bot that can react to events and message posts. The interactive message features like buttons and drop-down menus still require you to provide an endpoint.

Slack - behind a “firewall“

I've try to create a slackbot. Works fine, but my problems are calls from slack to my rest api. My app is an internal service, so it's not available from the internet. I have seen that outgoing webhooks is possible to set, but I have to forward the request back to the internal service which I don't like very much. As far as I know slack is based on websockets, so is it possible to write a bot which run behind my “firewall“ and get it's commands via websocket?
Greetings
Tonka
You can use services like Localtunnel for receiving webhooks behind a firewall.
We use it with a docker container to develop our slack bot in local env.
Webhooks, slash commands, interactive messages, events etc. are based on HTTP.
Only bots use websockets.
But even this bot websocket session still needs to be initiated with an HTTP call.
Not entirely sure how your firewall is set up, but you may want to make your endpoint public to make things easier.

AWS SNS not sending subscription confirmation for HTTP

I am trying to set up a basic SNS subscription but it looks like AWS never sends the confirmation, either through the console or using the SDK.
Steps I have taken so far:
I have set up a Topic using the AWS console
I have added HTTP subscriptions to both an ngrok tunnel URL and also a public web server URL using both the AWS console and the ruby SDK
I have allowed everyone to subscribe to the Topic by editing the Topic policy in the AWS console
By tailing the logs on both my localhost and public web servers I can see that no request is ever sent to the endpoint.
I'm pretty stumped here because it seems like it should definitely be working, or at least sending something (anything) to my endpoints?
The code I'm using for the ruby sdk is as follows:
sns = AWS::SNS.new(access_key_id: ENV['AWS_ACCESS_KEY_ID'], secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'])
# I only have one topic
topic = sns.topics.first
topic.subscribe(URI.parse('http://<NGROK_URL>.ngrok.com/notifications/notify'))
topic.subscriptions.first
# returns: => <AWS::SNS::Subscription arn:PendingConfirmation>
This turned out to be an issue related to the region I was working in. I changed to Oregon and all confirmations are sending immediately.
There must be some permissions setting somewhere that prevents you from sending any messages at all from certain regions, but it was failing silently.
For me, it appears that it may not be the region (though I was trying us-east-1 too), but how ngrok's network is set up. I used a different site-forwarding service (finch) and was completely successful. This AWS forum topic makes be think that the problem may be intermittent, too.

Resources