How to use the viber-bot.Message function in viber-bot

To help you get started, we’ve selected a few viber-bot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github se02035 / Viber-and-the-Microsoft-Bot-Framework / source / clients / viber / index.js View on Github external
'use strict';

// Viber bot specifics
const ViberBot = require('viber-bot').Bot;
const BotEvents = require('viber-bot').Events;
const TextMessage = require('viber-bot').Message.Text;

// Microsoft Bot Framework (MBF) - DirectLine - Connector 
const MbfBotConnector = require('mbf-directline').Core;
const MbfEvents = require('mbf-directline').Events;
const MbfPlatformViber = require('mbf-directline').Platform.Viber;

// Utilities
const winston = require('winston');
const toYAML = require('winston-console-formatter');
require('dotenv').config();

// config items
const ViberBotName = 'MBF Connector';
const ViberBotImageUrl = 'https://raw.githubusercontent.com/devrelv/drop/master/151-icon.png';
const ViberPublicAccountAccessTokenKey = 'xxxxxxxxxxxxxxxxxx';   // ToDo: Replace with your Viber Public Account access token
github se02035 / Viber-and-the-Microsoft-Bot-Framework / source / lib / microsoftBotConnector.js View on Github external
const MbfEvents = require(__dirname + '/mbf-events');

const Swagger = require('swagger-client');
const open = require('open');

// ATTENTION this implementation does only support the V3 bots
const directLineSpecV3 = require(__dirname + '/directline-swagger-v3.json');

// Viber Messages
const TextMessage = require('viber-bot').Message.Text;
const PictureMessage = require('viber-bot').Message.Picture;
const UrlMessage = require('viber-bot').Message.Url;
const ContactMessage = require('viber-bot').Message.Contact;
const VideoMessage = require('viber-bot').Message.Video;
const LocationMessage = require('viber-bot').Message.Location;
const StickerMessage = require('viber-bot').Message.Sticker;
const FileMessage = require('viber-bot').Message.File;

// MBF Activities
const MessageActivity = require(__dirname + '/activity/messageActivity.js').MessageActivity;

// config items
const defaultPollInterval = 1000;
const defaultDirectLineClientName = 'ViberBotConnector';
const defaultDirectLineSecret = 'xxxxxxxxxxxxxxxxxxxxx'; // ToDo: Replace with your Microsoft Bot Framework DirectLine secret

class MicrosoftBot extends EventEmitter {
    constructor(logger, platform, options) {
        super();

        this._logger = logger;
        this._platform = platform;
github se02035 / Viber-and-the-Microsoft-Bot-Framework / source / lib / microsoftBotConnector.js View on Github external
const EventEmitter = require('events');
const MbfEvents = require(__dirname + '/mbf-events');

const Swagger = require('swagger-client');
const open = require('open');

// ATTENTION this implementation does only support the V3 bots
const directLineSpecV3 = require(__dirname + '/directline-swagger-v3.json');

// Viber Messages
const TextMessage = require('viber-bot').Message.Text;
const PictureMessage = require('viber-bot').Message.Picture;
const UrlMessage = require('viber-bot').Message.Url;
const ContactMessage = require('viber-bot').Message.Contact;
const VideoMessage = require('viber-bot').Message.Video;
const LocationMessage = require('viber-bot').Message.Location;
const StickerMessage = require('viber-bot').Message.Sticker;
const FileMessage = require('viber-bot').Message.File;

// MBF Activities
const MessageActivity = require(__dirname + '/activity/messageActivity.js').MessageActivity;

// config items
const defaultPollInterval = 1000;
const defaultDirectLineClientName = 'ViberBotConnector';
const defaultDirectLineSecret = 'xxxxxxxxxxxxxxxxxxxxx'; // ToDo: Replace with your Microsoft Bot Framework DirectLine secret

class MicrosoftBot extends EventEmitter {
    constructor(logger, platform, options) {
        super();
github se02035 / Viber-and-the-Microsoft-Bot-Framework / source / lib / microsoftBotConnector.js View on Github external
"use strict";

const EventEmitter = require('events');
const MbfEvents = require(__dirname + '/mbf-events');

const Swagger = require('swagger-client');
const open = require('open');

// ATTENTION this implementation does only support the V3 bots
const directLineSpecV3 = require(__dirname + '/directline-swagger-v3.json');

// Viber Messages
const TextMessage = require('viber-bot').Message.Text;
const PictureMessage = require('viber-bot').Message.Picture;
const UrlMessage = require('viber-bot').Message.Url;
const ContactMessage = require('viber-bot').Message.Contact;
const VideoMessage = require('viber-bot').Message.Video;
const LocationMessage = require('viber-bot').Message.Location;
const StickerMessage = require('viber-bot').Message.Sticker;
const FileMessage = require('viber-bot').Message.File;

// MBF Activities
const MessageActivity = require(__dirname + '/activity/messageActivity.js').MessageActivity;

// config items
const defaultPollInterval = 1000;
const defaultDirectLineClientName = 'ViberBotConnector';
const defaultDirectLineSecret = 'xxxxxxxxxxxxxxxxxxxxx'; // ToDo: Replace with your Microsoft Bot Framework DirectLine secret
github DreamTeamMobile / botbuilder-viber / viber-connector.js View on Github external
const builder = require('botbuilder');
const ViberBot = require('viber-bot').Bot;
const BotEvents = require('viber-bot').Events;
const UserProfile = require('viber-bot').UserProfile;
const VTextMessage = require('viber-bot').Message.Text
const VPictureMessage = require('viber-bot').Message.Picture
const VLocationMessage = require('viber-bot').Message.Location
const VContactMessage = require('viber-bot').Message.Contact
const VStickerMessage = require('viber-bot').Message.Sticker
const winston = require('winston');
const toYAML = require('winston-console-formatter'); // makes the output more friendly
const async = require("async");
/*
Until BotBuilder supports custom channels,
we have to use Kik's channelId to make BotBuilder play nice with user data.
We can use any other channel which supports buttons instead of Kik here.
*/
const ViberChannelId = 'kik'

const logger = function() {
    const logger = new winston.Logger({ level: "debug" }); // We recommend DEBUG for development
    logger.add(winston.transports.Console, toYAML.config());
    return logger;
github DreamTeamMobile / botbuilder-viber / viber-connector.js View on Github external
const builder = require('botbuilder');
const ViberBot = require('viber-bot').Bot;
const BotEvents = require('viber-bot').Events;
const UserProfile = require('viber-bot').UserProfile;
const VTextMessage = require('viber-bot').Message.Text
const VPictureMessage = require('viber-bot').Message.Picture
const VLocationMessage = require('viber-bot').Message.Location
const VContactMessage = require('viber-bot').Message.Contact
const VStickerMessage = require('viber-bot').Message.Sticker
const winston = require('winston');
const toYAML = require('winston-console-formatter'); // makes the output more friendly
const async = require("async");
/*
Until BotBuilder supports custom channels,
we have to use Kik's channelId to make BotBuilder play nice with user data.
We can use any other channel which supports buttons instead of Kik here.
*/
const ViberChannelId = 'kik'

const logger = function() {
    const logger = new winston.Logger({ level: "debug" }); // We recommend DEBUG for development
    logger.add(winston.transports.Console, toYAML.config());
github broidHQ / integrations / broid-viber / lib / core / Adapter.js View on Github external
}, attachmentsButtons),
                    DefaultHeight: true,
                    Type: 'keyboard',
                };
            }
            if (dataType === 'Note') {
                return [new viber_bot_1.Message.Text(content, keyboard), message];
            }
            else if (dataType === 'Image' || dataType === 'Video') {
                const url = R.path(['object', 'url'], message);
                const preview = R.path(['object', 'preview'], message);
                if (dataType === 'Image') {
                    return [new viber_bot_1.Message.Picture(url, content, preview, keyboard), message];
                }
                else {
                    return [new viber_bot_1.Message.Video(url, null, preview, null, keyboard), message];
                }
            }
            else if (dataType === 'Place') {
                const latitude = R.path(['object', 'latitude'], message);
                const longitude = R.path(['object', 'longitude'], message);
                return [new viber_bot_1.Message.Location(latitude, longitude, keyboard), message];
            }
            return [null, message];
        })
            .spread((messageBuilder, message) => {
github se02035 / Viber-and-the-Microsoft-Bot-Framework / source / lib / platform / viber-platform.js View on Github external
"use strict";

const BotPlatform = require(__dirname + '/bot-platform.js');
const MessageActivity = require('../activity/messageActivity').MessageActivity;

const TextMessage = require('viber-bot').Message.Text;
const PictureMessage = require('viber-bot').Message.Picture;
const UrlMessage = require('viber-bot').Message.Url;
const ContactMessage = require('viber-bot').Message.Contact;
const VideoMessage = require('viber-bot').Message.Video;
const LocationMessage = require('viber-bot').Message.Location;
const StickerMessage = require('viber-bot').Message.Sticker;
const FileMessage = require('viber-bot').Message.File;

class ViberPlatform extends BotPlatform {
    constructor() {
        super();
    };

    convert(channelId, userData, platformMessage) {
        let botActivity;
        let botActivityArguments = { 
                channelId: channelId, senderId: userData.id, 
                senderName: userData.name, conversationAccountId: userData.id,
github broidHQ / integrations / integrations / broid-viber / lib / core / adapter.js View on Github external
if (attachment.mediaType === "text/html") {
                            actionType = "open-url";
                        }
                        return {
                            ActionBody: attachment.url,
                            ActionType: actionType,
                            BgColor: "#2db9b9",
                            Text: attachment.name || attachment.content,
                        };
                    }, attachmentsButtons),
                    DefaultHeight: true,
                    Type: "keyboard",
                };
            }
            if (type === "Note") {
                return [new viber_bot_1.Message.Text(content, keyboard), message];
            }
            else if (type === "Image" || type === "Video") {
                const url = R.path(["object", "url"], message);
                const preview = R.path(["object", "preview"], message);
                if (type === "Image") {
                    return [new viber_bot_1.Message.Picture(url, content, preview, keyboard), message];
                }
                else {
                    return [new viber_bot_1.Message.Video(url, null, preview, null, keyboard), message];
                }
            }
            else if (type === "Place") {
                const latitude = R.path(["object", "latitude"], message);
                const longitude = R.path(["object", "longitude"], message);
                return [new viber_bot_1.Message.Location(latitude, longitude, keyboard), message];
            }
github se02035 / Viber-and-the-Microsoft-Bot-Framework / source / lib / platform / viber-platform.js View on Github external
"use strict";

const BotPlatform = require(__dirname + '/bot-platform.js');
const MessageActivity = require('../activity/messageActivity').MessageActivity;

const TextMessage = require('viber-bot').Message.Text;
const PictureMessage = require('viber-bot').Message.Picture;
const UrlMessage = require('viber-bot').Message.Url;
const ContactMessage = require('viber-bot').Message.Contact;
const VideoMessage = require('viber-bot').Message.Video;
const LocationMessage = require('viber-bot').Message.Location;
const StickerMessage = require('viber-bot').Message.Sticker;
const FileMessage = require('viber-bot').Message.File;

class ViberPlatform extends BotPlatform {
    constructor() {
        super();
    };

    convert(channelId, userData, platformMessage) {
        let botActivity;
        let botActivityArguments = { 
                channelId: channelId, senderId: userData.id, 
                senderName: userData.name, conversationAccountId: userData.id,
                locale: userData.language, channelData: platformMessage.toJson() };

        switch (platformMessage.constructor.name) {
            case 'TextMessage':
                botActivity = new MessageActivity(