Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Normalized code syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Swimm authored Apr 13, 2017
1 parent e23b761 commit 035644e
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions docs/readme-ciscospark.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ This will configure your bot to respond only to messages from members of the spe

The full code for a simple Cisco Spark bot is below:

```
~~~ javascript
var Botkit = require('./lib/Botkit.js');

var controller = Botkit.sparkbot({
Expand Down Expand Up @@ -87,7 +87,7 @@ controller.on('direct_mention', function(bot, message) {
controller.on('direct_message', function(bot, message) {
bot.reply(message, 'I got your private message. You said, "' + message.text + '"');
});
```
~~~

## Controller Options

Expand All @@ -103,7 +103,7 @@ When creating the Botkit controller, there are several platform-specific options
| `limit_to_org` | _optional_ organization id in which the bot should exist. If user from outside org sends message, it is ignored
| `limit_to_domain` | _optional_ email domain (@howdy.ai) or array of domains [@howdy.ai, @botkit.ai] from which messages can be received

```
~~~ javascript
var controller = Botkit.sparkbot({
debug: true,
log: true,
Expand All @@ -114,8 +114,7 @@ var controller = Botkit.sparkbot({
limit_to_org: 'my_spark_org_id',
limit_to_domain: ['@howdy.ai','@cisco.com'],
});
```

~~~

## Spark Specific Events

Expand All @@ -140,9 +139,9 @@ Cisco Spark supports both a `text` field and a `markdown` field for outbound mes

To specify a markdown version, add it to your message object:

```
~~~ javascript
bot.reply(message,{text: 'Hello', markdown: '*Hello!*'});
```
~~~

## Attaching Files

Expand All @@ -152,18 +151,18 @@ Files can be attached to outgoing messages in one of two ways.

If the file you wish to attach is already available online, simply specify the URL in the `files` field of the outgoing message:

```
~~~ javascript
bot.reply(message,{text:'Here is your file!', files:['http://myserver.com/file.pdf']});
```
~~~

*Send Local File*

If the file you wish to attach is present only on the local server, attach it to the message as a readable stream:

```
~~~ javascript
var fs = require('fs');
bot.reply(message,{text: 'I made this file for you.', files:[fs.createReadStream('./newfile.txt')]});
```
~~~

## Receiving files

Expand All @@ -179,7 +178,7 @@ Botkit provides 2 methods for retrieving information about the file.

The callback function will receive an object with fields like `filename`, `content-type`, and `content-length`.

```
~~~ javascript
controller.on('direct_message', function(bot, message) {
bot.reply(message, 'I got your private message. You said, "' + message.text + '"');
if (message.original_message.files) {
Expand All @@ -188,7 +187,7 @@ controller.on('direct_message', function(bot, message) {
});
}
});
```
~~~

### bot.retrieveFile(url, cb)
| Parameter | Description
Expand All @@ -198,7 +197,7 @@ controller.on('direct_message', function(bot, message) {

The callback function will receive the full content of the file.

```
~~~ javascript
controller.on('direct_message', function(bot, message) {
bot.reply(message, 'I got your private message. You said, "' + message.text + '"');
if (message.original_message.files) {
Expand All @@ -211,7 +210,7 @@ controller.on('direct_message', function(bot, message) {
});
}
});
```
~~~

## Starting Direct Messages

Expand All @@ -236,23 +235,23 @@ and will create a direct message thread with the sender of the incoming_message.
Use this function to send a direct message to a user by their personId, which
can be found in message and event payloads at the following location:

```
~~~ javascript
var personId = message.original_message.actorId;
```
~~~

### bot.startPrivateConversationWithActor())
| Parameter | Description
|--- |---
| incoming_message | a message or event that has an actorId defined in message.original_message.actorId
| cb | callback function in the form function(err, file_content)

```
~~~ javascript
controller.on('bot_space_join', function(bot, message) {
bot.startPrivateConversationWithActor(message, function(err, convo) {
convo.say('The bot you invited has joined the channel.');
});
});
```
~~~



Expand Down

0 comments on commit 035644e

Please sign in to comment.