Vladimir Pokrasenko
Vladimir Pokrasenko

Reputation: 1

Doesn't work Welcome message to New User in Viber Bot 'conversation_started'

I try to send a welcome message to a new unsigned user, but it doesn't work. Please, help how solve this problem? This code doesn't work:

elseif($input['event'] == 'conversation_started') {
//    "tracking_data" = "tracking data",
    $data['tracking_data'] = $tracking_data;
    $message['type'] = "text";
    $message['text'] = 'Text to new user';
    $message['keyboard'] = [
        "Type" => "keyboard",
        "DefaultHeight" => true,
        "Buttons" => [[
            "ActionType" => "reply",
            "ActionBody" => "main_menu",
            "Text" => "Main menu",
            "TextSize" => "regular"
        ]]
    ];
}

Upvotes: 0

Views: 430

Answers (1)

George Gotsidis
George Gotsidis

Reputation: 436

As viber documentation stated, user must be subscribed in order for bot to send any kind of message.

An approach to your problem is:

  1. Create a JSON file to store userProfiles.
  2. You should check inside onConversationStarted() if the userProfile is subscribed.
  3. If yes, then use bot.sendMessage() to send your welcome message.

Please check how Viber Documentation API works!

Upvotes: 0

Related Questions