项目作者: jainishshah17

项目描述 :
Slack bot for weather
高级语言: JavaScript
项目地址: git://github.com/jainishshah17/slack-weather-bot.git
创建时间: 2019-10-16T17:56:55Z
项目社区:https://github.com/jainishshah17/slack-weather-bot

开源协议:Apache License 2.0

下载


slack-weather-bot

Slack bot to get weather details.

Prerequisites

Getting started

  • Checkout code:

    1. git checkout https://github.com/jainishshah17/slack-weather-bot.git
  • Install Npm dependencies:

    1. cd slack-weather-bot/
    2. npm install
  • Create Slack App

    1. Go to https://api.slack.com/apps
    2. Create New App:
      Name: Weather
      Development Slack Workspace: Choose your workspace
    3. Add logo and description: “Get current weather information by ZipCode.”
    4. Copy Signing Secret and store it in .env file.
    5. Go to Features -> OAuth & Permissions -> Scopes and add following permission and save changes:
      image
    6. Install newly created Weather App to your workspace.
    7. Go to Features -> OAuth & Permissions -> OAuth Tokens & Redirect URLs.

      Then copy OAuth Access Token and store it in .env file.
    8. Get and store Openweathermap API Key in .env file.
  • Start Weather app server

    1. npm start
  • Install and run Ngrok

  1. npm install -g ngrok
  2. ngrok http 3000
  3. ## You will see output like following
  4. ngrok by @inconshreveable (Ctrl+C to quit)
  5. Session Status online
  6. Session Expires 7 hours, 59 minutes
  7. Version 2.3.35
  8. Region United States (us)
  9. Web Interface http://127.0.0.1:4040
  10. Forwarding http://c1219f73.ngrok.io -> http://localhost:3000
  11. Forwarding https://c1219f73.ngrok.io -> http://localhost:3000
  12. Connections ttl opn rt1 rt5 p50 p90
  13. 0 0 0.00 0.00 0.00 0.00
  • Create Slash Command in Weather Slack App we created

    1. Go to Features -> Slash Commands -> Click on Create New Command
      Provide following details for new slash command:

      Command: /weather

      Request URL: https://c1219f73.ngrok.io/ (Note:Use your ngrok generated HTTPS URL)

      Short Description: Get current weather information by City or ZipCode

      Usage Hint: San Jose

    2. Go to slack and type /weather San Jose or /weather 95112 to see the magic:

Contact me on Twitter / GitHub