Get CSV column as variable to dial

Status
Not open for further replies.

Mister VoIP NL

Gold Partner
Advanced Certified
Joined
Sep 22, 2020
Messages
35
Reaction score
18
Hi All,

I want to route calls based on incoming call number (CID) and then dial a number attached to this number in the same CSV file. I can route
the calls based on incoming number but then I want to transfer to a number accordingly.....

This is the C# script

C#:
using System.Xml;

          public class Validator
          {
            
            public bool ValidateCSV(string fileContent, string number)
            {
                  foreach (string line in fileContent.Split('\n'))
                  {
                        string[] lineParts = line.Trim().Split(',');
                        if (lineParts.Length == 2)
                        {
                              string TransferQueue = lineParts[0];
                              string customerNUMBER = lineParts[1];
                    
                              if (number == customerNUMBER)
                                    return true;
                        }
                  }
            
                  return false;
            }
      }

How can I return the value "TransferQueue" so I can use it as a parameter to transfer to?

My CSV is simple with 2 columns:

810,0123455677
811,7765432100

Where the first column is the number to dial and the second column is the Caller.ID
 
You'll need two scripts, or use the CSV Parser instead.
 
I saw the CSV parser option but cannot find this component in the Call Flow Designer? only the JSON/XML parser
 
I saw the CSV parser option but cannot find this component in the Call Flow Designer? only the JSON/XML parser
i'm using the v16 version.....and I need to use the v18 version.....

o_Oo_Oo_O
 
  • Like
Reactions: Evolute IT
  • Like
Reactions: Mister VoIP NL
In your C# script, instead of:
C#:
if (number == customerNUMBER)
    return true;

You should use:
C#:
if (number == customerNUMBER)
    return TransferQueue;

This way you return the extension to which you need to transfer. Then you use the Transfer component to send the call to that number.
 
  • Like
Reactions: Evolute IT
Thank
In your C# script, instead of:
C#:
if (number == customerNUMBER)
    return true;

You should use:
C#:
if (number == customerNUMBER)
    return TransferQueue;

This way you return the extension to which you need to transfer. Then you use the Transfer component to send the call to that number.
Thank you, but I cannot return this value like that:

Cannot implicitly convert type 'string' to 'bool'
 
Yes, you need to change the method signature to return a string instead of a bool:
public string ValidateCSV(string fileContent, string number)

Also, there is another place in which you return false, you need to change that as well and return a default extension number for the case in which the caller's number is not found.
 
  • Like
Reactions: Evolute IT
Thanks again, i'm totally lost here...now it's returning the correct values but 3CX does cannot handle the value:

String '811' was not recognized as a valid Boolean.

I'm trying the TO_BOOLEAN syntax but no luck either..
 
Looks like you have no idea of what you're doing here. First you need to understand what you want to do and how, otherwise you're shooting in the dark and will never be able to create something that works. Take your time to learn how to use the CFD, read the manual and play with the examples:
https://www.3cx.com/docs/manual/call-flow-designer-manual/
https://github.com/3cx/cfd-demos/tree/master/tutorials

If you don't have time for this, you should hire a 3CX partner to create the app for you.
 
  • Like
Reactions: Evolute IT
Looks like you have no idea of what you're doing here. First you need to understand what you want to do and how, otherwise you're shooting in the dark and will never be able to create something that works. Take your time to learn how to use the CFD, read the manual and play with the examples:
https://www.3cx.com/docs/manual/call-flow-designer-manual/
https://github.com/3cx/cfd-demos/tree/master/tutorials

If you don't have time for this, you should hire a 3CX partner to create the app for you.
First link is dead
 
Looks like you have no idea of what you're doing here. First you need to understand what you want to do and how, otherwise you're shooting in the dark and will never be able to create something that works. Take your time to learn how to use the CFD, read the manual and play with the examples:
https://www.3cx.com/docs/manual/call-flow-designer-manual/
https://github.com/3cx/cfd-demos/tree/master/tutorials

If you don't have time for this, you should hire a 3CX partner to create the app for you.
I'm working on this for 3 days straight now, so time is not an issue....i'm willing to learn this and have looked into several manuals and examples. No i'm not an c# expert but if your own documentation suggest "TO_BOOLEAN" Converts the value received to a boolean and that does not work what else...
 
First link is dead
Thanks for the heads up, this would be a good place to start instead:
https://www.3cx.com/docs/manual/cfd-building-projects/

I'm working on this for 3 days straight now, so time is not an issue....i'm willing to learn this and have looked into several manuals and examples. No i'm not an c# expert but if your own documentation suggest "TO_BOOLEAN" Converts the value received to a boolean and that does not work what else...
OK, but your logic has changed. Your C# script is not returning a boolean anymore. It's returning the extension number to which you need to transfer. So the logic after that needs to be changed as well. You will not check the result as a boolean, you need to transfer the call to the extension returned by the script.
 
  • Like
Reactions: Evolute IT
Hi edossantos,

Thank you for your patience and replies! I really want to understand what is going on through the script, so I will have a look into this. I also i'm testing with the (new) CSV parser component and that seems to have solved my problems and is less complicated too :).
 
Status
Not open for further replies.

Forum statistics

Threads
111,973
Messages
590,071
Members
164,892
Latest member
Phone1stStop