Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
settings.json
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ A sample business system built with Meteor and the Smooch API.

3. Configure a webhook:

Configure a Smooch webhook to send appUser messages to your smoochDesk app at the "/hook" route
Configure a [Smooch webhook](https://app.smooch.io/integrations/webhook) to send "_All Triggers_" to your smoochDesk app at the "/hook" route

4. Configure your secret keys
4. Configure your secret keys and appToken

In _sever/messages.js_ add your Smooch keyId and secret
Using the _settings.json.example_ file as a guide, create a _settings.json_ file that contains your appToken, secret key, and key ID

5. Run it:

`meteor run`
`meteor --settings settings.json`

You can visit "/web-messenger" to send test messages as an end-user

## Based on Meteor Slack

Expand Down
1 change: 1 addition & 0 deletions client/main.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<head>
<script src="https://cdn.smooch.io/smooch.min.js"></script>
<link href='http://fonts.googleapis.com/css?family=Lato:400,700,900,400italic,700italic,900italic&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
</head>
3 changes: 3 additions & 0 deletions client/views/widget/widget.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template name="widget">
<script>Smooch.init({ appToken: Meteor.settings.public.smoochAppToken })</script>
</template>
13 changes: 9 additions & 4 deletions lib/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Router.map(function (){
path: '/channel/:_id'
});

this.route('widget', {
path: '/web-messenger'
});

this.route('hook', {
path: '/hook',
where: 'server',
Expand All @@ -23,11 +27,12 @@ Router.map(function (){

if(this.request.body.appUser) {
var appUser = this.request.body.appUser;
var channel = Channels.findOne({userId: appUser._id});
var name = appUser.givenName + " " + appUser.surname;
var channel = Channels.findOne({userId: appUser._id}) || {};
var name = this.request.body.messages[0].name;


if(!channel) {
channel = Channels.insert({name: name, userId: appUser._id});
if(!channel._id) {
channel._id = Channels.insert({name: name, userId: appUser._id});
}

if(this.request.body.messages) {
Expand Down
6 changes: 3 additions & 3 deletions server/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ var smooch = require('smooch-core');
//import { smooch } from 'smooch-core';

var SmoochBase = new smooch({
keyId: 'app_582d3ffb5e1e583300447d8c',
secret: 'NGKMzMLhmsP3VxRr33mVHpMa',
scope: 'app', // app or appUser
keyId: Meteor.settings.smoochKeyId,
secret: Meteor.settings.smoochSecret,
scope: 'app',
})

Meteor.methods({
Expand Down
5 changes: 5 additions & 0 deletions settings.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"smoochKeyId": "your_key_id",
"smoochSecret": "your_secret",
"smoochAppToken": "your_apptoken"
}