Skip to main content

Create a Stream App

This guide describes how to create a stream App.

Step 1: File Setup​

Your sample app needs the following file hosted within your domain's root directory:

my_app.html - The landing page for your App's first App stream within the Hootsuite dashboard.

Step 2: Create an App Stream​

To create a stream for your App in My Apps:

  • Click on your app's name
  • Click New App Extension
  • In the App Extension Type field, select Stream
  • In the App Extension Title field, insert a title for your stream.
  • Click Add
  • Optional: provide an icon to serve as the image of the stream:
    • Store the desired image in the domain's root directory
    • Navigate to your additional App extensions, then click Edit under the Actions heading for your stream
    • In the Icon URL (30x30) field, point to the absolute URL of the image you stored in your root directory
  • To specify the URL used to load your app stream, type it in the Service URL field (ex. https://localhost/app.html)
  • Click Save

You have now created a stream for your app!

Step 3: JS Library Setup​

In order to enable your app's ability to send and receive messages to and from the Hootsuite dashboard, you will need to add a reference to the Hootsuite hosted portion of the App Directory SDK. This file is located here:

https://assets.hootsuite.com/jsapi/4-1/hsp.js

Note: Do not download the above javascript file to include in your app. Always use the above CDN to ensure your app is using the current SDK version.

To reference this script, add the following HTML snippet to the top of the section of your my_app.html file:

<script src="https://assets.hootsuite.com/jsapi/4-1/hsp.js"></script>

Step 4: App-Dashboard Event Setup​

In my_app.html, initialize the JS API using the hsp.init function and set the hsp parameters by doing the following:

As the sdkApiKey string, use the SDK API Key you retrieved and stored previously
Insert this code in the section of the file:

<script>
hsp.init({
sdkApiKey: [YOUR-SDK-API-KEY-HERE]
});
</script>

Step 5: Add Content​

Add some content to your app. In the my_app.html file, at the top of the section of the document, insert the following HTML:

<h2>My First App</h2>

Step 6: App Stream Installation​

Inside your Hootsuite dashboard:

  • On the Launch Bar, click App Directory.
  • Under My APPS, click Installed. Your App should appear in the menu.
  • Note: if your App does not appear in the Installed section, click Developer under MY APPS. Click Install next to your App's name.
  • On the Launch Bar, click Streams.
  • Navigate to Add a stream, to the right of your previously installed streams. Click the Apps tab.
  • Click the + icon next to your App's name.
  • At this point you should see your app appear in a Hootsuite stream with the heading that you added in Step 5. It should look similar to this:

Step 7: Send Messages to Hootsuite​

Let's add functionality that will make your app communicate with the Hootsuite dashboard. We'll do this by using a basic function available in hsp.js:

hsp.showUser(twitterHandle): Opens a user info popup for the specified twitter username. Let's use Hootsuite (@hootsuite) as an example.

The code should be placed in the section of my_app.html, right after the heading added in Step 5 It should look something like this (line break tags are optional):

<br/>
<a href="#" onclick="hsp.showUser('hootsuite'); return false;">Show @hootsuite info</a>

Step 8: Receive Messages from Hootsuite​

Let's check if your app is enabled to receive events from the Hootsuite dashboard by using the hsp.bind() function for two different types of events:

  • refresh: Fired when the app stream is refreshed.
  • dropUser: Fired when a user drags and drops a Twitter account from the Hootsuite dashboard into your app stream.

We will place this functions in my_app.html, in between the script tags used for hsp.init(), right after the function created in Step 4.

hsp.bind('refresh', function() {
window.location.reload();
});

hsp.bind('dropuser', function(username, tweetID) {
hsp.showUser(username);
});

Where window.location.reload() reloads the app streams' window and dropping a Twitter account into the app stream will use the hsp.showUser(twitterHandle) function described in Step 7

Once your stream is set up, it's time to add an App Plugin that'll allow you to extend the set of actions that can be taken on messages received in the Hootsuite dashboard.