Code Monkey home page Code Monkey logo

announcer's Introduction

Announcer Backend (AB) 🔈

License: MIT

AB would provide Flex Message template and LINE bot feature.

  • Type any text to trigger bot for send Announcer template.
  • About GA feature, please follow this article.

Add friends

加入好友

QRcode

Environment

  • Express / nodejs v12.18
  • TypeScript

Heroku

You can test this project on Heroku.

Deploy

Use following up commands to check machine:

heroku run bash -a YOUR_HEROKU_NAME
heroku logs --tail -a YOUR_HEROKU_NAME

LIFF

  • Login LINE Developer Console.
  • Create a LINE Login channel.
  • Input channel information.
  • Click LIFF tab and add LIFF application.
  • Copy LIFF ID to environment CONCAT_ID variable.

Messaging API

  • Login LINE Developer Console.
  • Create a Messaging API channel.
  • Input channel information.
  • Copy Channel secret and Channel access token to environment CHANNEL_ACCESS_TOKEN and CHANNEL_SECRET variables.

Local test with Chatbot & API

1. first terminal window

cp .env.sample .env
npm install
npm run dev

2. Create a provisional https:

npx ngrok http 5000

3. Copy url to Messaging API and LIFF endpoint url.

LINE Bot

You can go to LINE Developer Console to change LINE Bot webhook url.

If you used channel_access_toen and channel_secret in .env file.

You can use change_bot_url.sh to change temp webhook url.

sh change_bot_url.sh 57G...YOUR_ACCESS_TOKEN...vw= https://{YOUR_DOMAIN}/webhooks/line

will see following log:

--------------------------

{}

--------------------------

{"endpoint":"https://{YOUR_DOMAIN}/webhooks/line","active":true}
-------------------------
  • {}: if empty, means success.

4. Use following command before deploy:

npm run dev

This command will compile TypeScript to JavaScript file in dist/.

5. Local Unit/Integration Test

If you use .env to develop this project(contain LINE Bot token), can use following command:

npm run test
  • If you installed act locally, run act to check GitHub Actions status.

Template Schema

API ➡️ /liff/share

Template 1 - Announcement

type announcement = {
    template: '1',
    title: 'Title',
    place: 'location',
    time: '12/26 15:00',
    url: 'HTTP string',
    imageUrl: 'HTTP string',
    description: 'aaa\nbbb\nccc',
    activity: 'some tag',
};

Template 2 - Staff List

type staffList = {
  template: '2',
  title: 'title',
  place: 'here',
  url: 'HTTP link',
  activity: 'tag',
  map: 'Google Map link',
  people: [{name: 'NiJia', time: '10:00~12:00'}],
};

Template 3 - Card

type Card = {
  template: '2',
  title: 'title',
  description: 'aaa\nbbb',
  avatar: 'HTTP link',
  back: 'HTTP image background link',
  followUrl: 'HTTP link',
};

Template 4 - News

type News = {
  image: string;
  date: string;
  description: string;
  link: string;
  tag: string;
  targetPicker?: string;
}

Response

Above template would response following type:

type FlexResponse = {
  flex: string;
};

License

MIT License

announcer's People

Contributors

louis70109 avatar

Watchers

 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.