klink.cloud - Product User Manual
  • Overview
    • 👋Welcome to klink.cloud
  • Getting Started
    • 🟦Setup Channels
      • Facebook Messenger
        • Connect to Facebook Messenger
        • Primary Routing Setup (Facebook & Instagram)
      • Facebook Feed
        • Connect to Facebook Feed
        • Primary Routing Setup (Facebook & Instagram)
      • LINE OA
        • Get Channel Secret and Channel Access Token
        • Connect to LINE OA
      • Instagram
      • Viber for Business
      • Google Workspace Email Setup
      • How to Setup Telegram Bot Channel
      • How to setup Telegram Business Account
      • How to set up WhatsApp Business Channel (Meta)
      • How to set up WhatsApp Mobile Channel
  • How to use
    • 📞Call
      • Inbound Call Handling
      • Outbound Call Handling
    • 💬Chat
      • Inbound Chat Handling
      • Outbound Chat Handling
      • Facebook Feed Handling
    • 🔖Tickets
      • Create a Ticket
      • Assign / Transfer Ticket
    • 📇Contact
      • How to Import Leads / Contacts
      • Contact Custom Fields
      • Individual Contacts
      • Company Contacts
      • Import / Export CSV
  • Advanced Setup
    • Setup Workflow Automation
    • Setup Queue Group
    • 🕖Setup SLA Targets
    • Setup Queue, Workflow, and SLA
  • Dashboard & Reports
    • 📊Reporting
      • CDR
      • Recording
      • Call Reports
        • Agent Call Statistics
        • Agent Call Activity
        • Trunk Activity
        • Queue AVG Waiting & Talking Time
        • Queue Performance
        • Agent Missed Call Activity
        • Agent Call Summary
        • Satisfaction Survey
      • Agent Status Report
      • CX Log
    • 📉Analytics Dashboard
      • 📶Call Dashboard
      • 📈Chat Dashboard
      • 💎Ticket Dashboard
  • Integrations
    • 🛒Ecommerce Marketplace
      • Shopee Integrations
      • Lazada Integrations
    • 🔈CRM Integrations
      • Salesforce CRM Integration
      • How to create Viber Messaging API Application
      • How to send transactional Viber Business Message
  • Messaging API
    • Line Messaging API
  • Features Roadmap & FAQ
    • ⏱️Features Road Map
    • 📢Release Notes
      • Chat Room Folder Enhancements
      • Enable/Disable Auto-Assign Toggle in Queue Settings
      • Agent Takeover Bot Chat Room
      • Workflow Automation - New Action "Send Message"
      • Enhancement of Hold Function
      • Workflow Automation Rule
      • Non-Voice Analytics Dashboard
      • WhatsApp Mobile Integration
      • Telegram Group Chat Integration for Inbox Module
      • Business Portfolio Integration - Facebook Feed
      • Call Recording Pause and Resume Feature
      • Advanced Hold Functionality for Efficient Conversation Management
      • Viber 24-Hour Response Timer
      • Enhanced Queue Settings and Workflow Automation Controls
      • Telegram Business Integration
      • Multi-Tab Call Support
      • Business Portfolio- (Meta) Messenger Integration
      • Mail Integration Enhancement and Telegram Integration
      • Facebook Feed Enhancement
      • Outlook Email Integration Enhancement (Beta)
      • Queue Setting (Beta)
      • Permission Enhancements and Multiple Assigns
      • CX Logs Enhancement
      • SMS In-bound Beta Version, SMS Integration Setting
      • Facebook Feed Integration (Beta)
      • SLA Setting and Business Hour Functionalities
      • Wrap Up Form Features and Enhancements
      • New Features & Enhancements
      • New Features and Improvement
      • New Features and Major Bug Fixes
    • FAQ
Powered by GitBook
On this page
  1. Integrations
  2. CRM Integrations

How to send transactional Viber Business Message

Steps to Send a Transactional Message to Viber Users via Phone Number

  1. Prerequisites:

    • Viber Business API Access: You need to register with Viber Business and obtain an API key/token.

    • Recipient's Phone Number: You need the recipient's Viber-registered phone number in international format (e.g., +65xxxxxxxx).

    • Node.js: Ensure that you have Node.js installed and set up for making API calls.

Full Example Code to Send a Transactional Message

const axios = require('axios');

// Replace with your Viber Business API token
const VIBER_BUSINESS_API_TOKEN = 'YOUR_VIBER_BUSINESS_API_TOKEN';

// Function to send a transactional message via Viber using the recipient's phone number
const sendTransactionalMessage = async (phoneNumber, messageText) => {
  try {
    const messagePayload = {
      "receiver": phoneNumber,  // The recipient's phone number in international format (e.g., +65xxxxxxx)
      "min_api_version": 1,  // Minimum API version required for this message
      "sender": {
        "name": "YourBusinessName",  // The sender's name as it will appear on the user's phone
        "avatar": "https://example.com/avatar.jpg"  // Optional: URL to the avatar image for the sender
      },
      "type": "text",  // The type of message (in this case, it's a text message)
      "text": messageText,  // The transactional message content (e.g., order confirmation)
      "tracking_data": "tracking_data_example",  // Optional tracking data for your system
    };

    // Send POST request to Viber Business API endpoint to send the message
    const response = await axios.post('https://chatapi.viber.com/pa/send_message', messagePayload, {
      headers: {
        'X-Viber-Auth-Token': VIBER_BUSINESS_API_TOKEN,  // Viber Business API authentication token
      }
    });

    // Log success response
    console.log('Message sent successfully:', response.data);
  } catch (error) {
    // Log any errors encountered during the API request
    console.error('Error sending message:', error.response ? error.response.data : error.message);
  }
};

// Example usage:
// Replace with the recipient's actual Viber-registered phone number in international format
const recipientPhoneNumber = '+65xxxxxxxx';  // Example for Singapore (+65)
// Replace with your actual message content
const transactionalMessageText = 'Your order #12345 has been confirmed! Track it at https://tracking-link.com';

// Call the function to send the transactional message
sendTransactionalMessage(recipientPhoneNumber, transactionalMessageText);

Explanation of the Code:

  1. API Token:

    • Replace YOUR_VIBER_BUSINESS_API_TOKEN with your Viber Business API token. This token is provided after registering for Viber's Business Messaging service.

  2. Phone Number:

    • Replace +65xxxxxxxx with the actual recipient’s Viber-registered phone number in international format (e.g., +65xxxxxxx for Singapore). The phone number must be registered with Viber.

  3. Message Text:

    • Modify the content of the transactionalMessageText variable to whatever transactional message you want to send (e.g., order confirmation, delivery update, etc.).

  4. API Request:

    • The code uses axios to send a POST request to the https://chatapi.viber.com/pa/send_message endpoint, with the message payload that includes the recipient’s phone number, message type, and content.

  5. Sender Information:

    • The sender object contains the business name and an optional avatar URL. These will be shown to the recipient when they receive the message.

  6. Optional Tracking Data:

    • The tracking_data field is optional and can be used to pass any data that you want to track for the message, such as an internal identifier.

Testing the Application:

  1. Ensure you have Node.js installed.

  2. Install the axios package if you haven't already:

npm install axios
  1. Run the script using Node.js:

node index.js

Result:

If everything is set up correctly, the transactional message (e.g., order confirmation) will be delivered to the specified Viber user, and you will see a success message logged in the console.

Important Considerations:

  1. Business Messaging API Access:

    • Depending on your business case, you may need to comply with specific Viber guidelines and have approval for sending transactional messages.

  2. Rate Limits:

    • Ensure you are aware of the rate limits imposed by Viber to avoid hitting limits or being blocked from sending messages.

  3. Pricing:

    • Viber charges for sending messages, especially promotional ones. The cost may vary depending on the country and the message type (e.g., transactional vs. promotional).

By following this code, you'll be able to send transactional Viber messages directly to customers using their phone numbers.

Last updated 7 months ago

You need to work with a Viber Business partner or apply through to get API access.

🔈
Viber Business Messaging Partner