Git Product home page Git Product logo

mattermost-giphy-lambda's Introduction

Giphy Integration for Mattermost using AWS Lambda

AWS Lambda Function to create a Slash-Command for Giphy-Integration in Mattermost

Description

This is pretty simple AWS Lamba function to use with Mattermost for Giphy-Integration. It allows to create a slash-command such as "/giphy " to post a random gif for that keyword from giphy into a channel or chat.

Setup

AWS Lambda

  1. Create a new lambda function with the "Node.js 6.10" runtime.
  2. Copy-paste the content of index.js into it.
  3. Save

AWS API Gateway

Add a new API Gateway POST endpoint. It should have "integration type" Lambda and point to your Lambda function from the previous step.

Mattermost submits its request using POST and as x-www-form-urlencoded, but Lambda expects JSON.

Therefore, you need to edit the "Integration Request" and add the following Body Mapping Template for application/x-www-form-urlencoded:

#set($allParams = $input.params())
{
  "body" : $input.json('$')
}

This should convert the x-www-form-urlencoded'ed data to JSON.

Mattermost

https://docs.mattermost.com/developer/slash-commands.html

Add a slash command according to the documentation and point it at your API Gateway URL.

Verify Requests

Mattermost creates a random verification token for each slash command. You can go back to your Lambda function and add it to the TOKEN constant to enable verification of incoming requests.

Get a Giphy-API Key

The API-Key in the current implementation is simply the public "beta" API key from giphy. You should probably request your own API key and add it to the API_KEY constant in the Lambda function.

mattermost-giphy-lambda's People

Contributors

pableu avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.