After creating your app, you need to add users who will be using the chat functionalities.
To add users from your backend, follow these steps:
appId
and apiToken
in base64.// Generate an authorization token in Node.js
const base64 = require('base-64');
const appId = 'your_app_id';
const apiToken = 'your_api_token';
const authToken = base64.encode(`${appId}:${apiToken}`);
console.log('Authorization Token:', authToken);
Include the authorization token in the request header as shown below:
// Example code for adding users in Node.js
const axios = require('axios');
const addUser = async () => {
const token = 'your_generated_token';
const appId = 'your_app_id';
const user = {
user_identifier: 'user@example.com',
first_name: 'First',
last_name: 'Last',
email: 'user@example.com',
phone: '1234567890'
};
try {
const response = await axios.post('https://lab.admin-api.mfereji.io/v1/users', {
app_id: appId,
users: [user]
}, {
headers: {
Authorization: `Bearer ${token}`
}
});
console.log('User added successfully:', response.data);
} catch (error) {
console.error('Error adding user:', error);
}
};
addUser();