【问题标题】:Randomize buttons in chatbot Messenger generic template随机化聊天机器人 Messenger 通用模板中的按钮
【发布时间】:2016-11-17 12:21:38
【问题描述】:

我想在通用模板聊天机器人中随机化 Answer_A;Answer_B;Answer_C。

  "message":{
"attachment":{
  "type":"template",    
  "payload":{
    "template_type":"generic",
    "elements":[
      {
        "title":"' . $res ['Question'] . '",  
    "image_url":"' . $res ['Picture'] . '",       
        "buttons":[
          {
            "type":"postback",
            "title":"' . $res ['Answer_A'] . '",
            "payload":"Answer_A-' . $res ['id'] . '"
          },
          {
            "type":"postback",
            "title":"' . $res ['Answer_B'] . '",
            "payload":"Answer_B-' . $res ['id'] . '"
          },
      {
            "type":"postback",
            "title":"' . $res ['Answer_C'] . '",
            "payload":"Answer_C-' . $res ['id'] . '"
          }                               

这是一个简单的琐事聊天机器人,问题从 *csv 文件加载:

Category;Question;Answer A;Answer B;Answer C;Correct Answer
Name;Sample question?;Lorem;Ipsum;Dolores;a

你知道如何随机显示答案吗?

【问题讨论】:

    标签: php arrays shuffle messenger chatbot


    【解决方案1】:

    把元素想象成一​​个$array。您需要的只是在发送模板之前对元素数组进行洗牌。

    【讨论】:

      猜你喜欢
      • 2016-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-12
      • 1970-01-01
      • 2019-01-03
      • 1970-01-01
      相关资源
      最近更新 更多