Voicent IVR Studio 创建Http请求

IVR Studio 直接访问数据库的操作是通过Java操作的,或者是JDBC直接写sql,但是对于我这个.net不太友好,好在Http是和后端语言无关的。

Voicent的api太不清晰了,各种摸索终于实现了,备忘之。

image

  1. 准备 WebApi,这里创建的是 .net framework 4.8 的 WebApi 项目。
using System;
using System.Threading.Tasks;
using System.Web.Http;

namespace VoicentService.Controllers
{
    /// <summary>
    /// AccountController
    /// </summary>
    public class AccountController : ApiController
    {
        /// <summary>
        /// CheckNumber
        /// </summary>
        /// <param name="number"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("api/Account/CheckNumber")]
        public async Task<CheckResult> CheckNumber(CheckNumber model)
        {

            var aaa = await this.Request.Content.ReadAsStringAsync();
            //var number = "";
            //return number == "1234";
            var result = new CheckResult()
            {
                BlResult = model.Number == "1234",
                Result = "this is result from website",
                RequestTime = DateTime.Now
            };
            return result;
        }
    }

    public class CheckNumber
    {
        public string Number { get; set; }
    }

    public class CheckResult
    {
        public bool BlResult { get; set; }
        public string Result { get; set; }
        public DateTime RequestTime { get; set; }
    }
}

请求的语法

POST /VoicentService/api/Account/CheckNumber HTTP/1.1
Host: example.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 11

number=1234
  1. 打开IVR Studio,在菜单栏选择Library=>24-Hour Hotline
    image
  2. 在Information右键选择property...
  3. 切换到Action tab,选择Submit Http Action,如图填写
    image
  4. 在Prompt新增一个
    image
  5. 点击OK,然后发布到Gateway并且重启,就可以测试了。

重点是Http Server的建立以及如何和http进行交互。

参考:
https://www.voicent.com/ivr/user-guide/ivr-http-action.htm
https://www.voicent.com/ivr/user-guide/ivr-action-return-variable.htm
http://voicent.com/ivr/blog/index.php/ivr-developer/5/ivr-http-extension-send-pin-number-to-web-server

posted @ 2022-09-30 16:25  nil  阅读(19)  评论(0编辑  收藏  举报