Public Account "Get Weather"
  • Updated on 28 Oct 2019
  • 1 minute to read
  • Contributors
  • Print
  • Share
  • Dark
    Light

Public Account "Get Weather"

  • Print
  • Share
  • Dark
    Light

Clone "Viber Public Account "Get Weather" folder into your enviropment

viber_copy

Process description

Resiver

Receives webhook-s from Viber Public Account and distributes them according to received value of "event" parameter.

"event": "message" divides into types: picture, video, file, contact, url, location, text.

Received messages with text type are transferred to Main logic.

Main logic

Manages the logic of message sending.

Requests the weather, sends received air temperature or message about undefined city.

Send message

By Viber Public Account token recevies account details (name and link for the avatar) for message sending.

Sends messages, distributes them by sending statuses.

Successful requests are trasferred to Message statuses after receiving message end status.

Message statuses

Distributes successful requests by the states:

"Sent", "Delivered", "Seen", "Not delivered, 14 days", "Not seen, 14 days", "failed - not delivered by Viber".

Preparation

Webhook

Connect Resiver to the Viber Webhook:

  • go to Webhook tab
  • press Connect to messenger
  • select Viber
  • press "Set Webhook" and specify the token of your Public Account

viber_set_wh

Welcome message

If necessary, set the welcome message for your Public Account:

  • After selecting Viber press the "Set Welcome message" button
  • choose the type of welcome message - text or a picture with text
  • fill out required fileds

viber_welcome_msg

Welcome message is sent as a reply to the received webhook which contains "event": "conversation_started".

This event indicates that user came to the chat with your Puclic Account for the first time (it means, there's no history) или когда чат открыт через deep link.

"conversation_started" is not considered a subscription and does not allow the Public Account to send messages to users.

But it allows you to send one greeting.

Integration with OpenWeatherMap

For user's comfort in Main logic there was a test key added for API OpenWeatherMap.

To get your OpenWeatherMap API access key, go to link and register.
weather_key

In the Get weather by city node, replace the test key with the one you received in theAPPID parameter value.
open_weather_key

Testing and launch

Just add required Public Account and start dialog.

Go to View mode Resiver or Main logic in order to see request flow, its movement and distributing to the nodes.

view_task

Was this article helpful?