smooch-core

8.11.4 • Public • Published

Smooch Core

Smooch Core is the most basic for interaction possible for the Smooch API. It wraps the public API in a convenient Javascript API.

This library is meant to be used server-side with Node.js.

Installation

$ npm install smooch-core --save

Contributing

If a method is missing please file an Issue, or better yet make a PR!

Smooch API Version

The Smooch API offers multiple versions. Each release of this project targets one and only one Smooch API version. If you depend on an older version of the Smooch API, you may need to use an older release of this library. Use the table below as your guide:

Smooch API version smooch-core version to use
v1.1 Upgrade guide 8.0.0 or newer
v1 7.* or older

Usage

var SmoochCore = require('smooch-core');

// using generated JWT
var smooch = new SmoochCore({
    jwt: 'some-jwt'
});

// using JWT components
var smooch = new SmoochCore({
    keyId: 'some-key',
    secret: 'some-secret',
    scope: 'appUser', // account, app, or appUser
    userId: 'some-id' // only required for appUser scope
});

// ...

smooch.webhooks.get(id).then(function(response) {
    // do something with the response.
});

Usage with a proxy

If you need to use a proxy, you can use one of the many proxies available, as long as it an http.Agent implementation. You only need to pass the agent when creating the SmoochCore instance.

var SmoochCore = require('smooch-core');
var SocksProxyAgent = require('socks-proxy-agent');
var proxy = process.env.http_proxy || 'socks://localhost:8123';
var agent = new SocksProxyAgent(proxy);

var smooch = new SmoochCore({
    keyId: 'some-key',
    secret: 'some-secret',
    httpAgent: agent
});

Testing new additions

If you've just added some new APIs and would like to test them locally before pushing your changes, do the following.

  1. npm run build
  2. Create a simple Node.js script
  3. Import the built SDK
  4. Test it

Example:

const Smooch = require('../smooch-core-js-private/lib/smooch');

const smooch = new Smooch({
    keyId: '<redacted>',
    secret: '<redacted>',
    scope: 'account'
});

(async () => {
    console.log(await smooch.apps.list());
})();

API

Below is a list of methods included in Smooch Core. For comprehensive documentation of Smooch Core and its methods see Smooch's REST API docs.

For more detailed information and example usage of each of the following methods, click on the method's 🔗 icon.

Method Description Link
appUsers Module
appUsers.get Get a specific appUser. 🔗
appUsers.update Update an appUser’s basic profile information and specify custom profile data. 🔗
appUsers.delete Delete an appUser. 🔗
appUsers.deleteProfile Delete an appUser’s profile. 🔗
appUsers.create Pre-create an appUser object before that appUser runs your app for the first time. 🔗
appUsers.linkChannel Link appUser to continue conversation on his/her preferred channel. 🔗
appUsers.unlinkChannel Remove the specified channel from the appUser’s clients. 🔗
appUsers.getMessages Get the specified appUser’s conversation history. 🔗
appUsers.resetUnreadCount Reset the unread count of the conversation to 0. 🔗
appUsers.typingActivity Notify Smooch when an app maker starts or stops typing a response. 🔗
appUsers.sendMessage Post a message to or from the appUser. 🔗
appUsers.deleteMessage Delete a single message. 🔗
appUsers.deleteMessages Clears the message history for an appUser, permanently deleting all messages. 🔗
appUsers.getChannels Get all of the appUser’s channel entity Ids. 🔗
appUsers.getBusinessSystems Get all the business systems to which an appUser’s conversation is connected. 🔗
appUsers.getAuthCode Get auth code. 🔗
appUsers.getLinkRequests Generate a transfer URL for a given channel type. 🔗
appUsers.mergeUsers Force the merge of two specific users, when the business has determined that they represent the same person 🔗
menu Module
menu.get Get the specified app’s menu. 🔗
menu.configure Configure the specified app’s menu. 🔗
menu.remove Remove the specified app’s menu. 🔗
webhooks Module
webhooks.list List all webhooks configured for a given app. 🔗
webhooks.create Create a webhook for the specified app. 🔗
webhooks.get Get individual webhooks. 🔗
webhooks.update Update existing webhooks. 🔗
webhooks.delete Delete specified webhook. 🔗
apps Module
apps.create Create a new app. 🔗
apps.list List all configured apps. 🔗
apps.get Get the specified app. 🔗
apps.delete Delete the specified app, including all its enabled integrations. 🔗
apps.getSdkIds Retrieve the IDs of the three SDK integrations (android, ios, and web) for the specified app, to be used when initializing the SDKs. 🔗
apps.keys.create Create a secret key for the specified app. 🔗
apps.keys.list List all secret keys for the sepcified app. 🔗
apps.keys.get Get a secret key. 🔗
apps.keys.delete Delete a secret key. 🔗
apps.keys.getJwt Get an app-scoped JWT signed using the requested keyId/secret pair. 🔗
integrations Module
integrations.create Create a new integration. 🔗
integrations.list List all integrations for a given app. 🔗
integrations.get Return the specified integration. 🔗
integrations.update Update the specified integration. 🔗
integrations.delete Delete the specified integration. 🔗
integrations.menu.get Get the specified integration’s menu. 🔗
integrations.menu.update Update the specified integration’s menu. 🔗
integrations.menu.delete Delete the specified integration's menu. 🔗
integrations.messageTemplates.create Create a message template for the specified WhatsApp integration. 🔗
integrations.messageTemplates.list List message templates for the specified WhatsApp integration. 🔗
integrations.messageTemplates.delete Delete a message template for the specified WhatsApp integration. 🔗
integrations.profile.get Get the specified integration’s profile. 🔗
integrations.profile.update Update the specified integration’s profile. 🔗
integrations.profile.photo.upload Upload a photo to be used for the the specified integration’s profile. 🔗
deployments Module
deployments.create Create a new deployment. 🔗
deployments.activate Activate the phone number of the deployment. 🔗
deployments.confirmCode Confirm the phone number of the deployment. 🔗
deployments.get Return the specified deployment. 🔗
deployments.list List all configured deployments. 🔗
deployments.delete Delete the specified deployment. 🔗
serviceAccounts Module
serviceAccounts.create Create a new service account. 🔗
serviceAccounts.list List all service accounts. 🔗
serviceAccounts.get Get the specified service account. 🔗
serviceAccounts.delete Delete the specified service account. 🔗
serviceAccounts.keys.create Create a secret key for the specified service account. 🔗
serviceAccounts.keys.list List all secret keys for the specified service account. 🔗
serviceAccounts.keys.get Get a specified secret key for the specified service account. 🔗
serviceAccounts.keys.delete Delete a specified secret key for the specified service account. 🔗
serviceAccounts.keys.getJwt Get an account-scoped JWT signed using the requested keyId/secret pair. 🔗
attachments Module
attachments.create Upload an attachment to Smooch to use in future messages. 🔗
attachments.delete Remove an attachment uploaded to Smooch 🔗
templates Module
templates.create Create a new template. 🔗
templates.list List all templates for a given app. 🔗
templates.get Return the specified template. 🔗
templates.update Update the specified template. 🔗
templates.delete Delete the specified template. 🔗
notifications Module
notifications.postNotification Send a notification. 🔗

Deployment

Deployment is automated. When you merge to master, the current version in package.json will be automatically released to the public and published on npm.

Steps:

  • Update the version
    • npm version major|minor|patch
  • PR to master
  • Merge

Copyright and license

Copyright 2018 Zendesk, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Readme

Keywords

none

Package Sidebar

Install

npm i smooch-core

Homepage

smooch.io

Weekly Downloads

1,661

Version

8.11.4

License

Apache-2.0

Unpacked Size

303 kB

Total Files

70

Last publish

Collaborators

  • alavers
  • lemieux
  • jugarrit
  • smoochlabs