You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _posts/2016-06-17-claudia-bot-builder.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ Let's rebuild that now. Step by step.
33
33
We're going to follow the instructions from the [Getting Started guide](https://github.com/claudiajs/claudia-bot-builder/blob/master/GETTING_STARTED.md) of the Claudia-bot-builder repository. There's some short administration first;
34
34
35
35
* Install [nvm](https://github.com/creationix/nvm) or something similar so that you can `nvm install v4.3.2` that Claudia-bot-builder requires (and AWS now supports)
36
-
*Intall ClaudiaJs globally (if you want to) for that version of Node `npm install claudia -g` or update it if it's already installed `npm update claudia -g`
36
+
*Install ClaudiaJs globally (if you want to) for that version of Node `npm install claudia -g` or update it if it's already installed `npm update claudia -g`
37
37
* Set up an [AWS Account](https://www.marcusoft.net/2016/02/first-aws-lamda-steps.html#setting-up-your-environment) - yeah that's troublesome, but a one time thing. Hang in there.
return`Pinged ${url} successfully - took ${end} ms`;
62
62
}).catch(function(err) {
63
-
return`Could not ping ${url} (${err.message})`;
63
+
return`Could not ping ${url} (${err.message})`;
64
64
});
65
65
});
66
66
```
67
67
68
-
The `claudia-bot-builder` gives us a simple construct that receives the `request` object as single inparameter. From that we can read the `request.text` property which contains the text that the user sends us. In our case we will use a [Slack Slash Command](https://api.slack.com/) like this: `/pingu https://www.marcusoft.net`, and in that case `request.text` will be `https://www.marcusoft.net`.
68
+
The `claudia-bot-builder` gives us a simple construct that receives the `request` object as single in-parameter. From that we can read the `request.text` property which contains the text that the user sends us. In our case we will use a [Slack Slash Command](https://api.slack.com/) like this: `/pingu https://www.marcusoft.net`, and in that case `request.text` will be `https://www.marcusoft.net`.
69
69
70
70
I'm using the [co-request](https://www.npmjs.com/package/co-request) module as to do simple http request, co-request allows me to use `yield` rather than the callback horrors that I've come to hate.
71
71
72
72
There's some simple error handling in there as well. Good enough for now.
73
73
74
74
To get all the dependencies we need into our application, and more importantly into the `package.json`, we can use this command:
75
75
76
-
```
76
+
```bash
77
77
npm install claudia-bot-builder co co-request -S
78
78
```
79
79
@@ -83,7 +83,7 @@ That's the hard part done.
83
83
84
84
Now for the part where Claudia excels. Deploying this is super simple:
@@ -133,10 +133,10 @@ Create a `testdata/basictest.json` file containing the following:
133
133
134
134
```json
135
135
{
136
-
"context" : {
137
-
"path" : "/",
138
-
"method" : "GET"
139
-
}
136
+
"context" : {
137
+
"path" : "/",
138
+
"method" : "GET"
139
+
}
140
140
}
141
141
```
142
142
@@ -155,7 +155,7 @@ From this part on it's just following the wizard. Here's a few pointers:
155
155
156
156
So that's `https://vozc2ng03h.execute-api.us-east-1.amazonaws.com/latest/slack/slash-command` in my case
157
157
* I left method as POST
158
-
* I customised the name to be `pingu`
158
+
* I customized the name to be `pingu`
159
159
* I uploaded a, most likely trademark violated, picture for my command
160
160
* Finally I added a nice description and a usage hint
161
161
@@ -184,7 +184,7 @@ Better yet... use [Claudia Bot Builder](https://www.npmjs.com/package/claudia-bo
184
184
185
185
`claudia update --configure-slack-slash-command` for slash-commands for only your team (that's what this article is about.). And use `claudia update --configure-slack-slash-app` for Slack applications.
186
186
187
-
## Test!
187
+
## Test
188
188
189
189
Once all of that is done you can now go to the Slack group for which you installed the command and run your beauty.
190
190
@@ -200,4 +200,4 @@ A testimony to see this quick turnaround in action would be to change the comman
200
200
201
201
It just works.
202
202
203
-
My code can be [found here](https://github.com/marcusoftnet/pingu).
203
+
My code can be [found here](https://github.com/marcusoftnet/pingu).
0 commit comments