Slack Adapter for OIC

This article was originally published in the Oracle Integration Blog. 

The Slack adapter for Oracle Integration Cloud was released recently and delivers an easy way of Integration with Slack. 

 

Slack and other platforms with similar capabilities changed the way we work, and the way we interact with our colleagues. It’s difficult to imagine a world with only email as communication method – the boost in productivity and cooperation with these types of platforms is incredible. Slack is also a verb nowadays (let me slack you), that alone is enough to show its Impact 😊

 Slack Adapter Capabilities

Slack is a collaboration hub that helps you and your team work together seamlessly. In Slack, team members send messages and share files in channels. 

The Slack Adapter offers outbound integration with Slack on the Oracle Integration platform. You can create outbound integrations that invoke the Slack application so you can manage channels, invite users, get profile information, manage chat and groups, upload files, and perform search operations. 

More details on the documentation page.

Use Cases

The first use case that comes to mind is about Notifications – Traditionally a notification is an email – but instead of relying on an email, you can publish those notifications into a dedicated channel, or tag the proper team/individual. This will allow a transparent handling and collaborations of all notifications! 

Let’s now think on Sales Orders – When a new order/opportunity is created in  CRM system you can create a new slack channel with all team members, or you can tag someone that has a particular task waiting to be fulfilled for example. 

These are just two obvious use cases but in reality there are so many possibilities here – you can pick up any real time event , filter it and tag someone, create a channel, send an attachment to a channel, escalations, reminders etc, etc. 

Prerequisites for Creating a Connection

If you are an Integration developer probably you will ask the Slack administrator for this information – but in case you have both roles, here is a quick walk-through. 

Before you can create a connection with the Slack Adapter, you must satisfy the following prerequisites. 

·  Have an OAuth application (published) on the Slack platform.

  •         Client ID and client secret.
  •         User Token Scopes defined
  •         Fill the Redirect URL

When you create a Slack app, the Client Id and Secret are
automatically created.


Under OAuth & Permissions tab you can add the desired scopes.


Fill the Redirect URL with:

https://<instance
name>.integration.ocp.oraclecloud.com:443/icsapis/agent/oauth/callback 


The last step is to install the app to the slack workspace!

 

How to create a connection?

 Choose Slack as the desired adapter. 

 Name your connection and provide an optional description. 

 Click configure Security:

Client Id and Secret:

Use the client id and secret from the slack app

 Scope:

Add the desired scope – here I just want to enable read/write capabilities. Scopes are separated by a space.

Here is a list of the supported scopes and their respective operations: https://docs.oracle.com/en/cloud/paas/integration-cloud/slack-adapter/invoke-operations-page.html

Finally press the “Provide Consent” button – this will open a popup/tab where you need to provide the slack credentials, after which you will be requested to allow access.

 All going well you should see the below screen

 

How to create an Integration?

I will showcase how to use the Slack adapter for notifications. With a simple scheduled Integration that is supposed to read files from an FTP – built to fail 😊 then the global fault comes into play and we create the Slack connection so that we can write the error notification to a channel!

Drag the Slack adapter onto the Global Fault canvas. 

 

Next you can see all the available operations – For this case we want to send a message

 Full list of Operations here . 

 And that’s about it! 

 Finally, we need to define the mapping activity.


There are 2 fields that we should map:

Channel – here I will hard-code the name of the channel where we want to write the message – “ops_integration” 

 

Text – This is the message we want to write. Since this is an error notification I concatenate some relevant fields, like “IntegrationName”,”Enviroment”, “ErrorReason

 You can add attachments or enrich this message as much as you want!

 concat (“There is an error in Integration : “,
$self/nsmpr2:metadata/nsmpr2:integration/nsmpr2:name, “, on environment:
“, $self/nsmpr2:metadata/nsmpr2:environment/nsmpr2:serviceInstanceName,
” with error details: “,
$GlobalFaultObject/nsmpr1:fault/nsmpr1:reason )
 

Now we can run the Integration, and it is builtto fail on the FTP invocation! 

 Once the error occurs, the Global Fault handles it! 

And this is the message published to Slack! 

 

 Easy, yet powerful!!