Skip to content

Commit 92b679c

Browse files
committed
docs: add initial documentation
1 parent a964ebd commit 92b679c

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

examples/echo-bot-ts/README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# LINE Echo Bot with TypeScript
2+
3+
An example LINE bot to echo message with TypeScript. The bot is coded according to TypeScript's best practices.
4+
5+
## Installation
6+
7+
- Clone the repository.
8+
9+
```bash
10+
# To clone only this example.
11+
git clone https://github.com/lauslim12/line-bot-sdk-nodejs examples/echo-bot-ts
12+
13+
# Clone whole repository.
14+
git clone https://github.com/line/line-bot-sdk-nodejs.git
15+
```
16+
17+
- Install all dependencies.
18+
19+
```bash
20+
npm install
21+
```
22+
23+
- Configure all of the environment variables.
24+
25+
```bash
26+
export CHANNEL_ACCESS_TOKEN=<YOUR_CHANNEL_ACCESS_TOKEN>
27+
export CHANNEL_SECRET=<YOUR_CHANNEL_SECRET>
28+
export PORT=<YOUR_PORT>
29+
```
30+
31+
- Setup your webhook URL in your LINE Official Account to be in the following format. Don't forget to disable the greeting messages and auto-response messages for convenience.
32+
33+
```bash
34+
https://example-url.com/webhook
35+
```
36+
37+
- Compile the TypeScript files.
38+
39+
```bash
40+
npm run build
41+
```
42+
43+
- Run the application.
44+
45+
```bash
46+
npm start
47+
```
48+
49+
## Alternative Installation
50+
51+
If you want to deploy it via Heroku, it is also possible and is even easier for testing purposes.
52+
53+
- Clone the repository.
54+
55+
```bash
56+
git clone https://github.com/lauslim12/line-bot-sdk-nodejs examples/echo-bot-ts
57+
```
58+
59+
- Create a Heroku application.
60+
61+
```bash
62+
git init
63+
heroku create <YOUR_APP_NAME> # Do not specify for a random name
64+
```
65+
66+
- Setup the environment variables, and don't forget to setup your webhook URL (from the Heroku application that you have just created) in your LINE Offical Account. The webhook URL will still accept the following format: `https://example-url.com.herokuapp.com/webhook`.
67+
68+
```bash
69+
heroku config:set CHANNEL_ACCESS_TOKEN=YOUR_CHANNEL_ACCESS_TOKEN
70+
heroku config:set CHANNEL_SECRET=YOUR_CHANNEL_SECRET
71+
```
72+
73+
- Push the application to the server.
74+
75+
```bash
76+
git push heroku master
77+
```
78+
79+
- Open your application.
80+
81+
```bash
82+
heroku open
83+
```
84+
85+
- Done!

0 commit comments

Comments
 (0)