Advertisement
Guest User

Context - AMI AI Calls

a guest
Mar 19th, 2024
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.01 KB | None | 0 0
  1. [ura-medical]
  2. exten => s,1,Answer()
  3. same => n,Set(TargetNumber=${TARGETNUM})
  4. same => n,Set(CDR(dst)=${TARGETNUM})
  5.  
  6. ; Sets the base path for recordings
  7. same => n,Set(BASEDIR=/var/spool/asterisk/monitor/${STRFTIME(${EPOCH},,%Y/%m/%d)})
  8.  
  9. ; Assemble the file name with the desired pattern
  10. same => n,Set(FILENAME=out-${CALLERID(num)}-${EXTEN}-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${UNIQUEID}.wav)
  11.  
  12. ; Start recording the call in the specified directory and file
  13. same => n,MixMonitor(${BASEDIR}/${FILENAME},ab)
  14.  
  15. ; Add prefix "71" to TargetNumber if it has 8 or 9 digits
  16. same => n,ExecIf($[${LEN(${TargetNumber})} = 8]?Set(TargetNumber=71${TargetNumber}))
  17. same => n,ExecIf($[${LEN(${TargetNumber})} = 9]?Set(TargetNumber=71${TargetNumber}))
  18.  
  19. ; Performs the query using adjusted TargetNumber
  20. same => n,Set(Result=${ODBC_GETDATE(${TargetNumber})})
  21. same => n,Set(data_query=${CUT(Result,\,,1)})
  22. same => n,Set(query_time=${CUT(Result,\,,2)})
  23. same => n,Set(query_name=${CUT(Result,\,,3)})
  24. same => n,Set(procedure=${CUT(Result,\,,4)})
  25. same => n,Set(doctor=${CUT(Result,\,,5)})
  26. same => n,Set(unit=${CUT(Result,\,,6)})
  27. same => n,Set(id_marcacao=${CUT(Result,\,,7)})
  28.  
  29. ; Compose the complete message
  30. same => n,Set(complete_message=Hello, ${name_consulta}! How are you? I am the virtual appointment assistant at MEDICAL CLINIC, and I am getting in touch to confirm your appointment with the specialty ${procedure} that is scheduled for the day ${date_consulta}, at ${hour_consulta}, with the professional ${doctor}, in unit ${unit}. If you wish to confirm this appointment, please enter one. If you wish to cancel this appointment, please Please type two. Now, if you want to reschedule, ask any questions or speak to one of our operators, type three.)
  31.  
  32. ; Print the complete message in the Asterisk console, and the Tag ID
  33. same => n,Verbose(1, Complete message value: ${complete_message})
  34. same => n,Verbose(2,Mark ID Value: ${marcacao_id})
  35.  
  36. ; Call Python script and play audio
  37. same => n,ExecIf($["${query_name}" != ""]?System(/usr/bin/python3.6 /opt/microsoft/microsoft.py "${complete_message}" "/var/lib /asterisk/sounds/microsoft/${query_name}"))
  38. same => n,ExecIf($["${query_name}" != ""]?Playback(/var/lib/asterisk/sounds/microsoft/${query_name}):NoOp)
  39. same => n,WaitExten() ; Wait for user input
  40.  
  41. ; If the person types 1 to confirm
  42. exten => 1,1,Set(STATUS=C)
  43. same => n,Set(CALLID=${TargetNumber})
  44. same => n,Verbose(1,Calling ODBC_INSERTCONFIRM with arguments: ${marking_id}, ${STATUS}, ${CALLID})
  45. same => n,Set(ODBC_INSERTCONFIRM(${marcacao_id},${STATUS},${CALLID})=)
  46. same => n,ExecIf($["${query_name}" != ""]?System(/usr/bin/python3.6 /opt/microsoft/microsoft.py "Thanks for your confirmation! Now, everything is fine for your appointment with ${doctor} on ${date_consulta} at ${hour_consulta} in the unit ${unit}. MEDICAL CLINIC thanks you for your attention, and wishes you a great day!." "/var/lib /asterisk/sounds/microsoft/${query_name}_confirmed"))
  47. same => n,Playback(/var/lib/asterisk/sounds/microsoft/${query_name}_confirmed)
  48. same => n,Hangup()
  49.  
  50. ; When the person types 2 (Want to cancel)
  51. exten => 2,1,Gosub(cancellation-confirmation,s,1)
  52.  
  53. ; If the person types 3 to speak to someone
  54. exten => 3,1,Set(STATUS=S)
  55. same => n,Set(CALLID=${TargetNumber})
  56. same => n,Verbose(1,Calling ODBC_INSERTCONFIRM with arguments: ${marking_id}, ${STATUS}, ${CALLID})
  57. same => n,Set(ODBC_INSERTCONFIRM(${marcacao_id},${STATUS},${CALLID})=)
  58. same => n,ExecIf($["${query_name}" != ""]?System(/usr/bin/python3.6 /opt/microsoft/microsoft.py "Okay! I'll forward you to our team now, one moment please." "/var/lib/asterisk/sounds/microsoft/${query_name}_encaminhar"))
  59. same => n,Playback(/var/lib/asterisk/sounds/microsoft/${query_name}_forward)
  60. same => n,Goto(ext-queues,453,1)
  61. same => n,Hangup()
  62.  
  63. [cancellation-confirmation]
  64. ; When the person types 2 (Want to cancel)
  65. exten => s,1,ExecIf($["${query_name}" != ""]?System(/usr/bin/python3.6 /opt/microsoft/microsoft.py "Are you sure you want to cancel your appointment? Press 1 to confirm your cancellation or 2 to hear your appointment information again." "/var/lib/asterisk/sounds/microsoft/${query_name}_cancel"))
  66. same => n,Background(/var/lib/asterisk/sounds/microsoft/${query_name}_cancel)
  67. same => n,WaitExten()
  68.  
  69. ; If the person types 1 after choosing option 2 (Confirms cancellation)
  70. exten => 1,1,Set(STATUS=N)
  71. same => n,Set(CALLID=${TargetNumber})
  72. same => n,Verbose(1,Calling ODBC_INSERTCONFIRM with arguments: ${marking_id}, ${STATUS}, ${CALLID})
  73. same => n,Set(ODBC_INSERTCONFIRM(${marcacao_id},${STATUS},${CALLID})=)
  74. same => n,ExecIf($["${query_name}" != ""]?System(/usr/bin/python3.6 /opt/microsoft/microsoft.py "Thank you for your attention. Your appointment has been cancelled. MEDICAL CLINIC thanks you for your attention, and wishes you a great day!" "/var/lib/asterisk/sounds/microsoft/${nome_consulta}_cancelado"))
  75. same => n,Playback(/var/lib/asterisk/sounds/microsoft/${query_name}_cancelado)
  76. same => n,Hangup()
  77.  
  78. ; If the person types 2 after choosing option 2 (Returns to beginning)
  79. exten => 2,1,Goto(ura-medical,s,1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement