Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • ViberClient

Index

Constructors

constructor

Properties

Readonly accessToken

accessToken: string

The access token used by the client.

Readonly axios

axios: AxiosInstance

The underlying axios instance.

Methods

broadcastCarouselContent

  • Broadcasts carousel content messages to the users.

    see

    https://developers.viber.com/docs/api/rest-bot-api/#carousel-content-message

    example
    await client.broadcastCarouselContent(
    ['pttm25kSGUo1919sBORWyA==', '2yBSIsbzs7sSrh4oLm2hdQ=='],
    {
    type: 'rich_media',
    buttonsGroupColumns: 6,
    buttonsGroupRows: 7,
    bgColor: '#FFFFFF',
    buttons: [
    {
    columns: 6,
    rows: 3,
    actionType: 'open-url',
    actionBody: 'https://www.google.com',
    image: 'http://html-test:8080/myweb/guy/assets/imageRMsmall2.png',
    },
    {
    columns: 6,
    rows: 2,
    text: '<font color=#323232><b>Headphones with Microphone, On-ear Wired earphones</b></font><font color=#777777><br>Sound Intone </font><font color=#6fc133>$17.99</font>',
    actionType: 'open-url',
    actionBody: 'https://www.google.com',
    textSize: 'medium',
    textVAlign: 'middle',
    textHAlign: 'left',
    },
    {
    columns: 6,
    rows: 1,
    actionType: 'reply',
    actionBody: 'https://www.google.com',
    text: '<font color=#ffffff>Buy</font>',
    textSize: 'large',
    textVAlign: 'middle',
    textHAlign: 'middle',
    image: 'https://s14.postimg.org/4mmt4rw1t/Button.png',
    },
    {
    columns: 6,
    rows: 1,
    actionType: 'reply',
    actionBody: 'https://www.google.com',
    text: '<font color=#8367db>MORE DETAILS</font>',
    textSize: 'small',
    textVAlign: 'middle',
    textHAlign: 'middle',
    },
    {
    columns: 6,
    rows: 3,
    actionType: 'open-url',
    actionBody: 'https://www.google.com',
    image: 'https://s16.postimg.org/wi8jx20wl/image_RMsmall2.png',
    },
    {
    columns: 6,
    rows: 2,
    text: "<font color=#323232><b>Hanes Men's Humor Graphic T-Shirt</b></font><font color=#777777><br>Hanes</font><font color=#6fc133>$10.99</font>",
    actionType: 'open-url',
    actionBody: 'https://www.google.com',
    textSize: 'medium',
    textVAlign: 'middle',
    textHAlign: 'left',
    },
    {
    columns: 6,
    rows: 1,
    actionType: 'reply',
    actionBody: 'https://www.google.com',
    text: '<font color=#ffffff>Buy</font>',
    textSize: 'large',
    textVAlign: 'middle',
    textHAlign: 'middle',
    image: 'https://s14.postimg.org/4mmt4rw1t/Button.png',
    },
    {
    columns: 6,
    rows: 1,
    actionType: 'reply',
    actionBody: 'https://www.google.com',
    text: '<font color=#8367db>MORE DETAILS</font>',
    textSize: 'small',
    textVAlign: 'middle',
    textHAlign: 'middle',
    },
    ],
    }
    );

    Parameters

    • broadcastList: string[]

      This mandatory parameter defines the recipients for the message. Every user must be subscribed and have a valid user id. The maximum list length is 300 receivers.

    • richMedia: RichMedia

      The rich media of the message.

    • Optional options: MessageOptions

      Other optional parameters.

    Returns Promise<BroadcastResponseData>

    Status and message token

broadcastContact

broadcastFile

broadcastLocation

broadcastMessage

broadcastPicture

broadcastSticker

broadcastText

broadcastURL

broadcastVideo

getAccountInfo

  • Fetches the account’s details as registered in ViberTypes.

    see

    https://developers.viber.com/docs/api/rest-bot-api/#get-account-info

    example
    await client.getAccountInfo();
    // {
    // status: 0,
    // statusMessage: 'ok',
    // id: 'pa:75346594275468546724',
    // name: 'account name',
    // uri: 'accountUri',
    // icon: 'http://example.com',
    // background: 'http://example.com',
    // category: 'category',
    // subcategory: 'sub category',
    // location: {
    // lon: 0.1,
    // lat: 0.2,
    // },
    // country: 'UK',
    // webhook: 'https://my.site.com',
    // eventTypes: ['delivered', 'seen'],
    // subscribersCount: 35,
    // members: [
    // {
    // id: '01234567890A=',
    // name: 'my name',
    // avatar: 'http://example.com',
    // role: 'admin',
    // },
    // ],
    // }

    Returns Promise<SucceededResponseData<AccountInfo>>

    The account’s details

getOnlineStatus

  • Fetches the online status of a given subscribed account members.

    see

    https://developers.viber.com/docs/api/rest-bot-api/#get-online

    example
    await client.getOnlineStatus(['01234567890=', '01234567891=', '01234567893=']);
    // [
    // {
    // id: '01234567890=',
    // onlineStatus: 0,
    // onlineStatusMessage: 'online',
    // },
    // {
    // id: '01234567891=',
    // onlineStatus: 1,
    // onlineStatusMessage: 'offline',
    // lastOnline: 1457764197627,
    // },
    // {
    // id: '01234567893=',
    // onlineStatus: 3,
    // onlineStatusMessage: 'tryLater',
    // },
    // ];

    Parameters

    • ids: string[]

      Array of unique Viber user id. 100 ids per request.

    Returns Promise<UserOnlineStatus[]>

    An array of online status.

getUserDetails

removeWebhook

sendCarouselContent

  • Sends a carousel content message to the user.

    see

    https://developers.viber.com/docs/api/rest-bot-api/#carousel-content-message

    example
    await client.sendCarouselContent(USER_ID, {
    type: 'rich_media',
    buttonsGroupColumns: 6,
    buttonsGroupRows: 7,
    bgColor: '#FFFFFF',
    buttons: [
    {
    columns: 6,
    rows: 3,
    actionType: 'open-url',
    actionBody: 'https://www.google.com',
    image: 'http://html-test:8080/myweb/guy/assets/imageRMsmall2.png',
    },
    {
    columns: 6,
    rows: 2,
    text: '<font color=#323232><b>Headphones with Microphone, On-ear Wired earphones</b></font><font color=#777777><br>Sound Intone </font><font color=#6fc133>$17.99</font>',
    actionType: 'open-url',
    actionBody: 'https://www.google.com',
    textSize: 'medium',
    textVAlign: 'middle',
    textHAlign: 'left',
    },
    {
    columns: 6,
    rows: 1,
    actionType: 'reply',
    actionBody: 'https://www.google.com',
    text: '<font color=#ffffff>Buy</font>',
    textSize: 'large',
    textVAlign: 'middle',
    textHAlign: 'middle',
    image: 'https://s14.postimg.org/4mmt4rw1t/Button.png',
    },
    {
    columns: 6,
    rows: 1,
    actionType: 'reply',
    actionBody: 'https://www.google.com',
    text: '<font color=#8367db>MORE DETAILS</font>',
    textSize: 'small',
    textVAlign: 'middle',
    textHAlign: 'middle',
    },
    {
    columns: 6,
    rows: 3,
    actionType: 'open-url',
    actionBody: 'https://www.google.com',
    image: 'https://s16.postimg.org/wi8jx20wl/image_RMsmall2.png',
    },
    {
    columns: 6,
    rows: 2,
    text: "<font color=#323232><b>Hanes Men's Humor Graphic T-Shirt</b></font><font color=#777777><br>Hanes</font><font color=#6fc133>$10.99</font>",
    actionType: 'open-url',
    actionBody: 'https://www.google.com',
    textSize: 'medium',
    textVAlign: 'middle',
    textHAlign: 'left',
    },
    {
    columns: 6,
    rows: 1,
    actionType: 'reply',
    actionBody: 'https://www.google.com',
    text: '<font color=#ffffff>Buy</font>',
    textSize: 'large',
    textVAlign: 'middle',
    textHAlign: 'middle',
    image: 'https://s14.postimg.org/4mmt4rw1t/Button.png',
    },
    {
    columns: 6,
    rows: 1,
    actionType: 'reply',
    actionBody: 'https://www.google.com',
    text: '<font color=#8367db>MORE DETAILS</font>',
    textSize: 'small',
    textVAlign: 'middle',
    textHAlign: 'middle',
    },
    ],
    });

    Parameters

    • receiver: string

      Unique Viber user id.

    • richMedia: RichMedia

      The rich media of the message.

    • Optional options: MessageOptions

      Other optional parameters.

    Returns Promise<SucceededResponseData<{ messageToken: number }>>

    Status and message token

sendContact

sendFile

sendLocation

sendMessage

sendPicture

sendSticker

sendText

sendURL

sendVideo

setWebhook

Static connect

Generated using TypeDoc