V
V
Vitaly2021-03-23 14:36:00
Node.js
Vitaly, 2021-03-23 14:36:00

How to make share-phone work in viber bot on node?

All the best!
I need to get the user's phone number in the bot, but it doesn't work at all :(
The button for sending the number looks like this:

const keyboardSharePhoneViber = {
    "Type": "keyboard",
    "Buttons": [
        {
            "ActionType": "share-phone",
            "ActionBody": "phone",
            "Text": "Share your phone number",
            "TextSize": "regular"
        }
    ]
}


Then I try to send this button to the user

viberBot.sendMessage(response.userProfile, new TextMessage('Please shere your phone', keyboardSharePhoneViber))


As a result I get an error

(node:20304) UnhandledPromiseRejectionWarning: #
( node: 20304 ) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled https://qna.habr.com/#promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html# cli_unhandled_reje... ). (rejection id: 1)
(node:20304) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


They also wrote somewhere that you need to manually specify min_api_version, but I still don’t understand where to prescribe it ...

Please help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Bogdan Boryslavskyi, 2021-09-24
@GeniusAtamans

Try robiti like this:

bot.on(BotEvents.CONVERSATION_STARTED, (response) => {
    response.send(new KeyboardMessage("Type": "keyboard",
    "Buttons": [
       {
        "Columns": 6,
        "Rows": 1,
        "Text": "",
        "ActionType": "share-phone",
        "ActionBody": "phone",
    }
    ], [], null, null, 3));
});

There de 3 u viklik, tse min_api_version

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question