GoodChat API is a standalone node.js web service allowing easy integration with smooch.io
The main purpose of Goodchat's is to integrate multiple chat channels to the GoodCity Project, allowing people to donate goods directly via their existing channels.
That said, GoodChat was designed as a generic and reusable product and therefore holds no shared business logic with the GoodCity. We intend this project, and therefore the code to be:
The code-generated documentation can be accessed here
You can re-generate the documentation using the following npm script:
$> npm run document
Updating the README table of contents:
$> npm run doctoc
NPM 7 or above is required in order to handle peer-dependencies of the apollo server. An older version of NPM can be used but it may require you to install some modules manually
Install the node dependencies using
$> npm install
Running GoodChat requires the following Sunshine Conversation credentials:
Create new app
buttonSettings
Create new API key
action for a new oneYou may create an instance of GoodChat, and start it manually as shown below
import goodchat, { GoodChatAuthMode } from '@goodcity/api.goodchat'
const [app] = await goodchat({
smoochAppId: 'sample_app_id',
smoochApiKeyId: 'sample_api_key_id',
smoochApiKeySecret: 'sample_api_key_secret',
goodchatHost: 'localhost:8000',
auth: {
mode: GoodChatAuthMode.NONE
}
})
app.listen(8000, () => {
console.info('Goodchat is running');
})
An pre-written startup script exists under the /bin
folder to run the server. It can be used easily thanks to the following npm scripts:
Build the project
$> npm run build
Run it
$> npm run start
$> npm run dev
When running the server in a development environment (NODE_ENV=development), the startup script will initiate an ngrok tunnel in order to have callable webhooks.
When running the server from an NPM script, the server can be configured using the following environment variables
NODE_ENV
- defines the environment it's running on. Options:production
staging
development
(default)NO_AUTH
- if set to "true" or "yes", will no support any form of authentication (good for testing)Here's an example query to get you started
query Conversations {
conversations {
id
type
messages {
id
content
}
}
}
Goodchat specs are written using Mocha, they are all located under the spec/
folder.
Run the specs using the following command:
$> npm run test
Please refer to the Pristma Migrate Flow
A set of npm scripts are available for the common actions:
db:migrate:new
Creates a new migration (without applying it)db:migrate:dev
Applies migrations to the dev environmentdb:migrate:prod
Applies migrations on production (to be used in CD)This mode is present for development/testing purposes
Copyright © 2020 by Crossroads Foundation Ltd
All rights reserved. No part of this software may be reproduced, distributed, or transmitted in any form or by any means, including photocopying, recording, or other electronic or mechanical methods, without the prior written permission of Crossroads Foundation Ltd. For permission requests, write to Crossroads Foundation Ltd., addressed “Attention: CTO” using the general contact details found on www.crossroads.org.hk.
Generated using TypeDoc