Git Product home page Git Product logo

snow2pubnub's Introduction

snow2pubnub

This repo contains a quick-and-dirty implementation of a Service Now script include that is capable of inserting a message onto PubNub. It was originally created for a demo and not intended for production use.

PubNub

First, take a look at the PubNub API in question.

In particular, there's a very convenient GET method that can be used to place a message on the queue

https://ps.pndsn.com/publish/{pub_key}/{sub_key}/0/{channel}/0/{payload}{?uuid}

URI Parameters

pub_key

string (required) Example: myPubKey the publish key to use

sub_key

string (required) Example: mySubKey the subscriber key

channel

string (required) Example: ch1 the destination of the message

callback

string (required) Example: myCallback response will be wrapped in JSONP function, 0 for no JSONP

payload

string (required) Example: %7B%22text%22%3A%22hey%22%7D url-encoded JSON

uuid

string (required) Example: db9c5e39-7c95-40f5-8d71-125765b6f561 A unique alphanumeric ID for identifying the client.

Example

So the following:

curl https://ps.pndsn.com/publish/myPubKey/mySubKey/0/ch1/0/%7B%22text%22%3A%22hey%22%7D?uuid=db9c5e39-7c95-40f5-8d71-125765b6f561

Will cause this to show up in Pubnub:

{
  "text": "hey"
}

SNOW REST

Service Now has a facility for setting up REST endpoints. Create a new REST message called PubNub that has the following endpoint

https://ps.pndsn.com/publish/${pubkey}/${subkey}/0/${channel}/0/${encodedMsg}?uuid=${uuid}

Once created, in the HTTP Methods section, click on the Default GET. In the second set of tabs, there is a tab titled Variable Substitutions. For each of the variables in the URI (pubkey, subkey, channel, encodeMsg, and uuid), set the names and values accordingly based on what you did for the curl test earlier.

Between the two sets of tabs, there is a section titled Related Links. With the Variable Substitutions set, click on Test. When doing so, you should now see a new message show up on PubNub that matches whatever you set encodeMsg to.

Note Right now, I can't get the channel variable to set correctly so as a workaround you can hard code your channel name.

SNOW Business Rule

The contents of pubnub.js are derived from the SNOW provided Yahoo Finance example. Make a business rule out of it, filling in the appropriate var values as needed.

Note Right now, I'm unable to get Business Rules to fire correctly so the pubnub.js code has not yet been tested. Specifically, I'm a little worried about whether or not encodeURI is available.

snow2pubnub's People

Contributors

nerdguru avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.