-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
16 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Viber builder | ||
|
||
## Install and Run | ||
|
||
Download this example or clone [bottender](https://github.com/Yoctol/bottender). | ||
|
||
``` | ||
curl https://codeload.github.com/Yoctol/bottender/tar.gz/master | tar -xz --strip=2 bottender-master/examples/viber-builder | ||
cd viber-builder | ||
npm install | ||
npm run dev | ||
``` | ||
|
||
## Idea of this example | ||
|
||
This example shows how to combine | ||
[handler](https://bottender.js.org/docs/APIReference-Handler) with | ||
[Viber](https://www.viber.com/) bot. You have to get `accessToken` before running this bot.\ | ||
For more information, check our [Viber guides](https://bottender.js.org/docs/Platforms-Viber). | ||
|
||
## Related examples | ||
|
||
* [viber-hello-world](../viber-hello-world) | ||
* [messenger-builder](../messenger-builder) | ||
* [line-builder](../line-builder) | ||
* [slack-builder](../slack-builder) | ||
* [telegram-builder](../telegram-builder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const { ViberBot, ViberHandler } = require('bottender'); | ||
const { createServer } = require('bottender/express'); | ||
|
||
const bot = new ViberBot({ | ||
accessToken: '__FILL_YOUR_TOKEN_HERE__', | ||
}); | ||
|
||
const handler = new ViberHandler() | ||
.onDelivered(() => { | ||
console.log('delivered'); | ||
}) | ||
.onSeen(() => { | ||
console.log('seen'); | ||
}) | ||
.onFailed(() => { | ||
console.log('failed'); | ||
}) | ||
.onText(/yo/i, async context => { | ||
await context.sendText('Hi there!'); | ||
}) | ||
.onEvent(async context => { | ||
await context.sendText("I don't know what you say."); | ||
}) | ||
.onError(async context => { | ||
await context.sendText('Something wrong happened.'); | ||
}); | ||
|
||
bot.onEvent(handler); | ||
|
||
const server = createServer(bot); | ||
server.listen(5000, () => { | ||
console.log('server is running on 5000 port...'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"dependencies": { | ||
"bottender": "latest" | ||
}, | ||
"devDependencies": { | ||
"nodemon": "^1.11.0" | ||
}, | ||
"scripts": { | ||
"dev": "nodemon index.js", | ||
"start": "node index.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Viber hello world | ||
|
||
## Install and Run | ||
|
||
Download this example or clone [bottender](https://github.com/Yoctol/bottender). | ||
|
||
``` | ||
curl https://codeload.github.com/Yoctol/bottender/tar.gz/master | tar -xz --strip=2 bottender-master/examples/viber-hello-world | ||
cd viber-hello-world | ||
npm install | ||
npm run dev | ||
``` | ||
|
||
## Idea of this example | ||
|
||
This example is a simple bot running on [Viber](https://www.viber.com/). | ||
You have to get `accessToken` before running this bot.\ | ||
For more information, check our [Viber guides](https://bottender.js.org/docs/Platforms-Viber). | ||
|
||
## Related examples | ||
|
||
* [viber-builder](../viber-builder) | ||
* [console-hello-world](../console-hello-world) | ||
* [messenger-hello-world](../messenger-hello-world) | ||
* [line-hello-world](../line-hello-world) | ||
* [slack-hello-world](../slack-hello-world) | ||
* [telegram-hello-world](../telegram-hello-world) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const { ViberBot } = require('bottender'); | ||
const { createServer } = require('bottender/express'); | ||
|
||
const bot = new ViberBot({ | ||
accessToken: '__FILL_YOUR_TOKEN_HERE__', | ||
}); | ||
|
||
bot.onEvent(async context => { | ||
if (context.event.isMessage) { | ||
await context.sendText('Hello World'); | ||
} | ||
}); | ||
|
||
const server = createServer(bot); | ||
|
||
server.listen(5000, () => { | ||
console.log('server is running on 5000 port...'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"dependencies": { | ||
"bottender": "latest" | ||
}, | ||
"devDependencies": { | ||
"nodemon": "^1.11.0" | ||
}, | ||
"scripts": { | ||
"dev": "nodemon index.js", | ||
"start": "node index.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters