0.0.15 • Published 2 years ago

witty-twilio-plugin v0.0.15

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

Witty Twilio Plugin

INSTALLATION

Download & install applications

  • Git
  • NodeJS {download current and latest}
  • XAMPP / WAMP or Any LAMP server you are comfortable with

Application Install

  1. Clone the repository https://gitlab.com/jason.posbang/witty-twilio-plugin.git
  2. Navigate to the app root directory using Cmder or Git Bash CLI Example: cd c:\xampp\htdocs\witty-video-chat-plugin\
  3. Run npm install

Testing

  1. Run npm run build
  2. Run npm pack
  3. Copy the created zip file and extract to the project node_modules

Publish

  1. Run npm run build
  2. Run npm publish
  3. In the project, run npm install --save witty-twilio-plugin

Local Testing

  1. Run npm link on current witty-video-chat-plugin folder
  2. Run npm link witty-twilio-plugin to target project folder
  3. Import package import WittyVideoChatPlugin from 'witty-twilio-plugin' Vue.use(WittyVideoChatPlugin);

Sample WittyVideoChat Implementation

<template>
    <div id="app">
        <!-- Dont forget to provide props and functions to events -->

        <witty-video-chat
            :user="user"
            :token="token"
            :config="config"
            :events="events"
        >
            <witty-chat>
                <witty-container>
                    <witty-user
                        :search.sync="search"
                    />
                    <witty-channels
                        @onActiveChannelChanged="activeChannelChanged"
                        :search="search"
                    />
                </witty-container>

                <!-- Witty conversations -->
                <witty-conversations
                    @onInfoClicked="onInfoClicked"
                    @onVideoClicked="onVideoClicked"
                    :disable-video="disableCreateVideo"
                    ref="wittyConversations"
                >
                    <!-- You can add slots here. See WittyConverstions for available slots. -->
                </witty-conversations>

                <!-- Witty overview -->
                <witty-overview
                    v-if="showOverview"
                    @close="showOverview = false"
                >
                    <!-- Slots implementation for WittyOverview -->
                    <template slot="collapse-item-prefix" slot-scope="{scope}">
                        <el-collapse-item name="test">
                            <template slot="title">
                                <div class="title_container">
                                    <label>{{ 'Sample Slot' }}</label>
                                </div>
                            </template>

                            <p>Data: {{ scope.name }}</p>
                            </p>Attrbs: {{ scope.attributes }}</p>
                        </el-collapse-item>
                    </template>

                    <template slot="collapse-item-postfix" slot-scope="{scope}">
                        <el-collapse-item name="test2">
                            <template slot="title">
                                <div class="title_container">
                                    <label>{{ 'Sample Slot 2' }}</label>
                                </div>
                            </template>

                            <p>Data: {{ scope.name }}</p>
                            </p>Attrbs: {{ scope.attributes }}</p>
                        </el-collapse-item>
                    </template>
                </witty-overview>
            </witty-chat>
        </witty-video-chat>
    </div>
</template>

<script>
    import WittyVideoChat from 'witty-twilio-plugin'
    import WittyChat from 'witty-twilio-plugin'
    import WittyContainer from 'witty-twilio-plugin'
    import WittyUser from 'witty-twilio-plugin'
    import WittyChannels from 'witty-twilio-plugin'
    import WittyConversations from 'witty-twilio-plugin'
    import WittyOverview from 'witty-twilio-plugin'
    import ChatParticipantDetailsProfile from './Overview/ChatParticipantDetailsProfile'
    import ChatParticipantDetailsCards from './Overview/ChatParticipantDetailsCards'
    import axios from 'axios'
    import Noty from 'noty';

    Vue.use(WittyVideoChat)
    Vue.use(WittyChat)
    Vue.use(WittyContainer)
    Vue.use(WittyUser)
    Vue.use(WittyChannels)
    Vue.use(WittyConversations)
    Vue.use(WittyOverview)
    Vue.use(WittyOverview)

    /// your codes here
</script>

<style lang="scss">
    @import '../src/themes/Witty/scss/style.scss';
    /* you styles here */
</style>

WittyVideo

Props

NameDescriptionTypeRequiredDefault
visibleIf the component is inside a modal. This must be synced with the modal visibility.Booleanfalsetrue
nameMeeting room name.StringfalseRoom
labelLabel for meeting room. name would be used if not set.falseRoom
tokenTwilio Access Token with Video Grant.Stringtrue-
identityCurrent user identity. Must match token.Stringfalsenull
userDataArray or Function return a list of users. If function must accept params callback, identities(optional or null), searchQueryArray or Functionfalse[]
themeFor theming, not yet used.Stringfalsedefault
translateTranslation function.Functionfalsenull
customClassesSets custom classes for buttons and other elements used in components. Optional.Objectfalse{"btnPrimary":"","btnCircle":"","btnCircleDanger":"","btnDefault":"","selectSingle":"","selectMultiple":""}
trialIf set will enable trial and limit room duration to provided duration. Set is_trial to true to enable trial.Objectfalse{"is_trial":false,"duration":0}
recordFunctionFunction to start/end recording. Recording must be implemented in the backend. Params roomd_id, record(Boolean). If record is true start recording, end recording if false.falsenull
enableKickParticipantEnable user to kick a room participant.Objectfalsefalse
enableEndMeetingShow end meeting button. Must have handling for room-disconnected event.Booleanfalsefalse
enableInviteParticipantEnable inviting other participants.Booleanfalsefalse
startVideoTextText to display in start video button.StringfalseStart

Events

Event NameDescriptionParameters
created-roomNew room has been created.Room data
joined-roomUser has joined a room.Room data
invite-participantsInvite participants.Array of participants.
remove-participantRemove participant.(Object){room: sid, participant_sid:sid, identity:participant identity}
room-disconnectedCurrent user has disconnected from the room. If endMeeting is true, room must be terminated in the backend.(Object){endMeeting: Boolean, meetingDuration: int seconds, meetingStatus: status, roomSid: sid}

Slots

NameDescriptionDefault Slot Content
unsported-browser-warningWarning message if current browser is not supported.-
trial-ended-warningWarning message if trial has ended. If trial is enabled.-
chat-channel-componentSlot for adding chat channels or other functions to side bar.-

MixIns

Some events are from this mixin.

MixIn
twilioVideoCallHelper

WittyVideoChat

Props

NameDescriptionTypeRequiredDefault
tokenTwilio Access Token, must have chat grant. Must be provided but is not required to use the component.Stringfalsenull
userCurrent user. Must match with prodivded token. Object must contain first_name, last_name, image_path, {identity property provided in config}. See : Props > userObjectfalsenull
configConfiguration settings for witty video chat. See : Props > configObjecttruenull
eventsObject containing necessary events for witty twilio plugin integration. List of events: ( onGetChannelUsers, onCreateChanneluser, onImageUpload, onGetAccessToken, onMention, onNewChannelCreated, onVideoInvalidToken, onVideoRoomCreated, onVideoRoomJoined, onVideoRoomRecord, onVideoRoomExit, onVideoRoomKickParticipant ). See : Props > events.Objecttruenull

Props > user

NameDescriptionTypeRequiredDefault
first_nameFirst name of user.Stringfalsenull
last_nameLast name of user.Stringfalsenull
{ identity key }Twilio identity of the user. Must match with current Twilio Access Token. Must match with identity provided in config prop.Stringtrueemail

Note: You can add other properties aside from these. Those properties can be used in events.

Sample:

{
    first_name: 'User',
    last_name: '',
    org_id: 3780,
    id: 1234,
    email: 'jasonu@wittymanager.com',
    image_path: '//hr.wittymanager.com/images/employee/3780-1599534873.jpg'
}

Props > config

NameDescriptionTypeRequiredDefault
identityKey of identity used in users prop.Stringtrueemail
secondaryLabelUse for displaying labels for users in user info.Stringfalsenull
tertiaryLabelUse for displaying labels for users in user info.Stringfalsenull
groupsUsed for grouping channels. Array containing group object data. See: Props > config > groupsArray of Objectstruenull
actionsObject containing allow actions for current user. See: Props > config > actionsStringtrueemail
apiObject containing API Endpoints for additional data required for creating channels and refreshing token. See: Props > config > apiStringtrueemail
videoObject containing config data for Video Components. See: Props > config > videoObjectoptional *Required if using video comnponents.null
messageOptionsArray of objects containing additional options to messages with right clicked. See: Props > config > messageOptions > itemArray of Objectsfalsenull
chatStatusObject containing list of available chat status for users. Status can also be updated by users. See Props > config > chatStatus > itemObjectfalseSee Props > config > chatStatus > sample
patternObject containing channel name pattern and default channel attribute. Used when creating new channels. See: Props > config > patterObjectfalsenull
filterConversationMethod for filter channels.Functionfalsenull
enableMentionsEnables mention function. Events for mentions must be provided if true.Booleanfalsenull

Sample:

config: {
    actions: {
        addChannel: false,
        editChannel: true,
        deleteChannel: true,
        pinConversation: true,
        removeParticipant: false
    },
    groups: [
        {
            type: 'multiple', 
            name: 'team', 
            isRemote: true,
            customNaming: true
        },
        {
            type: 'single',
            name: 'personal',
            isRemote: true
        }
    ],
    identity: 'email',
    secondaryLabel: 'position_name',
    tertiaryLabel: 'email',
    api: {
        users: {
            list: {
                url: 'http://witty2.witme/chat/get-users',
                method: 'get',
            },
            create: null
        },
        token: {
            get: null/
        },
        headers: {
            'X-CSRF-TOKEN' : 'e5-sNBWmdWTqsgJppj0UIdkvOWt0PvxslPT_EuZAj8pC-5xEY80eC7PqMhPJTlVTintbJjxhlTnezahEsA_rjw==',
            'X-Requested-With' : 'XMLHttpRequest',
            'Set-Cookie' : "HttpOnly;Secure;SameSite=Strict",
        },
    },
    video: {
        enableEndMeeting: false,
        enableKickParticipant: true,
        enableInviteParticipant: true
    },
    messageOptions: [
        {
            name: 'Convert to Task',
            class: ['divided'],
            key: 'task',
            event: ((data) => {})
        },
        {
            name: 'Convert to Ticket',
            key: 'ticket',
            event: ((data) => { console.log("data", data)})
        }
    ],
    chatStatus: {
        online: {
            orbStyle: {
                background: '#2EB67D',
            },
            textStyle: {
                color: '#2EB67D',
            },
            online: true,
            defaultOnline: true,
            label: 'Available'
        },
        busy: {
            orbStyle: {
                backgroundColor: '#EC5E5E',
            },
            textStyle: {
                color: '#EC5E5E',
            },
            online: true,
            label: 'Busy'
        },
        away: {
            orbStyle: {
                backgroundColor: '#f18700',
            },
            textStyle: {
                color: '#f18700',
            },
            online: true,
            label: 'Away'
        },
        offline: {
            orbStyle: {
                backgroundColor: 'grey',
            },
            textStyle: {
                color: 'grey',
            },
            online: false,
            defaultOffline: true,
            label: 'Offline'
        },
    },
    pattern: {
        conversation: '{email}',
        attributes: {
            org_id: 3780
        },
    },
    filterConversation: (channel) => {
        let orgId = channel && channel.attributes && channel.attributes.org_id || channel && channel.attributes && channel.attributes.orgId || null
        return orgId == 3780 ? true : false
    },
    enableMentions: true,
},

Props > config > groups

NameDescriptionTypeRequiredDefault
typeType of group.String 'multiple' or 'single'truenull
nameDisplay name of group.Stringtruenull
isRemoteUsed in markethammer. Just set to true.Booleantruetrue

Note: Just set isRemote to true.

Sample:

[
    {
        type: 'multiple', 
        name: 'team', 
        isRemote: true,
    },
    {
        type: 'single',
        name: 'personal',
        isRemote: true
    }
]

Props > config > actions

NameDescriptionTypeRequiredDefault
addChannelAllow creating channels.Boleantruetrue
editChannelAllow editing channels with type: multiple.Boleantruetrue
deleteChannelAllow deleting channels.Boleantruetrue
pinConversationAllow pinning conversations channels. Pinning a channel puts it on top of the list.Boleantruetrue
removeParticipantAllow removing other participants from a channel channels.Boleantruetrue

Note: All actions are true by default. All properties must be set.

Sample:

{
    addChannel: false,
    editChannel: true,
    deleteChannel: true,
    pinConversation: true,
    removeParticipant: false
}

Props > config > api

NameDescriptionTypeRequiredDefault
usersObject containing API Enpoints for user actions. See: Props > config > api > userObjecttruenull
tokenObject containing API Enpoints for refreshing token. Twilio Access Token only lasts 30mins by default.Objecttruenull
headersHeaders to for API requests. Must be in key(Header) value(Header value) structure.Objectfalsenull

Note: Just set isRemote to true.

Sample:

users: {
    list: {
        url: 'http://witty2.witme/chat/get-users',
        method: 'get',
    },
    create: {
        url: 'http://witty2.witme/chat/create-user',
        method: 'post',
    }
},
token: {
    get: {
        url: 'http://witty2.witme/chat/authenticate',
        method: 'get'
    }
},
headers: {
    'X-CSRF-TOKEN' : 'e5-sNBWmdWTqsgJppj0UIdkvOWt0PvxslPT_EuZAj8pC-5xEY80eC7PqMhPJTlVTintbJjxhlTnezahEsA_rjw==',
    'X-Requested-With' : 'XMLHttpRequest',
    'Set-Cookie' : "HttpOnly;Secure;SameSite=Strict",
},

Props > config > api > user

NameDescriptionTypeRequiredDefault
listObject containing API Enpoints for retrieving existing twilio user list. Used in creating new channels. See: Props > config > api > 'Enpoint Setup'Objecttruenull
createObject containing API Enpoints for creating new twilio user. Used when creating new channels. See: Props > config > api > 'Enpoint Setup'Objecttruenull

Sample:

list: {
    url: 'http://witty2.witme/chat/get-users',
    method: 'get',
},
create: {
    url: 'http://witty2.witme/chat/create-user',
    method: 'post',
}

Props > config > api > Enpoint Setup

NameDescriptionTypeRequiredDefault
urlURL of endpointStringtruenull
methodHTTP Method to use for request.Stringget, postnull

Sample:

{
    url: 'http://witty2.witme/chat/get-users',
    method: 'get',
}

Props > config > api > token

NameDescriptionTypeRequiredDefault
getObject containing API Enpoints for retrieving new token. Used in creating new channels. See: Props > config > api > 'Enpoint Setup'Objecttruenull

Note: Not required if Props > events > onGetAccessToken is provided.

Sample:

get: {
    url: 'http://witty2.witme/chat/authenticate',
    method: 'get'
}

Props > config > video

NameDescriptionTypeRequiredDefault
enableEndMeetingEnable users to end current active meeting. Only allows leaving meeting if set to falseBooleantruefalse
enableKickParticipantEnable removing other participants from active meeting.Booleantruefalse
enableInviteParticipantEnable inviting other participants to active meeting.Booleantruefalse

Sample:

{
    enableEndMeeting: false,
    enableKickParticipant: true,
    enableInviteParticipant: true
}

Props > config > messageOptions > sample

Sample:

[
    {
        name: 'Convert to Task',
        class: ['divided'],
        key: 'task',
        event: ((data) => {})
    },
    {
        name: 'Convert to Ticket',
        key: 'ticket',
        event: ((data) => { console.log("data", data)})
    }
]

Props > config > messageOptions > item

NameDescriptionTypeRequiredDefault
nameLabel to display for current option.Stringtruenull
classClass to add to option div.Stringfalsenull
keyKey for item. Must be unique. Must no be in list (reply, edit, copy, download, forward, delete)Stringtruenull
eventFunction to do when option is selectedFunctiontruenull

Sample:

{
    name: 'Convert to Task',
    class: ['divided'],
    key: 'task',
    event: ((data) => {})
},

Props > config > chatStatus > sample

Sample:

{
    offline: {
        orbStyle: {
            backgroundColor: 'var(--witty-avatar-status-orb-background)',
        },
        textStyle: {
            color: 'var(--witty-avatar-status-orb-background)',
        },
        online: false,
        defaultOffline: true,
        name
    },
    online: {
        orbStyle: {
            background: 'var(--witty-success-color)',
        },
        textStyle: {
            color: 'var(--witty-success-color)',
        },
        online: true,
        defaultOnline: true
    }
}

Props > config > chatStatus > item

NameDescriptionTypeRequiredDefault
orbStyleStyle for orb display. Sample {background: '#2EB67D'}Objecttruenull
textStyleStyle for text display. Sample {color: '#2EB67D'}Objecttruenull
onlineUser must be online to select status.Booleantruetrue
defaultOnlineIf true, this item would be used as default status if user is online.Objecttruefalse
labelStatus labelObjecttruenull

Sample:

online: {
    orbStyle: {
        background: '#2EB67D',
    },
    textStyle: {
        color: '#2EB67D',
    },
    online: true,
    defaultOnline: true,
    label: 'Available'
},

Props > config > chatStatus > pattern

NameDescriptionTypeRequiredDefault
conversationPattern for channel name for type: single channelsString '{email}'falsenull
attributesAny object you want to add to channel attributes.'Object'falsenull

Sample:

{
    conversation: '{email}',
    attributes: {
        org_id: 3780
    },
}

Props > events

NameDescriptionTypeRequiredDefault
onGetChannelUsersFunction used for retrieving list of users and user details. Must have the following params: callback, identities, searchFunctiontruenull
onCreateChanneluserFunction for creating new Twilio user. Called when creating new channels if invited user does not exist in twilio. Must have the following params: data (user data)Functiontruenull
onImageUploadFunction used for uploading images if pasted text to message input has images. Is not used for mesasge attachments. Must have the following params: data (file data)Functiontruenull
onMentionFunction used for handling mentions within the project implement twilio chat plugin. Twilio chat plugin only handles displaying mentions on message list, not notifications. Must have the following params: data (user data)Functiontruenull
onNewChannelCreatedCalled when a new channel is created. Must have the following params: channel (new channel data)Functionfalsenull
onVideoInvalidTokenCalled when token is invalid for use in meetings. Token might have expired or does no have Video Grant.Functionfalsenull
onVideoRoomCreatedCalled when a new meeting room is created.Functionfalsenull
onVideoRoomJoinedCalled when a new user has joined a meeting room.Functionfalsenull
onVideoRoomRecordFunction for implementing meeting room recording. Meeting room recording cannot be handled from plugin. Must have the following params: data (room data)Functionfalsenull
onVideoRoomExitFunction for terminating meeting room. Meeting room termination cannot be handled from plugin. All users are kicked out of the room once the room is terminated. Must have the following params: data (room data)Functionfalsenull
onVideoRoomKickParticipantFunction for removing meeting participants. Meeting room participants cannot be removed from plugin. Must have the following params: data (room data)Functionfalsenull

Note: All video events if not provided are disabled. Video Call events are not required if not using Video Plugin, or implementing Video Plugin separately from Chat.

Sample:

events: {
    onGetChannelUsers: vm.onGetChannelUsers,
    onCreateChanneluser: vm.onCreateChanneluser,
    onImageUpload: null,//(data) => { console.log("image upload", data)},
    onGetAccessToken: vm.onGetNewToken,
    onMention: (data) => { console.log("mention", data)},
    onNewChannelCreated: (channel) => {
        console.log("new channel created", channel)
    },

    //Video
    onVideoInvalidToken: vm.onVideoInvalidToken,
    onVideoRoomCreated: vm.onVideoRoomCreated,
    onVideoRoomJoined: vm.onVideoRoomJoined,
    onVideoRoomRecord: vm.onVideoRoomRecord,
    onVideoRoomExit: vm.onVideoRoomExit,
    onVideoRoomKickParticipant: vm.onVideoRoomKickParticipant
    //End Video
}

methods: {
	onVideoInvalidToken,() {
		// refresh token
	},

	onVideoRoomCreated (data) {
		// save data to db or do anything else
		/*
            data => {
                sid => Twilio Room Sid
                room => Twilio Room Name
                token => Token Used
            }
        */
	},

	onVideoRoomJoined (data) {
		// save data to db or do anything else
		/*
            data => {
                sid => Twilio Room Sid
                room => Twilio Room Name
                token => Token Used
            }
        */
	},

	onVideoRoomRecord(data) {
		// call record function in the backend
		/*
            data => {
                sid => string | room sid
                record => boolean | true to start recording, false to stop recording
            }
        */
	},

	onVideoRoomExit() {
		/*
            data => {
                endMeeting => boolean | Must terminate room in backend if true | Room terminated is handled in backend
                meetingDuration: int | duration in seconds
                meetingStatus: string | current meeting status
                roomSid: string | Twilio Room Sid
            }
        */
	},

	onVideoRoomKickParticipant() {
		// call kick function in the backend
		/*
            data => {
                identity => string | identity of participant that must be kicked
                participant => string | participant sid
                room => string | room sid
            }
        */
	}
}

Slots

NameDescriptionDefault Slot Content
default--

WittyConversations

Props

NameDescriptionTypeRequiredDefault
hideHeaderHide header.falsefalse
disableVideoHide video action.falsefalse

Events

Event NameDescriptionParameters
onInfoClickedInfo action button is clicked.-
onVideoClickedVideo action button is clicked.-

Slots

NameDescriptionDefault Slot Content
conversation-actionsSlot for adding additional actions for selected channel.-
message-prefixSlot for adding prefix to message item.-
message-postfixSlot for adding postfix to message item.-
participant-viewSlot for viewing participant details.-
participant-view-postfixSlot for viewing participant details.-
participant-view-action-prefixSlot for viewing participant details.-
participant-view-action-postfixSlot for viewing participant details.-

WittyOverview

Events

Event NameDescriptionParameters
closeClose button is clicked. Does not hide WittyOverview. Only fires an event.-

Slots

NameDescriptionDefault Slot Content
collapse-item-prefixAdd additional overview items before list.-
collapse-item-postfixAdd additional overview items after list.-

WittyUser

Props

NameDescriptionTypeRequiredDefault
searchSearch input. Implements .sync.Stringtruenull

WittyChannels

Props

NameDescriptionTypeRequiredDefault
searchSearch input from WittyUserStringfalsenull

Events

Event NameDescriptionParameters
unread-count-changedActive Channel unread count has changed.Count
onActiveChannelChangedSelected channel changedChannelSid
0.0.12

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.0.15

2 years ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago