How to pull data from a source in Dialogue Studio
Another advance feature you can add to your flow is retrieving data based on input, for example customer phone number. Below we will have an example, first what you can do with the incoming customer uri.
Preview
Preparations
In this scenario we are going to pull data from a database. In this example we will be using the following data set format:
id |
FirstName |
LastName |
SipAddress |
---|---|---|---|
1 | Keith | Sanders | sip:keiths@domain.com |
Configure
Before starting we need to add the nodes to connect to SQL. This can be done by adding it to the pallet:
Steps:
-
Open the menu in the top right
-
Select Manage palette
-
Open the tab Install
-
Search for the module node-red-contrib-mssql
-
Click install
We are going to start with a “Incoming conversation” node. This node only listens to audio/video and is connected to our server using SignalR.
Steps:
-
Drag and drop Incoming Call node
-
Open Node
-
Select / Configure server
-
Filter on Audio/Video
-
Next we are going to lookup the customers uri in a SQL database.
Steps:
-
Drag and drop MSSQL node
-
Open Node
-
Configure Connection
-
Enter Server name
-
Enter Username
-
Enter Password
-
(Optional) Enter Domain if you are using Microsoft Authentication
-
Enter Database
-
-
Enter the following Query:
-
-
Connect end of Incoming Call node to begin MSSQL node
Now we want to check if we found any results. We will do this using a switch.
Steps:
-
Drag and drop Switch node
-
Open Node
-
Add 2 rules
-
Is empty
-
Otherwise
-
-
-
Connect end of MSSQL node to begin Switch node
If there are results found, they will be stored in the msg.payload. For now we want to store this information so we can use it later. This can be done using a Change node.
Steps:
-
Drag and drop Change node
-
Open Node
-
Create 2 rules
-
Set: msg.FirstName
to: msg.payload[0].FirstName
-
Set: msg.LastName
to: msg.payload[0].LastName
-
-
-
Connect otherwise from Switch node to begin Change node
Next we want to greet the customer with there first and last name. This will be done using a Say node with an expression.
Steps:
-
Drag and drop Say node
-
Open Node
-
Change String to Expression
-
Use the following expression:
-
-
Connect end Change node to begin Say node
We also want a message if we didn't find the customer. This will be done with a Say node.
Steps:
-
Drag and drop Say node
-
Open Node
-
Enter a text notifying the customer we didn't find him.
-
-
Connect end Change node to begin Say node
Finally we want to wrap up this flow with a Disconnect node.
Steps:
-
Drag and drop Disconnect node
-
Connect end of both Say nodes to begin Disconnect node