I received this requirement to jump into something super fun in my opinion and wanted to document my experience. There's a Live Coding Happy Hour on this topic which I used for reference but my steps do differ due to being on a newer version of ServiceNow. I do want to mention that IntegrationHub and the Twitter Spoke make it super easy to go from zero to hero with an integration such as this. For example, lets say your organization isn't big into Flow Designer or IntegrationHub yet, you don't have to shy away from an integration such as this or something like the Slack spoke. These things are very easy to set up once you get the pieces in place. In my example I'm using demo data to tweet outages to a Twitter account, your organization may have specific security/communication policies in place so check with them before attempting this with records such as outages.
To get started you need to make sure you have IntegrationHub installed and the latest version of the Twitter Spoke, as of this writing it is 1.1.2.
Twitter Developer Account
The first thing I had to do was create a Twitter Developer Account. It was free and I signed up using my organization email since I'll be developing this functionality for them. Here's a link for more information on the Developer portal. What we're going to do is gain access to the Twitter API and create a Project within our Developer portal to use. I do want to note you may want to speak to your twitter administrator before doing this, to see if they have a team account and if they need to add you there first. You will need to Sign up to use the Twitter API with your Twitter Developer account, make sure you have a verified phone number associated to your Twitter Developer account because you'll need it to get past this step. Once you've submitted the application, go through the process of verifying it in email, and you may need to finish another questionnaire in your profile for elevated access. You'll really need to provide detailed information about your app in this section. Regarding the questions about aggregating data, etc. I mentioned the out-of-the-box Twitter dashboard that is installed as part of the Twitter Spoke.
The next thing I had to do within the Twitter Developer Portal was to create an app. Under the Elevated section I created a new project, named my app Outage, answered the usage questions, and placed it in the Development environment for now.
I do want to mention that it seems like apps are named per environment, so while I named my Project/App Outage, I'll name it Outage - Dev for this particular development environment. Once I get more serious and do testing, I'll more than likely create a Production version of the application and link that up to ServiceNow.
After set up I receive my Keys & Tokens which I need to reference later, but you'll want to save them off somewhere for the Spoke set up because they will not be displayed again, they will need to be regenerated.
Since I want the Twitter Spoke to write to Twitter, I edited the app permissions to Read and Write.
Connections & Credentials
Now that I have the Twitter side of the house set up, I'll now add the credentials into ServiceNow. Here's some product documentation on how to do that. In Rome there is a link for Twitter Credentials so that makes it a lot easier.
Just to clear some wording up, the Consumer Key is the API Key, and the Consumer Secret is the API Key Secret. I didn't get an Access Token/Access Token Secret when I created the app but noticed I can generate them now.
Under Credential alias I do see there are two out-of-the-box ones for Twitter, but they are not selectable for my Credential alias for some reason, I'll move on to Connections and just leave this blank for now. The two connections are as follows:
Twitter - Used for messages
Twitter_Media - Used for media
For this post I'll use the messages connection as that's what I'll be doing mainly. To note, it looks like only one connection can be used with a credential at a time. There's more information in the product documentation about aliases and child aliases that I assume would work for the Twitter_Media connection. On the Connection related list, click New to create a new HTTP Connection. Here's the product documentation on how to set this up, I basically followed the directions and hooked it up to my Outage - Dev credential I created previously.
Creating a Flow
The Twitter Spoke should be set up now for use with ServiceNow. To verify I went into Flow Designer > Connections and checked the Twitter Connection.
Next, I created a basic flow called Outage - Twitter and added a trigger for Outage - Inserted, just as a note I had to do this in the Global scope in order to access the Outage table. I then selected the Tweet action and inserted the following under Message:
/* **Access Flow/Action data using the fd_data object. Script must return a value. **example: var shortDesc = fd_data.trigger.current.short_description; **return shortDesc; */ var number = fd_data.trigger.current.number; var shortDesc = fd_data.trigger.current.short_description; var begin = fd_data.trigger.current.begin; return 'Outage ' + number + ' ' + shortDesc + ' ' + begin;
Now I'll test my Flow and check my account, I do see in the execution details of Flow Designer all looks well:
And in Twitter my Tweet shows under the account that is associated to my Twitter Developer account, yay!
For real life purposes I'll need to connect this app to my organization's account, but I've found there are some backend logistics things I need to do that are outside of the Twitter Spoke for ServiceNow. If you're planning on doing this check with your Twitter admin, or look into creating a Team account if you can. I'm hoping that if my developer account is added to a Team account that contains the Twitter account I want to post to, they can add my account easily, but thats for another day. I'll post an update to this post with what I find about using apps with other accounts once I know more.