How to use the viber-bot.Events.CONVERSATION_STARTED 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 DreamTeamMobile / botbuilder-viber / viber-connector.js View on Github external
function ViberEnabledConnector(opts) {
        var self = this;
        this.options = opts || {};
        this.viberBot = new ViberBot({
            authToken: this.options.Token,
            name: this.options.Name,
            // It is recommended to be 720x720, and no more than 100kb.
            avatar: this.options.AvatarUrl,
            logger: logger
        });

        this.viberBot.on(BotEvents.MESSAGE_RECEIVED, (message, response) => {
            self.processMessage(message, response);
        });

        this.viberBot.on(BotEvents.CONVERSATION_STARTED, (response, onFinish) => {
            // onFinish(new TextMessage(`Hi, ${userProfile.name}! Nice to meet you.`))
            var self = this;
            var userProfile = response.userProfile;
            var addr = {
                channelId: ViberChannelId,
                user: { id: encodeURIComponent(userProfile.id), name: userProfile.name },
                bot: { id: 'viberbot', name: self.options.Name },
                conversation: { id: 'ViberConversationId' }
            };

            var msg = new builder.Message()
                .address(addr)
                .timestamp(convertTimestamp(new Date()))
                .entities();
            msg.type = msg.data.type = 'contactRelationUpdate';
            msg.data.action = 'add';