Complex conferencing workflows allow you to communicate with multiple end-users on demand. Advanced conference workflows can be integrated to work with third-party apps, web services, and APIs. Using modern CPaaS, you can design and develop unique conferencing apps that provide your callers with a stellar conferencing experience.
In this tutorial, we will be looking at an advanced reference integration of a conferencing line for a small business owner.
The conference will include two user types:
A.K.A our small business owner who will be managing the conference line.
In our example conference, members will call into our conference line to speak with our host regarding some services.
The conference member calls into our conferencing line and waits for the host to join the line
Our conference host is sent an SMS telling them a new caller is on his conference line
The host then joins his conferencing line to speak with the caller
You will need the following to complete this tutorial:
A DID Number
MessageBird account
Lineblocs account
To create a new blank flow:
In Lineblocs dashboard click "Create" -> "New Flow"
Enter a name for your flow
Select "Blank" template
Click "Create"
First, we will set up variables to keep track of what our host's number is when they call in.
Our variables will allow us to switch context in our flow and to ensure we provide moderator access to our host.
To set up variables, please drag a "Set Variables" widget from the right pane into the flow graph, then connect the Launch widget "Incoming Call" port into the Set Variables "In" port.
Next, please click the "Set Variables" widget to bring up its widget options, then click
Please add the following variables:
```
Name: host_number
```
```
Value: your-phone-number
```
```
Name: messagebirdaccesstoken
```
```
Value: your-messagebird-access-token
```
```
Name: messagebird_number
```
```
Value: your-messagebird-number
```
We will add a macro to allow us to integrate a custom conferencing workflow.
Our macro will be set up to subscribe to conference events as they are triggered.
To add a new macro, please drag the "Macro" widget from the right pane into the flow graph, then rename this widget to "ConferenceEvents.".
Our conference events widget will be set up to track when new members join the conference and make sure our conference always has at most two participants – the host and one member, at any given time.
To setup the conferencing events, please click the "ConferenceEvents" widget, then in the right pane under function click
On the Macro Template screen, select template "Blank,", then click "Save.".
In the Lineblocs function editor, please add the following code:
```
function sendSMS(apiKey, apiNumber, number, body) {
var messagebird = require('messagebird')(apiKey);
messagebird.messages.create({
originator: apiNumber,
recipients : [ number ],
body : body
});
}
module.exports = function(event: LineEvent, context: LineContext) {
return new Promise(async function(resolve, reject) {
var call = context.flow.call;
var cell = context.cell;
var host = event['host_number'];
var sdk = context.getSDK();
var conf = sdk.createConference(context.flow, "Execline");
var number = "";
var isWaiting = true;
conf.on("MemberJoined", function(member: LineConferenceMember) {
if (member.call.callParams.from === call.callParams.from) {
var body = `${number} is now on your conference line.`;
sendSMS(event['messagebird_api_key'], event['messagebird_number'], host, body);
}
});
conf.on("MemberLeft", function(member: LineConferenceMember) {
if (isWaiting && conf.totalParticipants() === 0 && member.call.callParams.from !== call.callParams.from) {
// let our next conference member in
var body = `${number} is now on your conference line.`;
sendSMS(event['messagebird_api_key'], event['messagebird_number'], host, body);
resolve();
}
if (member.call.callParams.from === call.callParams.from) {
var body = `${number} has left your conference line`;
sendSMS(event['messagebird_api_key'], event['messagebird_number'], host, body);
}
});
if ( conf.totalParticipants() === 0 ) {
// let our first conference member in
isWaiting = false;
resolve();
}
});
}
```
Next, we will create a "Switch" widget to change context depending on whether our host is calling or if a member is calling.
To set up a switch, please drag a "Switch" widget from the right pane into the flow graph, then add the following two links:
```
Condition: Equals
```
```
Value: {{SetupVariables.host_number}}
```
```
Condition: Not Equals
```
```
Value: {{SetupVariables.host_number}}
```
Our conference will require at least two conferencing roles, the "user." and the "moderator."
To set up the call flow routes, please create two "SetVariable" widgets: "ModeratorRoute" and "UserRoute."
Please add the following variables under "ModeratorRoute":
```
name: role
```
```
value: moderator
```
Please add the following variables under "UserRoute":
```
name: role
```
```
value: user
```
Our final piece of the flow will be to add a "Conference" widget.
To add a "Conference" widget into the flow, please drag a "Conference" widget from the right pane into the flow.
In the "Conference" settings, please check "Wait for Moderator" and "End on Moderator leave" settings.
To make our flow all work together, we will need to add links between the widgets created.
Please add the following links:
SetupVariables to ConferenceEvents
ConferenceEvents to Switch
Switch Link 1 to ModeratorRoute
Switch Link 2 to UserRoute
ModeratorRoute to Conference
UserRoute to Conference
To save all your changes please click in the flow editor.
To use your call flow on a DID Number:
In the lineblocs dashboard please click DID Numbers -> My Numbers
Click the "Edit" button next to your number
Update the "Attached Flow" field
Click "Save"
To test as a caller:
Call the conferencing line number
To test as a host:
Use the host number to call into the conferencing line
In this guide we went over a reference conferencing app integration. For more related articles please see:
In this guide, we went over a reference conferencing app integration. For more related articles, please see: