Steps
- Login to your account using your mobile number Link
- Create a bot account
- After which, you will get a
Private Token
- Go to your Viber on your mobile (the account where you created the bot)
- Verify your mail ID and have a profile picture in your account.
- More -> Settings -> My Bots -> Select your bot which you created -> Click publish.
- More -> Settings -> My Bots -> Select your bot which you created -> Message -> Select Viber Chat API.
- Set Webhook Link
curl --location --request POST 'https://chatapi.viber.com/pa/set_webhook' \
--header 'X-Viber-Auth-Token: VIBER_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"url":"WEBHOOK_URL"
}'
Only when you set a webhook link, your bot will get activated.
Points to Note:
- Only when a user sends message to a bot, you will be able to reply.
- You can send message to a user only using user's id (not using user's mobile number)
Changes you should make
-
VIBER_ACCESS_TOKEN
- From Viber Admin Panel -
USER'S ID
- Received From Webhook
Send Text Message
curl --location --request POST 'https://chatapi.viber.com/pa/send_message' \
--header 'X-Viber-Auth-Token: VIBER_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"receiver":"USERS_ID",
"type":"text",
"text":"Hello"
}'
Send Picture
curl --location --request POST 'https://chatapi.viber.com/pa/send_message' \
--header 'X-Viber-Auth-Token: VIBER_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"receiver":"USERS_ID",
"type":"picture",
"text":"Photo description",
"media":"http://www.images.com/img.jpg",
"thumbnail":"http://www.images.com/thumb.jpg"
}'
Send Video
curl --location --request POST 'https://chatapi.viber.com/pa/send_message' \
--header 'X-Viber-Auth-Token: VIBER_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"receiver":"USERS_ID",
"type":"video",
"media":"http://www.images.com/video.mp4",
"thumbnail":"http://www.images.com/thumb.jpg",
"size":10000
}'
Send File
curl --location --request POST 'https://chatapi.viber.com/pa/send_message' \
--header 'X-Viber-Auth-Token: VIBER_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"receiver":"USERS_ID",
"type":"file",
"media":"http://www.images.com/file.doc",
"size":10000,
"file_name":"name_of_file.doc"
}'
Send Contact
curl --location --request POST 'https://chatapi.viber.com/pa/send_message' \
--header 'X-Viber-Auth-Token: VIBER_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"receiver":"USERS_ID",
"type":"contact",
"contact":{
"name":"Itamar",
"phone_number":"+91965XXXXXX"
}
}'
Top comments (0)