<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>IVR World &#187; IVR for beginner</title>
	<atom:link href="http://www.ivrsworld.com/tag/ivr-for-beginner/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ivrsworld.com</link>
	<description>IVR, Interactive Voice Response System, CTI Applications</description>
	<lastBuildDate>Fri, 10 Feb 2012 09:25:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Step By Step instructions to write your first IVR Application &#8211; II</title>
		<link>http://www.ivrsworld.com/building-ivrs/step-by-step-instructions-to-write-your-first-ivr-application-ii/</link>
		<comments>http://www.ivrsworld.com/building-ivrs/step-by-step-instructions-to-write-your-first-ivr-application-ii/#comments</comments>
		<pubDate>Thu, 14 May 2009 10:02:59 +0000</pubDate>
		<dc:creator>Uttam Pegu</dc:creator>
				<category><![CDATA[Building IVRS]]></category>
		<category><![CDATA[C++ IVRS Sample Code]]></category>
		<category><![CDATA[dialogic]]></category>
		<category><![CDATA[Interactive Voice Response System]]></category>
		<category><![CDATA[IVR for beginner]]></category>
		<category><![CDATA[IVR Software India]]></category>
		<category><![CDATA[ivrs]]></category>
		<category><![CDATA[IVRS C++ Source Code]]></category>

		<guid isPermaLink="false">http://www.ivrsworld.com/?p=362</guid>
		<description><![CDATA[In my previous post about Step By Step instructions to write your first IVR Application , I wrote about installing the Dialogic D4 PCI card on PCI slot and then installing Dialogic System Release on a Windows XP machine. In this part, I intend to provide the C++ code to initialise the card, make it [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>In my previous post about <strong><a href="http://www.ivrsworld.com/building-ivrs/step-by-step-instructions-to-write-your-first-ivr-application-i/">Step By Step instructions to write your first IVR Application</a> </strong>, I wrote about installing the Dialogic D4 PCI card on PCI slot and then installing Dialogic System Release on a Windows XP machine. In this part, I intend to provide the C++ code to initialise the card, make it ready to accept a call and then when it rings, pick the call and play an WAV file!</p>
<p>1. Setup Visual Studio 6.0. Please do not forget to select install the Visual C++ 6.0.</p>
<p>2. It is assumed that you know how to use Visual Studio C++ 6.0. Start a new project IVRS. You will have to include Dialogic INC directories as well as Lib in its option. Else you will see &#8220;Compile Error&#8221;.</p>
<p>3. Every Channel in a D4 PCI card is denoted by a string dxxxBnCk where n denotes the board ID and k denotes the channel number 1 through 4. For a D4 PCI Card, the list of channels are<br />
<span id="more-362"></span>     a. dxxxB1C1<br />
     b. dxxxB1C2<br />
     c. dxxxB1C3<br />
     d. dxxxB1C4<br />
     There are other ways to find these strings to denote channels. There are also Dialogic APIs to find these. You can also check these strings attached Sample Voice application that comes with Dialogic System Release.</p>
<p>4. Now here is the C++ code.</p>
<p>  To open the first channel<br />
   int hChanell;<br />
  hChannel = dx_open(dxxxB1C1,0)</p>
<p>  If  ( hChannel != -1 )<br />
  {<br />
  AfxBeginThread(threadFunc,chidchar);<br />
 }</p>
<p>// Initialise same way for other three channels, ie. dxxxB1C2, dxxxB1C3 and dxxxB1C4</p>
<p>Now threadFunc is a Windows Thread that performs the Call Flow.</p>
<p>DV_TPT def_rp_tpt[] = {<br />
	{IO_CONT,DX_LCOFF, 4, TF_LCOFF, 0, 0, NULL},<br />
	//{IO_CONT,DX_TONE,POTS_DISCTONE,TF_TONE,DX_TONEON,0,NULL},<br />
 	{IO_EOT,DX_MAXDTMF,1,TF_MAXDTMF,0,0,NULL}</p>
<p>UINT threadFunc(LPVOID pParam)<br />
{<br />
      char *ch = (char *)pParam;<br />
	int channel = atoi(ch);<br />
	unsigned char callid[81];<br />
	memset((void *)callid, 0, 81*sizeof(char));<br />
    char UniqueId[300];</p>
<p>    char mobid[20];<br />
	char temp[100];<br />
	char channelname[20];<br />
	char callername[50];<br />
	time_t starttime,endtime;</p>
<p>	char tm[100],tm1[100];<br />
    int retval=1;</p>
<p>	FILE *file;<br />
        char szBuffer[200];</p>
<p>     int  NumRingAnswer;</p>
<p>       // Ensure the phone is kept ON HOOK<br />
	if (dx_sethook(channel,DX_ONHOOK,EV_SYNC) == -1)<br />
		{<br />
			//WinPrintf(&#8220;dx_sethook failed&#8221;);<br />
			//return(0);<br />
		}</p>
<p>         NumRingAnswer = 3; // Answer after 3 rings<br />
	while(true)<br />
	{</p>
<p>		if (dx_wtring(channel,NumRingAnswer,DX_OFFHOOK,-1) == -1)<br />
		{<br />
				print(&#8220;ERROR: dx_wtring failed. errno = %d\n,Please make sure your drivers are properly installed&#8221;, errno);<br />
				exit(0);<br />
		}</p>
<p>		// PostMessage(hWnd,WM_OFFHOOK,channel,0);</p>
<p>		if(dx_gtcallid(channel,callid)==-1)<br />
		{<br />
		    //Get the caller id<br />
			strcpy((char *)callid, &#8220;0000000000&#8243;);<br />
			strcpy((char *)mobid, &#8220;0000000000&#8243;);</p>
<p>			if (ATDV_LASTERR(channel) == EDX_CLIDBLK)<br />
			{<br />
				//printf(&#8220;Caller ID information blocked \n&#8221;);<br />
			}<br />
				else if (ATDV_LASTERR(channel) == EDX_CLIDOOA)<br />
				{<br />
				//printf(&#8220;Caller out of area \n&#8221;);<br />
				}<br />
				else {<br />
				/* Or print the pre-formatted error message */<br />
				//printf(&#8220;Error: %s \n&#8221;, ATDV_ERRMSGP(channel));<br />
				}</p>
<p>		}<br />
		switch (ATDX_TERMMSK(channel))<br />
		{<br />
			case TM_LCOFF:<br />
				//delete cml;<br />
				return false;<br />
			case TM_DIGIT:<br />
			case TM_EOD:<br />
				dx_clrdigbuf(channel);<br />
		}</p>
<p>		strcpy(callername,(char *)callid);</p>
<p>		sprintf(channelname,&#8221;%d&#8221;,channel);</p>
<p>		sprintf(UniqueId,&#8221;%d&#8221;,::GetTickCount());  // Just to generate an unique ID</p>
<p>		starttime=time(NULL);</p>
<p>		dx_clrdigbuf(channel);</p>
<p>               strcpy(szBuffer,&#8221;Welcome.wav&#8221;); // welcome.wav is the file played, it has to be 11025 KHz, PCM, 8Bit, Mono.</p>
<p>	       if(dx_playwav(channel,szBuffer,def_rp_tpt,EV_SYNC)<0)<br />
			{<br />
                           printf(ATDV_ERRMSGP(channel));<br />
                        }</p>
<p>	        tch (ATDX_TERMMSK(channel))<br />
	             {<br />
		        case TM_LCOFF:<br />
			        return false;<br />
		          case TM_DIGIT:<br />
		         case TM_EOD:<br />
			       break;<br />
	               }</p>
<p>		endtime=time(NULL);<br />
		sprintf(tm,&#8221;%s&#8221;,asctime(localtime(&#038;starttime)));<br />
		sprintf(tm1,&#8221;%s&#8221;,asctime(localtime(&#038;endtime)));<br />
              // Just to record time of call</p>
<p>		if (dx_sethook(channel,DX_ONHOOK,EV_SYNC) == -1)<br />
		{<br />
			//WinPrintf(&#8220;dx_sethook failed&#8221;);<br />
			//return(0);<br />
		}</p>
<p>		PostMessage(hWnd,WM_ONHOOK,channel,0);</p>
<p>		// if it discovers a file civrs.dat in its directory, then it closes itself.<br />
		strcpy(szDirectory[channel],defLanguage);</p>
<p>     	if ( (file=fopen(&#8220;civrs.dat&#8221;,&#8221;r&#8221;))==NULL )<br />
		{<br />
		}<br />
		else<br />
		{<br />
			exit(0);<br />
		}<br />
	}<br />
	return 1;</p>
<p>}</p>
<p>6. The variable names etc. may produce some errors! This code may not work as it is if pasted! But this code is intended for use a reference and starting point</p>
<p>I will update the code with fully working code soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ivrsworld.com/building-ivrs/step-by-step-instructions-to-write-your-first-ivr-application-ii/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

