📖 Help Docs
🆕ChatDaddy App Updates (Release Notes)
📞 Contact Us
⚖️Scaling with ChatDaddy
ChatDaddy allows users to build scalable tools for businesses to empower their users to communicate via WhatsApp at the cheapest rates starting at just 1 USD/mo! For businesses to offer great services at affordable rates, they’d need access to an API that enables them to quickly add/remove users based on the requirements for each individual user.
For example, some users of your product may not require chat history and only send 500 messages a month whereas others send over 10000 messages a month!
This guide covers how to build a scalable platform using ChatDaddy’s APIs, that accommodates the usage of individual users. This is of course, in addition to all the features you get with the API, such as:
- Scaling without worrying about servers
- Generating “notes” in chats — notes are messages that never get sent to the other person in the chat
- Message queue that only allows a single message out at a time to prevent spam
- And so much more!
Before you can start building your scalable platform with the API, let’s get you access to the full platform
- Register for a ChatDaddy account if you haven’t already from https://app.chatdaddy.tech/SignUp
- Open ChatDaddy
- navigate to settings
- and then to billing
- or visit using (https://app.chatdaddy.tech/settings/billing)
- Click the “Upgrade Subscription” button
- Purchase the “API” plan
- Continue to payment
- Enter your card details & finish the purchase
- You should be redirected back to ChatDaddy & see a “Successful Purchase” popup
- Refresh the page now and verify that you the newly purchased plan in the billing section like the image below
- Superb! Now that you’ve full access to the platform, let’s get started with the API. We’d recommend using our typescript/javascript client to interact with our instant messaging service or if you choose, you could write your own REST client as well.
- typescript client:
- API docs: Stoplight
- Let’s setup a project to use API client now:
- We hope you have NodeJS tooling installed. If not, refer here
- Create a new project using NPM (you can use
yarn
too if you’d like) vianpm init
- Add our API client to your project:
npm i git+https://github.com/chatdaddy/typescript-client.git
- Create an empty file called
src/index.js
- You can choose to use typescript as well, but for this example — we’ll just use plain JavaScript
- Let’s authenticate
- Inside
index.js
— add the following snippet that’ll allow us to authenticate our requests - If you don’t have a refresh token or don’t know your team ID, you can find it easily on the ChatDaddy web app: https://app.chatdaddy.tech/settings/api
- Now, let’s purchase & add your first user’s account (note: this step will create a 1USD charge on your account)
- We’ll use the
AccountApi
from the instant messaging service to purchase & add this account: - Voila! You should now have another account in your team that you can assign to any one of your users!
- You can repeat this process as many times to scale as your user base grows!
- Impressed as you may be now, you likely have two questions now:
- If my user requires higher limits or needs chat history, how do I upgrade the ChatDaddy account?
- If my user unsubscribes, how will I unsubscribe the specific ChatDaddy account?
- First, let’s see how you can unsubscribe the account. We offer two ways:
- You can delete the account, removing all user data & cancelling the subscription in the process, with a simple API request:
- You can “archive” the account, this will cancel your subscription for this account — logout the user from account, remove all synced data (will however, keep all notes & contacts)
- Second, let’s see how you can upgrade/downgrade accounts:
- With one super simple API call, you can update the account’s tier
- If you try to change the tier of an account when it’s already at the same tier — the request will fail with a 400 Bad Request status code
- Policy on downgrading:
- When downgrading to a tier without chat history — all the chats, messages received at the time of login (scanning QR) will be removed
- If they choose to upgrade then, the user will have to re-scan the code to re-sync the history
- If they have crossed the 1000 message threshold — they will not be able to send any more messages till they upgrade or their usage gets reset at the start of the next billing period
- There we go, you’re now fully equipped to build a platform that can quickly & cheaply scale with your user base!
- You can also find our API pricing below:
For this guide, we’ll be using the typescript client from GitHub.
import { verifyToken, makeAccessTokenFactory, JWT, Scope } from '@chatdaddy/client'
const REFRESH_TOKEN = 'put-your-refresh-token-here'
const TEAM_ID = 'put-team-id'
// the access token factory fetches access tokens as you'd need them
// using your refresh token, so that you can easily make requests to our services
// without worrying about expired credentials or over-fetching access tokens
const getAccessToken = makeAccessTokenFactory({
request: { refreshToken: REFRESH_TOKEN }
})
import { AccountApi, AccountTier, AccountType, Configuration } from '@chatdaddy/client'
(async() => {
const { token: accessToken } = await getAccessToken(TEAM_ID)
const accountsApi = new AccountApi(new Configuration({ accessToken }))
const { data } = await accountsApi.accountsPost({
accountsPostRequest: {
// just a nickname -- does not need to be unique
// this is just for display purposes
nickname: 'My New Account',
// change the tier to upgrade/downgrade functionality
// this one gives only limited messages, and syncs no chat history
tier: AccountTier.LimitedMsgNoChatHistory,
type: AccountType.Wa
}
})
console.log(`purchases & created a new account with ID: "${data.accountId}"!`)
})()
We’ll tackle both now.
// account ID => the ID of the account you want to delete
await accountsApi.accountsDelete({ accountId })
// account ID => the ID of the account to archive
await accountsApi.accountsArchive({ accountId })
// upgrades the tier to "unlimited messages & chat history"
await accountsApi.accountsPatch({
accountId,
accountsPatchRequest: { tier: AccountTier.UnlimitedMsgChatHistory }
})
The account usage is billed by day. That is, you will be billed for the number of accounts used each day. For example, if you create an account today, and delete it 15 days later you’d be charged for only the 15 days.
Note: the creation of the account also incurs a charge equivalent to the cost of the tier of the account you create. For example, if you choose to create an unlimited_msg_chat_history
account & you have — you will be charged 0.4USD
Billed monthly:
Feature: unlimited sending out of messages, chat history sync (100K messages will be synced at most from this history)
API Tier: unlimited_msg_chat_history
Number of account-days | Price per account per day | Price per account |
1 - 3000 | 0.4USD | 12 USD/mo |
3001 - 15000 | 0.33USD | 10 USD/mo |
15001 - 30000 | 0.27USD | 8 USD/mo |
30001 - 150000 | 0.24USD | 7 USD/mo |
150000 + | 0.2USD | 6 USD/mo |
Note: the billing above is graduated, which means if you have 101 accounts & you use them for the full month you would pay (100 x 30 x 0.4 USD + 1 x 30 x 0.33 USD = 1209.9USD)
Feature: unlimited sending out of messages, no chat history sync
API Tier: unlimited_msg_no_chat_history
Number of account-days | Price per account per day | Price |
1 - 3000 | 0.3USD | 9 USD/mo |
3001 - 15000 | 0.27USD | 8 USD/mo |
15001 - 30000 | 0.24USD | 7 USD/mo |
30001 - 150000 | 0.2USD | 6 USD/mo |
150000 + | 0.15USD | 4.5 USD/mo |
Feature: 1000 messages per month, no chat history sync
API Tier: limited_msg_no_chat_history
Number of account-days | Price per account per day | Price |
1 - | 0.034USD | 1 USD/mo |