From 75555000f6cdd1fb7a4e0676681edeb68b5bd169 Mon Sep 17 00:00:00 2001 From: Josue Galindo Date: Thu, 29 Oct 2020 13:22:10 +0100 Subject: [PATCH 1/2] v1.0.1 Updated dependencies and Readme --- .env.sample | 3 +++ CHANGELOG.md | 4 ++++ README.md | 47 +++++++++++++++++++++++++++------------- package-lock.json | 55 ++++++++++++++++------------------------------- package.json | 2 +- 5 files changed, 59 insertions(+), 52 deletions(-) create mode 100644 .env.sample create mode 100644 CHANGELOG.md diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..97ef7db --- /dev/null +++ b/.env.sample @@ -0,0 +1,3 @@ +TENEO_ENGINE_URL= +CHANNEL_SECRET= YourLineProviderName -> BasicSettings -> ChannelSecret > +CHANNEL_ACCESS_TOKEN= YourLineProviderName -> MessagingAPI -> ChannelAccessTopic > diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..91ac49a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +# v.1.0.1 +## 29/10/2020 +1. [](#improved) + * Updated dependencies and README.md diff --git a/README.md b/README.md index 2c93be9..7df02b0 100644 --- a/README.md +++ b/README.md @@ -14,17 +14,14 @@ Your bot needs to be published and you need to know the engine URL. ## Setup instructions -### Create and configure a Line Provider +### Create a Line Provider 1. Log in with your LINE account here: [https://developers.line.biz/en/](https://developers.line.biz/en/). Use a QR Code or an email address. You may need to complete your developer profile after you've logged in. 2. Click on Create New Provider, and give it a name. 3. Now, create a Messaging API Channel, and fill in the necessary fields: description, icon, category, etc. 4. Open the newly created channel, find and copy the CHANNEL_SECRET value for later use. -5. Scroll down on the page and issue a CHANNEL_ACCESS_TOKEN (set expiration time to 0 hours for now, so the token doesn't expire), and copy that value too. -6. Go to the 'Use Webhooks' section, and set it to 'Enabled'. You will be setting the 'Webhook_URL' after the next steps. -7. Next, scroll down to the 'Using LINE features' section and disable 'Auto-reply messages' by clicking the 'Set message' link. - ### Running the connector locally +#### Setup the connector 1. Download or clone the connector source code: ``` git clone https://github.com/artificialsolutions/tie-api-example-line.git @@ -33,34 +30,54 @@ Your bot needs to be published and you need to know the engine URL. ``` npm install ``` -3. Create a `.env` file in the folder where you stored the source, and add values for TENEO_ENGINE_URL, CHANNEL_SECRET, and CHANNEL_ACCESS_TOKEN: +3. A file .env.sample file is included in the project. Use it as a reference to create a `.env` file in the folder where you stored the source, and add values for CHANNEL_SECRET and TENEO_ENGINE_URL. CHANNEL_ACCESS_TOKEN will be set later on. ``` TENEO_ENGINE_URL= CHANNEL_SECRET= - CHANNEL_ACCESS_TOKEN= + CHANNEL_ACCESS_TOKEN= ``` 4. Start the connector in Console: ``` node server.js ``` -Next, we need to make the connector available via https. We'll use [ngrok](https://ngrok.com) for this. +#### Make the connector available via HTTPS +1. Next, we need to make the connector available via https. We'll use [ngrok](https://ngrok.com) for this. -1. Start ngrok. The connector runs on port 3000 by default, so we need to start ngrok like this: +2. Start ngrok - The connector runs on port 3000 by default, so we need to start ngrok like this: ``` ngrok http 3000 ``` -2. Running the command above will display a public https URL. Copy it, you will need it in the next section. +3. Running the command above will display a public https URL. Copy it, you will need it in the next section. -### Update Webhook URL in the line provider -1. Once the connector is available via https, copy the public https URL from the previous step andp paste in into the Webhook URL of your Line Channel provider. Also, add a /callback suffix to the URL field. The final Webhook URL should look roughly like this: +#### Update Webhook URL in the Line Provider +1. Next, in the 'LINE Official Account Features' section > 'Auto-reply messages', click on 'Edit'. +2. Set 'Response mode' to Bot. Disable 'Auto-Response' and 'Greeting Message'. +Set 'Webhooks' to Enabled. +3. Go back to 'Messaging API' > 'Webhook Settings' and set 'Webhook URL' by using the public https URL obtained from ngrok in the previous step, and attaching the suffix '/callback'. The URL will look roughly like this: + ``` + https://12345abcde.ngrok.io/callback ``` - https://7a6e4de6.ngrok.io/callback + +4. Click 'Verify' and also Enable 'Use Webhook'. + +5. Browse to 'Message API' > Channel Access Token. Click issue, and copy the 'Channel Access Token' value for later use. +It is very important to note that this token must be re-issued everytime the Webhook URL is changed, to prevent authentication errors. + +#### Update and restart the Connector +1. Finally, update the CHANNEL_ACCESS_TOKEN variable in .env file of your project source with the 'Channel Access Token' value obtained in the previous step: + +TENEO_ENGINE_URL=< your_engine_url > +CHANNEL_SECRET=< The value obtained in previous steps> +CHANNEL_ACCESS_TOKEN=< 'Channel Access Token', from the previous step > + +2. Restart the connector in Console: + ``` + node server.js ``` -2. Click the blue 'Update' button to save the url. ### Start chatting with the bot. -Go back to the Channel settings of your Provider, and scroll down to the QR code shown in the bots section. Use it to add your bot as a new contact to your LINE app. +Go back to the Basic Settings section of your Provider, and locate the QR code shown in the bots section. Use it to add your bot as a new contact to your LINE app. That's it! Your bot should now be available in LINE and responding to messages that are sent to it. diff --git a/package-lock.json b/package-lock.json index 191d6b0..23fbfe9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,12 +5,12 @@ "requires": true, "dependencies": { "@artificialsolutions/tie-api-client": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@artificialsolutions/tie-api-client/-/tie-api-client-1.3.1.tgz", - "integrity": "sha512-lmUtspoFxgIvOUB51yW2ml9Ej2mlwiRCVTctHoaRzCTplIgs46Pi3cW+LBs6XSGgHGKjysX4uTZQRpkLhGYA5w==", + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/@artificialsolutions/tie-api-client/-/tie-api-client-1.3.7.tgz", + "integrity": "sha512-ve1YifLfpWnFU21TsQyJ5xY1XAs2avq8sZ5KzHR0BPXGUpnWvhvUCF/MEr6c/nBGfoXZyeDyx2GRPeV4uJILDA==", "requires": { - "es6-promise": "^4.2.5", - "isomorphic-fetch": "^2.2.1" + "es6-promise": "^4.2.8", + "isomorphic-fetch": "^3.0.0" } }, "@line/bot-sdk": { @@ -180,18 +180,10 @@ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" }, - "encoding": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", - "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", - "requires": { - "iconv-lite": "~0.4.13" - } - }, "es6-promise": { - "version": "4.2.6", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz", - "integrity": "sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q==" + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" }, "escape-html": { "version": "1.0.3", @@ -347,18 +339,13 @@ "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==" }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" - }, "isomorphic-fetch": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", - "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-3.0.0.tgz", + "integrity": "sha512-qvUtwJ3j6qwsF3jLxkZ72qCgjMysPzDfeV240JHiGZsANBYd+EEuu35v7dfrJ9Up0Ak07D7GGSkGhCHTqg/5wA==", "requires": { - "node-fetch": "^1.0.1", - "whatwg-fetch": ">=0.10.0" + "node-fetch": "^2.6.1", + "whatwg-fetch": "^3.4.1" } }, "media-typer": { @@ -405,13 +392,9 @@ "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" }, "node-fetch": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", - "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", - "requires": { - "encoding": "^0.1.11", - "is-stream": "^1.0.1" - } + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" }, "on-finished": { "version": "2.3.0", @@ -559,9 +542,9 @@ "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" }, "whatwg-fetch": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", - "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.4.1.tgz", + "integrity": "sha512-sofZVzE1wKwO+EYPbWfiwzaKovWiZXf4coEzjGP9b2GBVgQRLQUZ2QcuPpQExGDAW5GItpEm6Tl4OU5mywnAoQ==" } } } diff --git a/package.json b/package.json index 30779f9..2012a51 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "url": "https://github.com/artificialsolutions/tie-api-example-line" }, "dependencies": { - "@artificialsolutions/tie-api-client": "^1.3.1", + "@artificialsolutions/tie-api-client": "^1.3.7", "@line/bot-sdk": "^6.8.0", "express": "^4.16.3", "http": "0.0.0" From b5ceb590e5b44b12f9e6df29bb8a11ef0f49aaf0 Mon Sep 17 00:00:00 2001 From: Josue Galindo Date: Thu, 29 Oct 2020 13:23:15 +0100 Subject: [PATCH 2/2] Update v1.0.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 23fbfe9..2d608d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "line-teneo-connector", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2012a51..46de2e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "line-teneo-connector", - "version": "1.0.0", + "version": "1.0.1", "description": "A basic example using Teneo and Line", "main": "server.js", "scripts": {