@mailvideo/embed v1.0.0
@mailvideo/embed
This package embeds mailvideo iframe to handle video in your application.
Install
pnpm i @mailvideo/embedFeatures
- It can create new or existing video and share it with your users.
- View video statistics.
Prerequisites
You need to contact mailvideo to get a public key to be able to use this plugin.
Example
Usage
import { loadMailVideo } from '@mailvideo/embed';
const mailvideo = await loadMailVideo({
publishableKey: 'your-public-key',
tenantId: 2,
accountId: 5,
});
const [video, error] = await mailvideo.pickVideo();
if (video) {
// a video was created/selected
console.log(video);
return;
}
if (error === 'user-cancelled') {
// user cancelled the dialog
return;
}
// something went wrong
console.error(error);Methods
loadMailVideo
Loads the mailvideo script and returns a promise that resolves to a MailVideo object.
loadMailVideo options
| Name | Description | Type | Default |
|---|---|---|---|
| publishableKey | Your public key | string | Required |
| locale | The locale to use for the mailvideo iframe. | string | en |
| verbose | If true, all information will be console logged. | boolean | false |
| tenantId | The tenant id to use for the mailvideo iframe. | string/number | Required |
| accountId | The account id to use for the mailvideo iframe. | string/number | Required |
| preload | If this is true, then the iframe will be preloaded and appended to the body, and hidden. | boolean/HTMLDivElement | false |
| canCreateMailVideoTeam | If the user can read all users in it's tenant/team. This is used if a mailvideo team has not yet been created for the tenant/team. | boolean | true |
pickVideo
Opens a popup dialog or inject iframe into a custom container to create a new video or select an existing video.
PickVideoOptions
| Name | Description | Type | Default |
|---|---|---|---|
| person | The person to use for the mailvideo iframe. | PersonData | undefined |
| company | The company to use for the mailvideo iframe. | CompanyData | undefined |
| activity | The activity to use for the mailvideo iframe. | ActivityData | undefined |
| divElement | The div element to use for the mailvideo iframe. If not specified it will open a popup dialog in the middle of the page. | HTMLDivElement | undefined |
| logMailVideoSent | If your system has API endpoint to log events, then mailvideo will log when a user sends a video. | boolean | true |
| logMailVideoSeen | If your system has API endpoint to log events, then mailvideo will logwhen a video has been seen by the recipient. | boolean | true |
PickVideoResponse
| Name | Description | Type |
|---|---|---|
| id | The video id | string |
| title | The video title | string |
| link | The video link | string |
| embedCode | The video embed code | string |
| emailHTMLCode | The video email html code | string |
pickVideoTemplate
This is the same as pickVideo, execpt it is used for email templates. When setting person, company or activity options, you put the wildcards that you replace in the email template. For example if you have a wildcard called {{personId}}
You will do the following:
const [video] = await mailvideo.pickVideoTemplate({
person: {
id: '{{personId}}',
},
});
video.link; // => https://share.mailvideo.com/watch/sakdjdsf873453?personId={{personId}}PickVideoTemplateOptions
| Name | Description | Type | Default |
|---|---|---|---|
| accountIdTemplate | This will replace the accountId of the user that created the template. So we can correctly show who sent video. | string | undefined |
| person | The person to use for the mailvideo iframe. | PersonTemplateData | undefined |
| company | The company to use for the mailvideo iframe. | CompanyTemplateData | undefined |
| activity | The activity to use for the mailvideo iframe. | ActivityTempalteData | undefined |
| divElement | The div element to use for the mailvideo iframe. If not specified it will open a popup dialog in the middle of the page. | HTMLDivElement | undefined |
| logMailVideoSent | If your system has API endpoint to log events, then mailvideo will log when a user sends a video. | boolean | true |
| logMailVideoSeen | If your system has API endpoint to log events, then mailvideo will logwhen a video has been seen by the recipient. | boolean | true |
PickVideoTemplateResponse
| Name | Description | Type |
|---|---|---|
| id | The video id | string |
| title | The video title | string |
| link | The video link | string |
| embedCode | The video embed code | string |
| emailHTMLCode | The video email html code | string |
openPlatform
Open the library of videos for a specific company/person/activity or just for the entire platform. You can see all sent videos to that company/person. Also you can manage exiting videos.
OpenPlatformOptions
| Name | Description | Type | Default |
|---|---|---|---|
| person | The person to use for the mailvideo iframe. | PersonData | undefined |
| company | The company to use for the mailvideo iframe. | CompanyData | undefined |
| activity | The activity to use for the mailvideo iframe. | ActivityData | undefined |
| divElement | The div element to use for the mailvideo iframe. If not specified it will open a popup dialog in the middle of the page. | HTMLDivElement | undefined |
| logMailVideoSent | If your system has API endpoint to log events, then mailvideo will log when a user sends a video. | boolean | true |
| logMailVideoSeen | If your system has API endpoint to log events, then mailvideo will logwhen a video has been seen by the recipient. | boolean | true |
openVideo
Open a specific video to edit or see analytics.
OpenVideoOptions
| Name | Description | Type | Default |
|---|---|---|---|
| videoId | The id of the video to view | string | required |
| divElement | The div element to use for the mailvideo iframe. If not specified it will open a popup dialog in the middle of the page. | HTMLDivElement | undefined |
| logMailVideoSent | If your system has API endpoint to log events, then mailvideo will log when a user sends a video. | boolean | true |
| logMailVideoSeen | If your system has API endpoint to log events, then mailvideo will logwhen a video has been seen by the recipient. | boolean | true |
Interfaces
interface PersonData {
id: string | number;
name: string;
email?: string;
}
interface CompanyData {
id: string | number;
name: string;
}
interface ActivityData {
id: string | number;
name: string;
}
interface PersonTemplateData {
id: string;
name?: string;
email?: string;
}
interface CompanyTemplateData {
id: string;
name?: string;
}
interface ActivityTemplateData {
id: string;
name?: string;
}2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago