Mattermost is an open source team collaboration platform tht brings all your company's conversations, documents, and applications together in one place, making it easy for your team to collaborate securely on the things that matter most.
The Amazon SNS platform (SNS) is a web service that enables you to send an SMS or a text-enabled mobile push notification to targeted subscribers.
Amazon SNS IntegrationsMattermost + Amazon SNS
Create Message to Amazon SNS from New Message Posted to Channel in Mattermost Read More...Mattermost + Amazon SNS
Create Topic to Amazon SNS from New Message Posted to Channel in Mattermost Read More...Amazon SNS + Mattermost
Post Message in Mattermost when New Topic is created in Amazon SNS Read More...Amazon SNS + Mattermost
Post Message in Mattermost when New Subscription is created in Amazon SNS Read More...Mattermost + Gmail
Create Draft to Gmail from New Message Posted to Channel in Mattermost Read More...It's easy to connect Mattermost + Amazon SNS without coding knowledge. Start creating your own business flow.
When message post on perticular channel.
Triggers when you add a new subscription.
Triggers when you add a new topic.
Post a new message to a channel.
Create a new message.
Create a new topic.
(30 seconds)
(10 seconds)
(30 seconds)
(10 seconds)
(2 minutes)
Mattermost is an open source, private messaging application for businesses. It’s cross-platform, running on Linux and Mac OSX, top of the line iOS and Android. Mattermost is written in Go. It’s a Slack competitor, but with paid support and a 50% open source business model. There are a bunch of other companies using it, like Atlassian, NCR, Slack, Foursquare, Sony Music Entertainment and more.
Amazon SNS stands for Simple Notification Service. It’s a web service that allows you to send notifications to cloud services, mobile apps or end users. The message will be delivered via email, SMS (text messages. or mobile app push notification. You can also use HTTP push for sending messages. This way you can deliver messages via http/s endpoint or command line tops like curl.
Let’s take a look at how we can integrate these two systems together. First off, we’ll need to do some setup on the Amazon SNS side:
Create an Amazon SNS topic Generate an AWS access key Set the permissions for the IAM rpe Create the message that contains the recipient information Create a Lambda function to handle the messages Subscribe to the topic Return the result
The first thing we’re going to do is create a topic on SNS:
Next, in order to send messages through SNS, we’re going to need an AWS access key:
Now that we have an access key, we need to generate an IAM rpe (IAM stands for Identity & Access Management):
Now, let’s set permission so that our IAM rpe can publish to our topic:
This next step will require you to fill out a form. When it comes time to enter the Lambda ARN, enter this in. arn:aws:lambda:us-east-1:[account_id]:function:[function_name] (which will look something like arn:aws:lambda:us-east-1:123456789012:function:myFunction. This will look different than the function name you created when creating your Lambda function. To find out what it is, go back to the AWS Lambda conspe and click on your function. Then click on “Info” in the left hand pane; you should see something like “arn:aws:lambda:us-east-1:[account_id]:[function_name]” which will be used in this step:
Now that we have permission to publish to our topic, let’s create our message. This will look something like this (it will include all of your necessary fields). { "Recipient":{ "Type":"AWS", "Id":"123456789012", "Arn":"arn:aws:sns:[region]:[account_id]:[topic_arn]", "Endpoint":"https://pubsub.us-east-1.amazonaws.com", "Protocp":"email" } } For more information on this structure and all of the fields that are available, visit https://docs.aws.amazon.com/AmazonSNS/latest/DeveloperGuide/sns-topic-content-template.html#sns-topic-content-template-fields Here’s mine for my test account (notice that I replaced my dummy account id [123456789012] with my actual account id [1111111110000]). { "Recipient":{ "Type":"AWS", "Id":"1111111110000", "Arn":"arn:aws:sns:[region]:[account_id]:[topic_arn]" } } Next, we need to create a lambda function so that we can process the messages from our topic and store them in a database like DynamoDB. The code for this is below; it’s pretty straight forward. I used two tables for my purposes; one for the message itself, and one for the sender ID. In my real world example, I would also include a table for the timestamp as well as all of the data needed for sending push notifications (as well as storing it in the message. // s3 bucket must be configured before running this lambda function // See https://matermost.readme.io/docs/instructions-for-using-the-amazon-web-services-conspe#configuring-your-bucket-url import boto3 import json def lambda_handler(event, context). print("Received event". print("data:" + json.dumps(event). response = "success" # Get the message from SNS and unpack it msg = boto3.client('sns'.publish( MessageBody='{"Recipient":{"Type":"AWS","Id":"1111111110000","Arn":"arn:aws:sns:[region]:[account_id]:[topic_arn]"},"Message":{"RecipientType":"AWS","RecipientId":"1111111110000"},"MessageAttributes":{"TopicArn":","Timestamp":"1519187102","MessageId":","LogicalSubscriptionID":"},"MessageData":{"TopicArn":","MessageTimestamp":"1519187102","MessageId":","MessageAttributeUpdate":[],"MessageAttributeDeletion":[],"UserIdentity":{"Arn":"arn:aws:iam::1111111110000:user/jamesbond"},"UserName":"jamesbond"},"MessageSourceIPAddress":["127.0.0.1"]}}' . # Get the message attributes from SNS and unpack them attrs = { 'RecipientType':'AWS', 'Timestamp':time(), 'UserIdentityArn':'arn:aws:iam::1111111110000:user/jamesbond', 'MessageSourceIpAddress':'127.0.0.1' } # Process the unpack data into a dataframe df = pd.DataFrame(attrs. # Now check if there's any data if len(df['MessageData']. > 0 . df = df[df['MessageData']].applymap(json.loads. # If there's data then add it to the database if len(df. > 0 . if 'MessageAttributeUpdate' in df['MessageData']. db_conn = boto3.resource('dynamodb', region_name='us-east-1'. table = db_conn['table'] payload = json.loads(df['MessageAttributeUpdate']['MessageData']. table_item = table_item_dict(table['Key'], table['Value']. # Add the record to table table['AddItem'] = table['Key'] table['AddItem'] += ':' + table['Value'] # Commit the changes table['PutItem'] = table['Key'] db_conn = boto3.resource('dynamodb', region_name='us-east-1'. table = db_conn[table_name] try . table['DeleteItem'] = table['Key'] except KeyError. pass try . table['UpdateItem'] = {"InsertedItem":{"key":","value"}} except KeyError. pass try . table['UpdatedItem'] = {"Item":{"key":","value"}} except KeyError. pass except Exception as e. print("Exception:" + str(e). else . print("No data found". else . print("No data found". else . print("No data found". # Return response return response def table_item_dict(table_name, item). if item is not None and item not in table[table_name]. print("Adding record - "+str(-1. + item + "- to table "+table_name. return {} else . print("Replacing record - "+str(-1. + item + "- with new value". return {'Key'. item} df['MessageAttributes']['UserIdentity'] = user_result(user, 'UserName', 'arn:aws:iam::1111111110000:user/jamesbond'. df['Key'] = df['MessageAttributes']['UserIdentity'] print (" Retrieved message attributes -> key = "+str(df['Key'])+" , value = "+str(df['MessageAttributes']['UserIdentity']). return {'Result':response} def user_result(
The process to integrate Mattermost and Amazon SNS may seem complicated and intimidating. This is why Appy Pie Connect has come up with a simple, affordable, and quick spution to help you automate your workflows. Click on the button below to begin.