phonic 0.30.2 → 0.30.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (428) hide show
  1. package/README.md +1 -770
  2. package/dist/cjs/Client.js +2 -2
  3. package/dist/cjs/api/resources/agents/client/Client.d.ts +3 -3
  4. package/dist/cjs/api/resources/agents/client/Client.js +27 -21
  5. package/dist/cjs/api/resources/agents/client/requests/AgentsCreateRequest.d.ts +2 -4
  6. package/dist/cjs/api/resources/agents/client/requests/AgentsDeleteRequest.d.ts +1 -3
  7. package/dist/cjs/api/resources/agents/client/requests/AgentsGetRequest.d.ts +1 -3
  8. package/dist/cjs/api/resources/agents/client/requests/AgentsListRequest.d.ts +1 -3
  9. package/dist/cjs/api/resources/agents/client/requests/UpdateAgentRequest.d.ts +2 -4
  10. package/dist/cjs/api/resources/agents/client/requests/UpsertAgentRequest.d.ts +2 -4
  11. package/dist/cjs/api/resources/conversations/client/requests/ConversationsListRequest.d.ts +9 -27
  12. package/dist/cjs/api/resources/conversations/client/requests/ConversationsSipOutboundCallRequest.d.ts +5 -15
  13. package/dist/cjs/api/resources/conversations/client/requests/OutboundCallRequest.d.ts +1 -1
  14. package/dist/cjs/api/resources/extractionSchemas/client/Client.js +20 -15
  15. package/dist/cjs/api/resources/extractionSchemas/client/requests/CreateExtractionSchemaRequest.d.ts +1 -3
  16. package/dist/cjs/api/resources/extractionSchemas/client/requests/ExtractionSchemasDeleteRequest.d.ts +1 -3
  17. package/dist/cjs/api/resources/extractionSchemas/client/requests/ExtractionSchemasGetRequest.d.ts +1 -3
  18. package/dist/cjs/api/resources/extractionSchemas/client/requests/ExtractionSchemasListRequest.d.ts +1 -3
  19. package/dist/cjs/api/resources/extractionSchemas/client/requests/UpdateExtractionSchemaRequest.d.ts +1 -3
  20. package/dist/cjs/api/resources/projects/client/Client.js +28 -21
  21. package/dist/cjs/api/resources/tools/client/Client.d.ts +10 -0
  22. package/dist/cjs/api/resources/tools/client/Client.js +30 -15
  23. package/dist/cjs/api/resources/tools/client/requests/CreateToolRequest.d.ts +15 -4
  24. package/dist/cjs/api/resources/tools/client/requests/CreateToolRequest.js +1 -0
  25. package/dist/cjs/api/resources/tools/client/requests/ToolsDeleteRequest.d.ts +1 -3
  26. package/dist/cjs/api/resources/tools/client/requests/ToolsGetRequest.d.ts +6 -3
  27. package/dist/cjs/api/resources/tools/client/requests/ToolsListRequest.d.ts +1 -3
  28. package/dist/cjs/api/resources/tools/client/requests/UpdateToolRequest.d.ts +5 -4
  29. package/dist/cjs/api/resources/tools/client/requests/UpdateToolRequest.js +1 -0
  30. package/dist/cjs/api/resources/voices/client/Client.js +8 -6
  31. package/dist/cjs/api/resources/voices/client/requests/VoicesListRequest.d.ts +1 -3
  32. package/dist/cjs/api/types/Conversation.d.ts +2 -0
  33. package/dist/cjs/api/types/ConversationItem.d.ts +0 -2
  34. package/dist/cjs/api/types/IsUserSpeakingPayload.d.ts +8 -0
  35. package/dist/cjs/api/types/IsUserSpeakingPayload.js +5 -0
  36. package/dist/cjs/api/types/OutboundCallConfig.d.ts +1 -1
  37. package/dist/cjs/api/types/Tool.d.ts +4 -1
  38. package/dist/cjs/api/types/Tool.js +1 -0
  39. package/dist/cjs/api/types/index.d.ts +1 -0
  40. package/dist/cjs/api/types/index.js +1 -0
  41. package/dist/cjs/core/auth/AuthProvider.d.ts +4 -0
  42. package/dist/cjs/core/auth/AuthProvider.js +2 -0
  43. package/dist/cjs/core/auth/AuthRequest.d.ts +9 -0
  44. package/dist/cjs/core/auth/AuthRequest.js +2 -0
  45. package/dist/cjs/core/auth/index.d.ts +2 -0
  46. package/dist/cjs/core/fetcher/Fetcher.js +2 -2
  47. package/dist/cjs/core/fetcher/index.d.ts +5 -5
  48. package/dist/cjs/core/fetcher/index.js +5 -5
  49. package/dist/cjs/version.d.ts +1 -1
  50. package/dist/cjs/version.js +1 -1
  51. package/dist/index.d.mts +76 -122
  52. package/dist/index.d.ts +76 -122
  53. package/dist/index.js +37 -52
  54. package/dist/index.mjs +37 -52
  55. package/package.json +2 -2
  56. package/reference.md +4 -4
  57. package/dist/esm/Client.d.mts +0 -50
  58. package/dist/esm/Client.mjs +0 -47
  59. package/dist/esm/api/errors/BadRequestError.d.mts +0 -8
  60. package/dist/esm/api/errors/BadRequestError.mjs +0 -15
  61. package/dist/esm/api/errors/ConflictError.d.mts +0 -8
  62. package/dist/esm/api/errors/ConflictError.mjs +0 -15
  63. package/dist/esm/api/errors/ForbiddenError.d.mts +0 -8
  64. package/dist/esm/api/errors/ForbiddenError.mjs +0 -15
  65. package/dist/esm/api/errors/GatewayTimeoutError.d.mts +0 -9
  66. package/dist/esm/api/errors/GatewayTimeoutError.mjs +0 -15
  67. package/dist/esm/api/errors/InternalServerError.d.mts +0 -9
  68. package/dist/esm/api/errors/InternalServerError.mjs +0 -15
  69. package/dist/esm/api/errors/NotFoundError.d.mts +0 -8
  70. package/dist/esm/api/errors/NotFoundError.mjs +0 -15
  71. package/dist/esm/api/errors/UnauthorizedError.d.mts +0 -9
  72. package/dist/esm/api/errors/UnauthorizedError.mjs +0 -15
  73. package/dist/esm/api/errors/index.d.mts +0 -7
  74. package/dist/esm/api/errors/index.mjs +0 -7
  75. package/dist/esm/api/index.d.mts +0 -4
  76. package/dist/esm/api/index.mjs +0 -4
  77. package/dist/esm/api/resources/agents/client/Client.d.mts +0 -208
  78. package/dist/esm/api/resources/agents/client/Client.mjs +0 -552
  79. package/dist/esm/api/resources/agents/client/index.d.mts +0 -2
  80. package/dist/esm/api/resources/agents/client/index.mjs +0 -1
  81. package/dist/esm/api/resources/agents/client/requests/AgentsCreateRequest.d.mts +0 -43
  82. package/dist/esm/api/resources/agents/client/requests/AgentsCreateRequest.mjs +0 -4
  83. package/dist/esm/api/resources/agents/client/requests/AgentsDeleteRequest.d.mts +0 -15
  84. package/dist/esm/api/resources/agents/client/requests/AgentsDeleteRequest.mjs +0 -4
  85. package/dist/esm/api/resources/agents/client/requests/AgentsGetRequest.d.mts +0 -15
  86. package/dist/esm/api/resources/agents/client/requests/AgentsGetRequest.mjs +0 -4
  87. package/dist/esm/api/resources/agents/client/requests/AgentsListRequest.d.mts +0 -13
  88. package/dist/esm/api/resources/agents/client/requests/AgentsListRequest.mjs +0 -4
  89. package/dist/esm/api/resources/agents/client/requests/UpdateAgentRequest.d.mts +0 -104
  90. package/dist/esm/api/resources/agents/client/requests/UpdateAgentRequest.mjs +0 -10
  91. package/dist/esm/api/resources/agents/client/requests/UpsertAgentRequest.d.mts +0 -40
  92. package/dist/esm/api/resources/agents/client/requests/UpsertAgentRequest.mjs +0 -4
  93. package/dist/esm/api/resources/agents/client/requests/index.d.mts +0 -6
  94. package/dist/esm/api/resources/agents/client/requests/index.mjs +0 -1
  95. package/dist/esm/api/resources/agents/index.d.mts +0 -2
  96. package/dist/esm/api/resources/agents/index.mjs +0 -2
  97. package/dist/esm/api/resources/agents/types/AgentsCreateResponse.d.mts +0 -9
  98. package/dist/esm/api/resources/agents/types/AgentsCreateResponse.mjs +0 -4
  99. package/dist/esm/api/resources/agents/types/AgentsDeleteResponse.d.mts +0 -7
  100. package/dist/esm/api/resources/agents/types/AgentsDeleteResponse.mjs +0 -4
  101. package/dist/esm/api/resources/agents/types/AgentsGetResponse.d.mts +0 -7
  102. package/dist/esm/api/resources/agents/types/AgentsGetResponse.mjs +0 -4
  103. package/dist/esm/api/resources/agents/types/AgentsListResponse.d.mts +0 -7
  104. package/dist/esm/api/resources/agents/types/AgentsListResponse.mjs +0 -4
  105. package/dist/esm/api/resources/agents/types/AgentsUpdateResponse.d.mts +0 -7
  106. package/dist/esm/api/resources/agents/types/AgentsUpdateResponse.mjs +0 -4
  107. package/dist/esm/api/resources/agents/types/AgentsUpsertResponse.d.mts +0 -11
  108. package/dist/esm/api/resources/agents/types/AgentsUpsertResponse.mjs +0 -4
  109. package/dist/esm/api/resources/agents/types/index.d.mts +0 -6
  110. package/dist/esm/api/resources/agents/types/index.mjs +0 -6
  111. package/dist/esm/api/resources/conversations/client/Client.d.mts +0 -236
  112. package/dist/esm/api/resources/conversations/client/Client.mjs +0 -858
  113. package/dist/esm/api/resources/conversations/client/Socket.d.mts +0 -64
  114. package/dist/esm/api/resources/conversations/client/Socket.mjs +0 -159
  115. package/dist/esm/api/resources/conversations/client/index.d.mts +0 -2
  116. package/dist/esm/api/resources/conversations/client/index.mjs +0 -1
  117. package/dist/esm/api/resources/conversations/client/requests/ConversationsListRequest.d.mts +0 -48
  118. package/dist/esm/api/resources/conversations/client/requests/ConversationsListRequest.mjs +0 -4
  119. package/dist/esm/api/resources/conversations/client/requests/ConversationsSipOutboundCallRequest.d.mts +0 -39
  120. package/dist/esm/api/resources/conversations/client/requests/ConversationsSipOutboundCallRequest.mjs +0 -4
  121. package/dist/esm/api/resources/conversations/client/requests/EvaluateConversationRequest.d.mts +0 -13
  122. package/dist/esm/api/resources/conversations/client/requests/EvaluateConversationRequest.mjs +0 -4
  123. package/dist/esm/api/resources/conversations/client/requests/ExtractDataRequest.d.mts +0 -13
  124. package/dist/esm/api/resources/conversations/client/requests/ExtractDataRequest.mjs +0 -4
  125. package/dist/esm/api/resources/conversations/client/requests/OutboundCallRequest.d.mts +0 -30
  126. package/dist/esm/api/resources/conversations/client/requests/OutboundCallRequest.mjs +0 -4
  127. package/dist/esm/api/resources/conversations/client/requests/index.d.mts +0 -5
  128. package/dist/esm/api/resources/conversations/client/requests/index.mjs +0 -1
  129. package/dist/esm/api/resources/conversations/index.d.mts +0 -2
  130. package/dist/esm/api/resources/conversations/index.mjs +0 -2
  131. package/dist/esm/api/resources/conversations/types/ConversationsCancelResponse.d.mts +0 -7
  132. package/dist/esm/api/resources/conversations/types/ConversationsCancelResponse.mjs +0 -4
  133. package/dist/esm/api/resources/conversations/types/ConversationsExtractDataResponse.d.mts +0 -7
  134. package/dist/esm/api/resources/conversations/types/ConversationsExtractDataResponse.mjs +0 -4
  135. package/dist/esm/api/resources/conversations/types/ConversationsGetAnalysisResponse.d.mts +0 -7
  136. package/dist/esm/api/resources/conversations/types/ConversationsGetAnalysisResponse.mjs +0 -4
  137. package/dist/esm/api/resources/conversations/types/ConversationsGetResponse.d.mts +0 -7
  138. package/dist/esm/api/resources/conversations/types/ConversationsGetResponse.mjs +0 -4
  139. package/dist/esm/api/resources/conversations/types/ConversationsListEvaluationsResponse.d.mts +0 -7
  140. package/dist/esm/api/resources/conversations/types/ConversationsListEvaluationsResponse.mjs +0 -4
  141. package/dist/esm/api/resources/conversations/types/ConversationsListExtractionsResponse.d.mts +0 -7
  142. package/dist/esm/api/resources/conversations/types/ConversationsListExtractionsResponse.mjs +0 -4
  143. package/dist/esm/api/resources/conversations/types/ConversationsListResponse.d.mts +0 -9
  144. package/dist/esm/api/resources/conversations/types/ConversationsListResponse.mjs +0 -4
  145. package/dist/esm/api/resources/conversations/types/ConversationsOutboundCallResponse.d.mts +0 -7
  146. package/dist/esm/api/resources/conversations/types/ConversationsOutboundCallResponse.mjs +0 -4
  147. package/dist/esm/api/resources/conversations/types/ConversationsSipOutboundCallResponse.d.mts +0 -7
  148. package/dist/esm/api/resources/conversations/types/ConversationsSipOutboundCallResponse.mjs +0 -4
  149. package/dist/esm/api/resources/conversations/types/index.d.mts +0 -9
  150. package/dist/esm/api/resources/conversations/types/index.mjs +0 -9
  151. package/dist/esm/api/resources/extractionSchemas/client/Client.d.mts +0 -142
  152. package/dist/esm/api/resources/extractionSchemas/client/Client.mjs +0 -431
  153. package/dist/esm/api/resources/extractionSchemas/client/index.d.mts +0 -2
  154. package/dist/esm/api/resources/extractionSchemas/client/index.mjs +0 -1
  155. package/dist/esm/api/resources/extractionSchemas/client/requests/CreateExtractionSchemaRequest.d.mts +0 -37
  156. package/dist/esm/api/resources/extractionSchemas/client/requests/CreateExtractionSchemaRequest.mjs +0 -4
  157. package/dist/esm/api/resources/extractionSchemas/client/requests/ExtractionSchemasDeleteRequest.d.mts +0 -15
  158. package/dist/esm/api/resources/extractionSchemas/client/requests/ExtractionSchemasDeleteRequest.mjs +0 -4
  159. package/dist/esm/api/resources/extractionSchemas/client/requests/ExtractionSchemasGetRequest.d.mts +0 -15
  160. package/dist/esm/api/resources/extractionSchemas/client/requests/ExtractionSchemasGetRequest.mjs +0 -4
  161. package/dist/esm/api/resources/extractionSchemas/client/requests/ExtractionSchemasListRequest.d.mts +0 -15
  162. package/dist/esm/api/resources/extractionSchemas/client/requests/ExtractionSchemasListRequest.mjs +0 -4
  163. package/dist/esm/api/resources/extractionSchemas/client/requests/UpdateExtractionSchemaRequest.d.mts +0 -33
  164. package/dist/esm/api/resources/extractionSchemas/client/requests/UpdateExtractionSchemaRequest.mjs +0 -4
  165. package/dist/esm/api/resources/extractionSchemas/client/requests/index.d.mts +0 -5
  166. package/dist/esm/api/resources/extractionSchemas/client/requests/index.mjs +0 -1
  167. package/dist/esm/api/resources/extractionSchemas/index.d.mts +0 -2
  168. package/dist/esm/api/resources/extractionSchemas/index.mjs +0 -2
  169. package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasCreateResponse.d.mts +0 -9
  170. package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasCreateResponse.mjs +0 -4
  171. package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasDeleteResponse.d.mts +0 -7
  172. package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasDeleteResponse.mjs +0 -4
  173. package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasGetResponse.d.mts +0 -7
  174. package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasGetResponse.mjs +0 -4
  175. package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasListResponse.d.mts +0 -7
  176. package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasListResponse.mjs +0 -4
  177. package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasUpdateResponse.d.mts +0 -7
  178. package/dist/esm/api/resources/extractionSchemas/types/ExtractionSchemasUpdateResponse.mjs +0 -4
  179. package/dist/esm/api/resources/extractionSchemas/types/index.d.mts +0 -5
  180. package/dist/esm/api/resources/extractionSchemas/types/index.mjs +0 -5
  181. package/dist/esm/api/resources/index.d.mts +0 -18
  182. package/dist/esm/api/resources/index.mjs +0 -18
  183. package/dist/esm/api/resources/projects/client/Client.d.mts +0 -157
  184. package/dist/esm/api/resources/projects/client/Client.mjs +0 -540
  185. package/dist/esm/api/resources/projects/client/index.d.mts +0 -2
  186. package/dist/esm/api/resources/projects/client/index.mjs +0 -1
  187. package/dist/esm/api/resources/projects/client/requests/CreateConversationEvalPromptRequest.d.mts +0 -16
  188. package/dist/esm/api/resources/projects/client/requests/CreateConversationEvalPromptRequest.mjs +0 -4
  189. package/dist/esm/api/resources/projects/client/requests/CreateProjectRequest.d.mts +0 -13
  190. package/dist/esm/api/resources/projects/client/requests/CreateProjectRequest.mjs +0 -4
  191. package/dist/esm/api/resources/projects/client/requests/UpdateProjectRequest.d.mts +0 -15
  192. package/dist/esm/api/resources/projects/client/requests/UpdateProjectRequest.mjs +0 -4
  193. package/dist/esm/api/resources/projects/client/requests/index.d.mts +0 -3
  194. package/dist/esm/api/resources/projects/client/requests/index.mjs +0 -1
  195. package/dist/esm/api/resources/projects/index.d.mts +0 -2
  196. package/dist/esm/api/resources/projects/index.mjs +0 -2
  197. package/dist/esm/api/resources/projects/types/ProjectsCreateEvalPromptResponse.d.mts +0 -7
  198. package/dist/esm/api/resources/projects/types/ProjectsCreateEvalPromptResponse.mjs +0 -4
  199. package/dist/esm/api/resources/projects/types/ProjectsCreateResponse.d.mts +0 -9
  200. package/dist/esm/api/resources/projects/types/ProjectsCreateResponse.mjs +0 -4
  201. package/dist/esm/api/resources/projects/types/ProjectsDeleteResponse.d.mts +0 -7
  202. package/dist/esm/api/resources/projects/types/ProjectsDeleteResponse.mjs +0 -4
  203. package/dist/esm/api/resources/projects/types/ProjectsGetResponse.d.mts +0 -7
  204. package/dist/esm/api/resources/projects/types/ProjectsGetResponse.mjs +0 -4
  205. package/dist/esm/api/resources/projects/types/ProjectsListEvalPromptsResponse.d.mts +0 -7
  206. package/dist/esm/api/resources/projects/types/ProjectsListEvalPromptsResponse.mjs +0 -4
  207. package/dist/esm/api/resources/projects/types/ProjectsListResponse.d.mts +0 -7
  208. package/dist/esm/api/resources/projects/types/ProjectsListResponse.mjs +0 -4
  209. package/dist/esm/api/resources/projects/types/ProjectsUpdateResponse.d.mts +0 -7
  210. package/dist/esm/api/resources/projects/types/ProjectsUpdateResponse.mjs +0 -4
  211. package/dist/esm/api/resources/projects/types/index.d.mts +0 -7
  212. package/dist/esm/api/resources/projects/types/index.mjs +0 -7
  213. package/dist/esm/api/resources/tools/client/Client.d.mts +0 -160
  214. package/dist/esm/api/resources/tools/client/Client.mjs +0 -442
  215. package/dist/esm/api/resources/tools/client/index.d.mts +0 -2
  216. package/dist/esm/api/resources/tools/client/index.mjs +0 -1
  217. package/dist/esm/api/resources/tools/client/requests/CreateToolRequest.d.mts +0 -92
  218. package/dist/esm/api/resources/tools/client/requests/CreateToolRequest.mjs +0 -14
  219. package/dist/esm/api/resources/tools/client/requests/ToolsDeleteRequest.d.mts +0 -15
  220. package/dist/esm/api/resources/tools/client/requests/ToolsDeleteRequest.mjs +0 -4
  221. package/dist/esm/api/resources/tools/client/requests/ToolsGetRequest.d.mts +0 -20
  222. package/dist/esm/api/resources/tools/client/requests/ToolsGetRequest.mjs +0 -4
  223. package/dist/esm/api/resources/tools/client/requests/ToolsListRequest.d.mts +0 -15
  224. package/dist/esm/api/resources/tools/client/requests/ToolsListRequest.mjs +0 -4
  225. package/dist/esm/api/resources/tools/client/requests/UpdateToolRequest.d.mts +0 -54
  226. package/dist/esm/api/resources/tools/client/requests/UpdateToolRequest.mjs +0 -14
  227. package/dist/esm/api/resources/tools/client/requests/index.d.mts +0 -5
  228. package/dist/esm/api/resources/tools/client/requests/index.mjs +0 -1
  229. package/dist/esm/api/resources/tools/index.d.mts +0 -2
  230. package/dist/esm/api/resources/tools/index.mjs +0 -2
  231. package/dist/esm/api/resources/tools/types/ToolsCreateResponse.d.mts +0 -9
  232. package/dist/esm/api/resources/tools/types/ToolsCreateResponse.mjs +0 -4
  233. package/dist/esm/api/resources/tools/types/ToolsDeleteResponse.d.mts +0 -7
  234. package/dist/esm/api/resources/tools/types/ToolsDeleteResponse.mjs +0 -4
  235. package/dist/esm/api/resources/tools/types/ToolsGetResponse.d.mts +0 -7
  236. package/dist/esm/api/resources/tools/types/ToolsGetResponse.mjs +0 -4
  237. package/dist/esm/api/resources/tools/types/ToolsListResponse.d.mts +0 -7
  238. package/dist/esm/api/resources/tools/types/ToolsListResponse.mjs +0 -4
  239. package/dist/esm/api/resources/tools/types/ToolsUpdateResponse.d.mts +0 -7
  240. package/dist/esm/api/resources/tools/types/ToolsUpdateResponse.mjs +0 -4
  241. package/dist/esm/api/resources/tools/types/index.d.mts +0 -5
  242. package/dist/esm/api/resources/tools/types/index.mjs +0 -5
  243. package/dist/esm/api/resources/voices/client/Client.d.mts +0 -65
  244. package/dist/esm/api/resources/voices/client/Client.mjs +0 -166
  245. package/dist/esm/api/resources/voices/client/index.d.mts +0 -2
  246. package/dist/esm/api/resources/voices/client/index.mjs +0 -1
  247. package/dist/esm/api/resources/voices/client/requests/VoicesListRequest.d.mts +0 -15
  248. package/dist/esm/api/resources/voices/client/requests/VoicesListRequest.mjs +0 -4
  249. package/dist/esm/api/resources/voices/client/requests/index.d.mts +0 -1
  250. package/dist/esm/api/resources/voices/client/requests/index.mjs +0 -1
  251. package/dist/esm/api/resources/voices/index.d.mts +0 -2
  252. package/dist/esm/api/resources/voices/index.mjs +0 -2
  253. package/dist/esm/api/resources/voices/types/VoicesGetResponse.d.mts +0 -7
  254. package/dist/esm/api/resources/voices/types/VoicesGetResponse.mjs +0 -4
  255. package/dist/esm/api/resources/voices/types/VoicesListResponse.d.mts +0 -7
  256. package/dist/esm/api/resources/voices/types/VoicesListResponse.mjs +0 -4
  257. package/dist/esm/api/resources/voices/types/index.d.mts +0 -2
  258. package/dist/esm/api/resources/voices/types/index.mjs +0 -2
  259. package/dist/esm/api/types/Agent.d.mts +0 -80
  260. package/dist/esm/api/types/Agent.mjs +0 -10
  261. package/dist/esm/api/types/AssistantChoseNotToRespondPayload.d.mts +0 -6
  262. package/dist/esm/api/types/AssistantChoseNotToRespondPayload.mjs +0 -4
  263. package/dist/esm/api/types/AssistantEndedConversationPayload.d.mts +0 -6
  264. package/dist/esm/api/types/AssistantEndedConversationPayload.mjs +0 -4
  265. package/dist/esm/api/types/AudioChunkPayload.d.mts +0 -10
  266. package/dist/esm/api/types/AudioChunkPayload.mjs +0 -4
  267. package/dist/esm/api/types/AudioChunkResponsePayload.d.mts +0 -10
  268. package/dist/esm/api/types/AudioChunkResponsePayload.mjs +0 -4
  269. package/dist/esm/api/types/AudioFinishedPayload.d.mts +0 -6
  270. package/dist/esm/api/types/AudioFinishedPayload.mjs +0 -4
  271. package/dist/esm/api/types/BadRequestErrorBody.d.mts +0 -5
  272. package/dist/esm/api/types/BadRequestErrorBody.mjs +0 -4
  273. package/dist/esm/api/types/BasicError.d.mts +0 -14
  274. package/dist/esm/api/types/BasicError.mjs +0 -4
  275. package/dist/esm/api/types/ConfigPayload.d.mts +0 -66
  276. package/dist/esm/api/types/ConfigPayload.mjs +0 -14
  277. package/dist/esm/api/types/Conversation.d.mts +0 -49
  278. package/dist/esm/api/types/Conversation.mjs +0 -4
  279. package/dist/esm/api/types/ConversationAnalysis.d.mts +0 -9
  280. package/dist/esm/api/types/ConversationAnalysis.mjs +0 -4
  281. package/dist/esm/api/types/ConversationCreatedPayload.d.mts +0 -8
  282. package/dist/esm/api/types/ConversationCreatedPayload.mjs +0 -4
  283. package/dist/esm/api/types/ConversationEval.d.mts +0 -4
  284. package/dist/esm/api/types/ConversationEval.mjs +0 -4
  285. package/dist/esm/api/types/ConversationEvalPrompt.d.mts +0 -11
  286. package/dist/esm/api/types/ConversationEvalPrompt.mjs +0 -4
  287. package/dist/esm/api/types/ConversationEvaluation.d.mts +0 -8
  288. package/dist/esm/api/types/ConversationEvaluation.mjs +0 -4
  289. package/dist/esm/api/types/ConversationEvaluationResult.d.mts +0 -32
  290. package/dist/esm/api/types/ConversationEvaluationResult.mjs +0 -12
  291. package/dist/esm/api/types/ConversationExtraction.d.mts +0 -22
  292. package/dist/esm/api/types/ConversationExtraction.mjs +0 -4
  293. package/dist/esm/api/types/ConversationItem.d.mts +0 -33
  294. package/dist/esm/api/types/ConversationItem.mjs +0 -10
  295. package/dist/esm/api/types/CreateAgentRequest.d.mts +0 -70
  296. package/dist/esm/api/types/CreateAgentRequest.mjs +0 -10
  297. package/dist/esm/api/types/DtmfPayload.d.mts +0 -8
  298. package/dist/esm/api/types/DtmfPayload.mjs +0 -4
  299. package/dist/esm/api/types/ErrorPayload.d.mts +0 -17
  300. package/dist/esm/api/types/ErrorPayload.mjs +0 -4
  301. package/dist/esm/api/types/Error_.d.mts +0 -5
  302. package/dist/esm/api/types/Error_.mjs +0 -4
  303. package/dist/esm/api/types/ExtractionField.d.mts +0 -23
  304. package/dist/esm/api/types/ExtractionField.mjs +0 -12
  305. package/dist/esm/api/types/ExtractionSchema.d.mts +0 -14
  306. package/dist/esm/api/types/ExtractionSchema.mjs +0 -4
  307. package/dist/esm/api/types/InputCancelledPayload.d.mts +0 -6
  308. package/dist/esm/api/types/InputCancelledPayload.mjs +0 -4
  309. package/dist/esm/api/types/InputTextPayload.d.mts +0 -8
  310. package/dist/esm/api/types/InputTextPayload.mjs +0 -4
  311. package/dist/esm/api/types/InterruptedResponsePayload.d.mts +0 -8
  312. package/dist/esm/api/types/InterruptedResponsePayload.mjs +0 -4
  313. package/dist/esm/api/types/OutboundCallConfig.d.mts +0 -39
  314. package/dist/esm/api/types/OutboundCallConfig.mjs +0 -4
  315. package/dist/esm/api/types/Project.d.mts +0 -22
  316. package/dist/esm/api/types/Project.mjs +0 -4
  317. package/dist/esm/api/types/ReadyToStartConversationPayload.d.mts +0 -6
  318. package/dist/esm/api/types/ReadyToStartConversationPayload.mjs +0 -4
  319. package/dist/esm/api/types/SetExternalIdPayload.d.mts +0 -8
  320. package/dist/esm/api/types/SetExternalIdPayload.mjs +0 -4
  321. package/dist/esm/api/types/SetTwilioCallSidPayload.d.mts +0 -8
  322. package/dist/esm/api/types/SetTwilioCallSidPayload.mjs +0 -4
  323. package/dist/esm/api/types/Task.d.mts +0 -9
  324. package/dist/esm/api/types/Task.mjs +0 -4
  325. package/dist/esm/api/types/Tool.d.mts +0 -51
  326. package/dist/esm/api/types/Tool.mjs +0 -14
  327. package/dist/esm/api/types/ToolCallInterruptedPayload.d.mts +0 -12
  328. package/dist/esm/api/types/ToolCallInterruptedPayload.mjs +0 -4
  329. package/dist/esm/api/types/ToolCallOutputPayload.d.mts +0 -9
  330. package/dist/esm/api/types/ToolCallOutputPayload.mjs +0 -4
  331. package/dist/esm/api/types/ToolCallOutputProcessedPayload.d.mts +0 -35
  332. package/dist/esm/api/types/ToolCallOutputProcessedPayload.mjs +0 -4
  333. package/dist/esm/api/types/ToolCallPayload.d.mts +0 -12
  334. package/dist/esm/api/types/ToolCallPayload.mjs +0 -4
  335. package/dist/esm/api/types/ToolParameter.d.mts +0 -38
  336. package/dist/esm/api/types/ToolParameter.mjs +0 -19
  337. package/dist/esm/api/types/UpdateSystemPromptPayload.d.mts +0 -8
  338. package/dist/esm/api/types/UpdateSystemPromptPayload.mjs +0 -4
  339. package/dist/esm/api/types/UserFinishedSpeakingPayload.d.mts +0 -6
  340. package/dist/esm/api/types/UserFinishedSpeakingPayload.mjs +0 -4
  341. package/dist/esm/api/types/UserStartedSpeakingPayload.d.mts +0 -6
  342. package/dist/esm/api/types/UserStartedSpeakingPayload.mjs +0 -4
  343. package/dist/esm/api/types/ValidationError.d.mts +0 -14
  344. package/dist/esm/api/types/ValidationError.mjs +0 -4
  345. package/dist/esm/api/types/Voice.d.mts +0 -11
  346. package/dist/esm/api/types/Voice.mjs +0 -4
  347. package/dist/esm/api/types/index.d.mts +0 -44
  348. package/dist/esm/api/types/index.mjs +0 -44
  349. package/dist/esm/api/types/overrides.d.mts +0 -50
  350. package/dist/esm/api/types/overrides.mjs +0 -1
  351. package/dist/esm/core/auth/BasicAuth.d.mts +0 -8
  352. package/dist/esm/core/auth/BasicAuth.mjs +0 -23
  353. package/dist/esm/core/auth/BearerToken.d.mts +0 -5
  354. package/dist/esm/core/auth/BearerToken.mjs +0 -12
  355. package/dist/esm/core/auth/index.d.mts +0 -2
  356. package/dist/esm/core/auth/index.mjs +0 -2
  357. package/dist/esm/core/base64.d.mts +0 -2
  358. package/dist/esm/core/base64.mjs +0 -22
  359. package/dist/esm/core/fetcher/APIResponse.d.mts +0 -20
  360. package/dist/esm/core/fetcher/APIResponse.mjs +0 -1
  361. package/dist/esm/core/fetcher/BinaryResponse.d.mts +0 -20
  362. package/dist/esm/core/fetcher/BinaryResponse.mjs +0 -14
  363. package/dist/esm/core/fetcher/Fetcher.d.mts +0 -40
  364. package/dist/esm/core/fetcher/Fetcher.mjs +0 -116
  365. package/dist/esm/core/fetcher/Headers.d.mts +0 -2
  366. package/dist/esm/core/fetcher/Headers.mjs +0 -82
  367. package/dist/esm/core/fetcher/HttpResponsePromise.d.mts +0 -58
  368. package/dist/esm/core/fetcher/HttpResponsePromise.mjs +0 -99
  369. package/dist/esm/core/fetcher/RawResponse.d.mts +0 -29
  370. package/dist/esm/core/fetcher/RawResponse.mjs +0 -40
  371. package/dist/esm/core/fetcher/ResponseWithBody.d.mts +0 -4
  372. package/dist/esm/core/fetcher/ResponseWithBody.mjs +0 -3
  373. package/dist/esm/core/fetcher/Supplier.d.mts +0 -4
  374. package/dist/esm/core/fetcher/Supplier.mjs +0 -19
  375. package/dist/esm/core/fetcher/createRequestUrl.d.mts +0 -1
  376. package/dist/esm/core/fetcher/createRequestUrl.mjs +0 -5
  377. package/dist/esm/core/fetcher/getErrorResponseBody.d.mts +0 -1
  378. package/dist/esm/core/fetcher/getErrorResponseBody.mjs +0 -41
  379. package/dist/esm/core/fetcher/getFetchFn.d.mts +0 -1
  380. package/dist/esm/core/fetcher/getFetchFn.mjs +0 -14
  381. package/dist/esm/core/fetcher/getHeader.d.mts +0 -1
  382. package/dist/esm/core/fetcher/getHeader.mjs +0 -8
  383. package/dist/esm/core/fetcher/getRequestBody.d.mts +0 -7
  384. package/dist/esm/core/fetcher/getRequestBody.mjs +0 -20
  385. package/dist/esm/core/fetcher/getResponseBody.d.mts +0 -1
  386. package/dist/esm/core/fetcher/getResponseBody.mjs +0 -52
  387. package/dist/esm/core/fetcher/index.d.mts +0 -9
  388. package/dist/esm/core/fetcher/index.mjs +0 -5
  389. package/dist/esm/core/fetcher/makeRequest.d.mts +0 -1
  390. package/dist/esm/core/fetcher/makeRequest.mjs +0 -38
  391. package/dist/esm/core/fetcher/requestWithRetries.d.mts +0 -1
  392. package/dist/esm/core/fetcher/requestWithRetries.mjs +0 -37
  393. package/dist/esm/core/fetcher/signals.d.mts +0 -11
  394. package/dist/esm/core/fetcher/signals.mjs +0 -32
  395. package/dist/esm/core/headers.d.mts +0 -3
  396. package/dist/esm/core/headers.mjs +0 -25
  397. package/dist/esm/core/index.d.mts +0 -6
  398. package/dist/esm/core/index.mjs +0 -6
  399. package/dist/esm/core/json.d.mts +0 -15
  400. package/dist/esm/core/json.mjs +0 -19
  401. package/dist/esm/core/runtime/index.d.mts +0 -1
  402. package/dist/esm/core/runtime/index.mjs +0 -1
  403. package/dist/esm/core/runtime/runtime.d.mts +0 -9
  404. package/dist/esm/core/runtime/runtime.mjs +0 -99
  405. package/dist/esm/core/url/index.d.mts +0 -2
  406. package/dist/esm/core/url/index.mjs +0 -2
  407. package/dist/esm/core/url/join.d.mts +0 -1
  408. package/dist/esm/core/url/join.mjs +0 -66
  409. package/dist/esm/core/url/qs.d.mts +0 -6
  410. package/dist/esm/core/url/qs.mjs +0 -61
  411. package/dist/esm/core/websocket/events.d.mts +0 -36
  412. package/dist/esm/core/websocket/events.mjs +0 -21
  413. package/dist/esm/core/websocket/index.d.mts +0 -1
  414. package/dist/esm/core/websocket/index.mjs +0 -1
  415. package/dist/esm/core/websocket/ws.d.mts +0 -147
  416. package/dist/esm/core/websocket/ws.mjs +0 -423
  417. package/dist/esm/environments.d.mts +0 -14
  418. package/dist/esm/environments.mjs +0 -9
  419. package/dist/esm/errors/PhonicError.d.mts +0 -15
  420. package/dist/esm/errors/PhonicError.mjs +0 -26
  421. package/dist/esm/errors/PhonicTimeoutError.d.mts +0 -6
  422. package/dist/esm/errors/PhonicTimeoutError.mjs +0 -9
  423. package/dist/esm/errors/index.d.mts +0 -2
  424. package/dist/esm/errors/index.mjs +0 -2
  425. package/dist/esm/index.d.mts +0 -4
  426. package/dist/esm/index.mjs +0 -4
  427. package/dist/esm/version.d.mts +0 -1
  428. package/dist/esm/version.mjs +0 -1
package/README.md CHANGED
@@ -11,775 +11,6 @@ The Phonic TypeScript library provides convenient access to the Phonic API from
11
11
  npm i -s phonic
12
12
  ```
13
13
 
14
- ## Setup
15
-
16
- Grab an API key from the [Phonic API Keys](https://phonic.co/api-keys) section and pass it to the Phonic constructor.
17
-
18
- ```ts
19
- import { Phonic } from "phonic";
20
-
21
- const phonic = new Phonic("ph_...");
22
- ```
23
-
24
- ## Agents
25
-
26
- ### List agents
27
-
28
- ```ts
29
- const result = await phonic.agents.list({ project: "main" });
30
- ```
31
-
32
- ### Get agent
33
-
34
- Returns an agent by name or ID.
35
-
36
- ```ts
37
- const result = await phonic.agents.get("chris", { project: "main" });
38
- ```
39
-
40
- ### Create agent
41
-
42
- ```ts
43
- const result = await phonic.agents.create({
44
- name: "chris",
45
-
46
- // Optional fields
47
- project: "main", // Defaults to "main"
48
- phoneNumber: "assign-automatically", // Defaults to null
49
- timezone: "Australia/Melbourne", // Defaults to "America/Los_Angeles"
50
- audioFormat: "mulaw_8000", // Defaults to "pcm_44100". Must be "mulaw_8000" when `phoneNumber` is "assign-automatically"
51
- voiceId: "sarah", // Defaults to "grant"
52
- audioSpeed: 1.1, // Defaults to 1.0. Must be between 0.5 and 1.5, multiple of 0.1
53
- welcomeMessage: "Hello, how can I help you?", // Defaults to ""
54
- systemPrompt: "You are an expert in {{subject}}. Be kind to {{user_name}}.", // Defaults to "Respond in 1-2 sentences."
55
- templateVariables: {
56
- subject: {
57
- defaultValue: "Maths",
58
- },
59
- user_name: {
60
- defaultValue: null,
61
- },
62
- },
63
- tools: ["keypad_input", "natural_conversation_ending", "my-custom-tool"], // Defaults to []
64
- noInputPokeSec: 30, // Defaults to null
65
- noInputPokeText: "Hey, are you with me?", // Defaults to "Are you still there?"
66
- noInputEndConversationSec: 150, // Defaults to 180
67
- boostedKeywords: ["Salamanca Market", "Bonorong Wildlife Sanctuary"], // Defaults to []
68
- configurationEndpoint: {
69
- url: "https://myapp.com/webhooks/phonic-config",
70
- headers: {
71
- Authorization: "Bearer 123",
72
- },
73
- timeoutMs: 10000, // Defaults to 3000
74
- }, // Defaults to null
75
- });
76
- ```
77
-
78
- ### Update agent
79
-
80
- ```ts
81
- const result = await phonic.agents.update("chris", {
82
- name: "chris",
83
-
84
- // Optional fields
85
- project: "main",
86
- phoneNumber: "assign-automatically", // or null
87
- timezone: "Australia/Melbourne",
88
- voiceId: "sarah",
89
- audioFormat: "mulaw_8000", // Must be "mulaw_8000" when `phoneNumber` is "assign-automatically"
90
- audioSpeed: 1.1, // Must be between 0.5 and 1.5, multiple of 0.1
91
- welcomeMessage: "Hello, how can I help you?",
92
- systemPrompt: "You are an expert in {{subject}}. Be kind to {{user_name}}.",
93
- templateVariables: {
94
- subject: {
95
- defaultValue: "Maths",
96
- },
97
- user_name: {
98
- defaultValue: null,
99
- },
100
- },
101
- tools: ["keypad_input", "natural_conversation_ending", "my-custom-tool"],
102
- noInputPokeSec: 30,
103
- noInputPokeText: "Hey, are you with me?",
104
- noInputEndConversationSec: 150,
105
- boostedKeywords: ["Salamanca Market", "Bonorong Wildlife Sanctuary"],
106
- configurationEndpoint: {
107
- url: "https://myapp.com/webhooks/phonic-config",
108
- headers: {
109
- Authorization: "Bearer 123",
110
- },
111
- timeoutMs: 7000,
112
- },
113
- });
114
- ```
115
-
116
- ### Upsert agent
117
-
118
- ```ts
119
- const result = await phonic.agents.upsert({
120
- name: "chris",
121
-
122
- // Optional fields
123
- project: "main",
124
- phoneNumber: "assign-automatically", // or null
125
- timezone: "Australia/Melbourne",
126
- voiceId: "sarah",
127
- audioFormat: "mulaw_8000", // Must be "mulaw_8000" when `phoneNumber` is "assign-automatically"
128
- audioSpeed: 1.1, // Defaults to 1.0. Must be between 0.5 and 1.5, multiple of 0.1
129
- welcomeMessage: "Hello, how can I help you?",
130
- systemPrompt: "You are an expert in {{subject}}. Be kind to {{user_name}}.",
131
- templateVariables: {
132
- subject: {
133
- defaultValue: "Maths",
134
- },
135
- user_name: {
136
- defaultValue: null,
137
- },
138
- },
139
- tools: ["keypad_input", "natural_conversation_ending", "my-custom-tool"],
140
- noInputPokeSec: 30,
141
- noInputPokeText: "Hey, are you with me?",
142
- noInputEndConversationSec: 150,
143
- boostedKeywords: ["Salamanca Market", "Bonorong Wildlife Sanctuary"],
144
- configurationEndpoint: {
145
- url: "https://myapp.com/webhooks/phonic-config",
146
- headers: {
147
- Authorization: "Bearer 123",
148
- },
149
- timeoutMs: 7000,
150
- },
151
- });
152
- ```
153
-
154
- ### Delete agent
155
-
156
- ```ts
157
- const result = await phonic.agents.delete("chris", {
158
- // Optional fields
159
- project: "main",
160
- });
161
- ```
162
-
163
- ## Tools
164
-
165
- ### List tools
166
-
167
- ```ts
168
- const result = await phonic.tools.list({
169
- project: "customer-support", // Optional. Defaults to "main".
170
- });
171
- ```
172
-
173
- ### Get tool
174
-
175
- Returns a tool by name or ID.
176
-
177
- ```ts
178
- const result = await phonic.tools.get("next_invoice", {
179
- project: "customer-support", // Optional. Defaults to "main".
180
- });
181
- ```
182
-
183
- ### Create tool
184
-
185
- #### Create webhook tool
186
-
187
- ```ts
188
- const result = await phonic.tools.create({
189
- project: "customer-support", // Optional. Defaults to "main".
190
- name: "next_invoice",
191
- description: "Returns the next invoice of the given user",
192
- type: "custom_webhook",
193
- executionMode: "sync",
194
- endpointMethod: "POST",
195
- endpointUrl: "https://myapp.com/webhooks/next-invoice",
196
- endpointHeaders: {
197
- Authorization: "Bearer 123",
198
- },
199
- endpointTimeoutMs: 20000, // Optional, defaults to 15000
200
- parameters: [
201
- {
202
- type: "string",
203
- name: "user",
204
- description: "Full name of the user to get the invoice for",
205
- isRequired: true,
206
- },
207
- {
208
- type: "array",
209
- itemType: "string",
210
- name: "invoice_items",
211
- description: "List of invoice items",
212
- isRequired: false,
213
- },
214
- {
215
- type: "number",
216
- name: "invoice_total",
217
- description: "Total invoice amount in USD",
218
- isRequired: true,
219
- },
220
- ],
221
- });
222
- ```
223
-
224
- #### Create WebSocket tool
225
-
226
- WebSocket tools allow you to handle tool execution through the WebSocket connection. When the agent calls a WebSocket tool, you'll receive a `tool_call` message and must respond with a `tool_call_output` message that contains the tool result.
227
-
228
- ```ts
229
- const result = await phonic.tools.create({
230
- project: "customer-support", // Optional. Defaults to "main".
231
- name: "get_product_recommendations",
232
- description: "Gets personalized product recommendations",
233
- type: "custom_websocket",
234
- executionMode: "async",
235
- toolCallOutputTimeoutMs: 5000, // Optional, defaults to 15000
236
- parameters: [
237
- {
238
- type: "string",
239
- name: "category",
240
- description: "Product category (e.g., 'handbags', 'shoes', 'electronics')",
241
- isRequired: true,
242
- },
243
- ],
244
- });
245
- ```
246
-
247
- To use this tool in a conversation, add it to your agent or config:
248
-
249
- ```ts
250
- // When creating an agent
251
- const result = await phonic.agents.create({
252
- name: "shopping-assistant",
253
- tools: ["get_product_recommendations"],
254
- // ... other config
255
- });
256
-
257
- // Or, override agent settings when starting a WebSocket conversation
258
- const phonicWebSocket = phonic.sts.websocket({
259
- name: "shopping-assistant",
260
- tools: ["get_product_recommendations"],
261
- // ... other config
262
- });
263
-
264
- // Handle the tool call when it's invoked
265
- phonicWebSocket.onMessage(async (message) => {
266
- if (message.type === "tool_call" && message.name === "get_product_recommendations") {
267
- const category = message.parameters.category;
268
-
269
- // Execute your business logic
270
- const recommendations = fetchRecommendations(category);
271
-
272
- // Send the result back
273
- phonicWebSocket.[sendToolCallOutput](#send-tool-output-to-phonic)({
274
- toolCallId: message.tool_call_id,
275
- output: {
276
- products: recommendations,
277
- total: recommendations.length
278
- }
279
- });
280
- }
281
- });
282
- ```
283
-
284
- ### Update tool
285
-
286
- Updates a tool by ID or name. All fields are optional - only provided fields will be updated.
287
-
288
- ```ts
289
- const result = await phonic.tools.update("next_invoice", {
290
- project: "customer-support", // Optional. Defaults to "main".
291
- name: "next_invoice_updated",
292
- description: "Updated description.",
293
- type: "custom_webhook",
294
- executionMode: "sync",
295
- endpointMethod: "POST",
296
- endpointUrl: "https://myapp.com/webhooks/next-invoice-updated",
297
- endpointHeaders: {
298
- Authorization: "Bearer 456",
299
- },
300
- endpointTimeoutMs: 30000,
301
- parameters: [
302
- {
303
- type: "string",
304
- name: "user",
305
- description: "Full name of the user to get the invoice for",
306
- isRequired: true,
307
- },
308
- {
309
- type: "array",
310
- itemType: "string",
311
- name: "invoice_items",
312
- description: "List of invoice items",
313
- isRequired: true,
314
- },
315
- {
316
- type: "number",
317
- name: "invoice_total",
318
- description: "Total invoice amount in USD",
319
- isRequired: true,
320
- },
321
- ],
322
- });
323
- ```
324
-
325
- For WebSocket tools, you would use `toolCallOutputTimeoutMs` instead of the endpoint fields:
326
-
327
- ```ts
328
- const result = await phonic.tools.update("get_product_recommendations", {
329
- description: "Updated product recommendation tool",
330
- toolCallOutputTimeoutMs: 7000,
331
- });
332
- ```
333
-
334
- ### Delete tool
335
-
336
- Deletes a tool by ID or name.
337
-
338
- ```ts
339
- const result = await phonic.tools.delete("next_invoice", {
340
- project: "customer-support", // Optional. Defaults to "main".
341
- });
342
- ```
343
-
344
- ## Voices
345
-
346
- ### List voices
347
-
348
- ```ts
349
- const result = await phonic.voices.list({ model: "merritt" });
350
- ```
351
-
352
- ### Get voice
353
-
354
- ```ts
355
- const result = await phonic.voices.get("grant");
356
- ```
357
-
358
- ## Conversations
359
-
360
- ### List conversations
361
-
362
- ```ts
363
- const result = await phonic.conversations.list({
364
- project: "main",
365
- durationMin: 10, // sec
366
- durationMax: 20, // sec
367
- startedAtMin: "2025-04-17", // 00:00:00 UTC time is assumed
368
- startedAtMax: "2025-09-05T10:30:00.000Z",
369
- });
370
- ```
371
-
372
- ### Get conversation by id
373
-
374
- ```ts
375
- const result = await phonic.conversations.get("conv_b1804883-5be4-42fe-b1cf-aa84450d5c84");
376
- ```
377
-
378
- ### Get conversation by external id
379
-
380
- ```ts
381
- const result = await phonic.conversations.getByExternalId({
382
- project: "main",
383
- externalId: "CAdb9c032c809fec7feb932ea4c96d71e1",
384
- });
385
- ```
386
-
387
- ### Outbound call
388
-
389
- ```ts
390
- const result = await phonic.conversations.outboundCall("+19189396241", {
391
- // Optional fields
392
- agent: "chris",
393
- template_variables: {
394
- customer_name: "David",
395
- subject: "Chess",
396
- },
397
- });
398
- ```
399
-
400
- ### Outbound call using own Twilio account
401
-
402
- In Twilio, create a restricted API key with the following permissions: `voice -> calls -> read` and `voice -> calls -> create`.
403
-
404
- ```ts
405
- const result = await phonic.conversations.twilio.outboundCall(
406
- {
407
- account_sid: "AC...",
408
- api_key_sid: "SK...",
409
- api_key_secret: "...",
410
- from_phone_number: "+19189372905",
411
- to_phone_number: "+19189396241",
412
- },
413
- {
414
- // Optional fields
415
- agent: "chris",
416
- welcome_message: "Hello, how can I help you?",
417
- project: "main",
418
- system_prompt: "You are a helpful assistant.",
419
- voice_id: "grant",
420
- enable_silent_audio_fallback: true,
421
- vad_prebuffer_duration_ms: 1800,
422
- vad_min_speech_duration_ms: 40,
423
- vad_min_silence_duration_ms: 550,
424
- vad_threshold: 0.6,
425
- tools: ["keypad_input", "natural_conversation_ending"],
426
- },
427
- );
428
- ```
429
-
430
- ## STS via WebSocket
431
-
432
- To start a conversation, open a WebSocket connection:
433
-
434
- ```ts
435
- const phonicWebSocket = phonic.sts.websocket({
436
- input_format: "mulaw_8000",
437
-
438
- // Optional fields
439
- agent: "chris",
440
- template_variables: {
441
- customer_name: "David",
442
- subject: "Chess",
443
- },
444
- welcome_message: "Hello, how can I help you?",
445
- voice_id: "grant",
446
- output_format: "mulaw_8000",
447
- });
448
- ```
449
-
450
- Stream input (user) audio chunks:
451
-
452
- ```ts
453
- phonicWebSocket.audioChunk({
454
- audio: "...", // base64 encoded audio chunk
455
- });
456
- ```
457
-
458
- Process messages that Phonic sends back to you:
459
-
460
- ```ts
461
- phonicWebSocket.onMessage((message) => {
462
- switch (message.type) {
463
- case "input_text": {
464
- console.log(`User: ${message.text}`);
465
- break;
466
- }
467
-
468
- case "audio_chunk": {
469
- // Send the audio chunk to Twilio, for example:
470
- twilioWebSocket.send(
471
- JSON.stringify({
472
- event: "media",
473
- streamSid: "...",
474
- media: {
475
- payload: message.audio,
476
- },
477
- }),
478
- );
479
- break;
480
- }
481
-
482
- case "tool_call": {
483
- // Handle WebSocket tool calls
484
- console.log(`Tool ${message.tool_name} called with parameters:`, message.parameters);
485
-
486
- // Example: Process a product recommendations tool call
487
- if (message.tool_name === "get_product_recommendations") {
488
- const category = message.parameters.category;
489
- const recommendations = fetchRecommendations(category);
490
-
491
- phonicWebSocket.[sendToolCallOutput](#send-tool-output-to-phonic)({
492
- toolCallId: message.tool_call_id,
493
- output: {
494
- products: recommendations,
495
- total: recommendations.length
496
- }
497
- });
498
- }
499
- break;
500
- }
501
- }
502
- });
503
- ```
504
-
505
- Update the system prompt mid-conversation:
506
-
507
- ```ts
508
- phonicWebSocket.updateSystemPrompt({
509
- systemPrompt: "...",
510
- });
511
- ```
512
-
513
- Set an external id for the conversation (can be the Twilio Call SID, for example):
514
-
515
- ```ts
516
- phonicWebSocket.setExternalId({
517
- externalId: "...",
518
- });
519
- ```
520
-
521
- ### Send tool output to Phonic
522
-
523
- When you receive a `tool_call` message for a WebSocket tool, you must respond with the tool's output using `sendToolCallOutput()`. This method sends the execution result back to Phonic so the conversation can continue.
524
-
525
- ```ts
526
- phonicWebSocket.sendToolCallOutput({
527
- toolCallId: "tool_call_123...", // The tool_call_id from the tool_call message
528
- output: "Success! Found 2 items", // Can be any JSON-serializable value (string, number, object, array, etc.)
529
- });
530
-
531
- // Or with an object:
532
- phonicWebSocket.sendToolCallOutput({
533
- toolCallId: message.tool_call_id,
534
- output: {
535
- result: "success",
536
- data: {
537
- items: ["item1", "item2"],
538
- total: 2,
539
- },
540
- },
541
- });
542
- ```
543
-
544
- **Important notes:**
545
-
546
- - You must use the exact `tool_call_id` received in the `tool_call` message
547
- - The `output` can be any JSON-serializable value (string, number, boolean, object, array, etc.)
548
- - If you don't send a response within `toolCallOutputTimeoutMs`, the tool call will be marked as failed.
549
-
550
- To end the conversation, close the WebSocket:
551
-
552
- ```ts
553
- phonicWebSocket.close();
554
- ```
555
-
556
- You can also listen for close and error events:
557
-
558
- ```ts
559
- phonicWebSocket.onClose((event) => {
560
- console.log(`Phonic WebSocket closed with code ${event.code} and reason "${event.reason}"`);
561
- });
562
-
563
- phonicWebSocket.onError((event) => {
564
- console.log(`Error from Phonic WebSocket: ${event.message}`);
565
- });
566
- ```
567
-
568
- ### Messages that Phonic sends back to you
569
-
570
- #### `conversation_created`
571
-
572
- ```ts
573
- {
574
- type: "conversation_created";
575
- conversation_id: string;
576
- }
577
- ```
578
-
579
- Sent when the conversation has been successfully created.
580
-
581
- #### `ready_to_start_conversation`
582
-
583
- ```ts
584
- {
585
- type: "ready_to_start_conversation";
586
- }
587
- ```
588
-
589
- Sent when Phonic is ready to begin processing audio. You should start sending audio chunks after receiving this message.
590
-
591
- #### `input_text`
592
-
593
- ```ts
594
- {
595
- type: "input_text";
596
- text: string;
597
- }
598
- ```
599
-
600
- Phonic sends this message once user's audio is transcribed.
601
-
602
- #### `audio_chunk`
603
-
604
- ```ts
605
- {
606
- type: "audio_chunk";
607
- audio: string; // base64 encoded array of audio data (each value is in range [-32768..32767] for "pcm_44100" output format, and in range [0..255] for "mulaw_8000" output format)
608
- text: string; // May potentially be "", but will typically be one word.
609
- }
610
- ```
611
-
612
- These are the assistant response audio chunks.
613
-
614
- #### `audio_finished`
615
-
616
- ```ts
617
- {
618
- type: "audio_finished";
619
- }
620
- ```
621
-
622
- Sent after the last "audio_chunk" is sent.
623
-
624
- #### `user_started_speaking`
625
-
626
- ```ts
627
- {
628
- type: "user_started_speaking";
629
- }
630
- ```
631
-
632
- Sent when the user begins speaking.
633
-
634
- #### `user_finished_speaking`
635
-
636
- ```ts
637
- {
638
- type: "user_finished_speaking";
639
- }
640
- ```
641
-
642
- Sent when the user stops speaking.
643
-
644
- #### `interrupted_response`
645
-
646
- ```ts
647
- {
648
- type: "interrupted_response",
649
- text: string, // partial assistant response that cuts off approximately where the user interrupted
650
- }
651
- ```
652
-
653
- Sent when the user interrupts the assistant, after the user has finished speaking.
654
-
655
- #### `assistant_chose_not_to_respond`
656
-
657
- ```ts
658
- {
659
- type: "assistant_chose_not_to_respond";
660
- }
661
- ```
662
-
663
- Sent when the assistant decides not to respond to the user's input.
664
-
665
- #### `assistant_ended_conversation`
666
-
667
- ```ts
668
- {
669
- type: "assistant_ended_conversation";
670
- }
671
- ```
672
-
673
- Sent when the assistant decides to end the conversation.
674
-
675
- #### `tool_call`
676
-
677
- ```ts
678
- {
679
- type: "tool_call";
680
- tool_call_id: string;
681
- tool_name: string;
682
- parameters: Record<string, unknown>;
683
- }
684
- ```
685
-
686
- Sent when a WebSocket tool is called during the conversation. When you receive this message, you should:
687
-
688
- 1. Process the tool call using the provided `tool_name` and `parameters`
689
- 2. Send back the result using [`phonicWebSocket.sendToolCallOutput`](#send-tool-output-to-phonic)
690
-
691
- This is only sent for tools created with `type: "custom_websocket"`. Webhook tools are executed server-side and only send `tool_call_output_processed` messages.
692
-
693
- #### `tool_call_output_processed`
694
-
695
- ```ts
696
- {
697
- type: "tool_call_output_processed";
698
- tool_call_id: string;
699
- tool: {
700
- id: string;
701
- name: string;
702
- };
703
- endpoint_url: string | null;
704
- endpoint_timeout_ms: number | null;
705
- endpoint_called_at: string | null;
706
- request_body: {
707
- call_info: {
708
- from_phone_number: string;
709
- to_phone_number: string;
710
- } | null;
711
- [key: string]: unknown;
712
- } | null;
713
- response_body: Record<string, unknown> | null;
714
- response_status_code: number | null;
715
- timed_out: boolean | null;
716
- error_message: string | null;
717
- }
718
- ```
719
-
720
- Sent when a tool is called during the conversation. Built-in tools will have null values for endpoint-related fields.
721
-
722
- When a custom tool is called, the `request_body` field always includes a `call_info` field.
723
- If the conversation is not a phone call, `call_info` will be `null`. If it is a phone call, `call_info` will be an object with `from_phone_number` and `to_phone_number` fields, both formatted as E.164 phone numbers (e.g., "+1234567890").
724
-
725
- #### `error`
726
-
727
- ```ts
728
- {
729
- type: "error";
730
- error: {
731
- message: string;
732
- code?: string;
733
- };
734
- param_errors?: Record<string, string>;
735
- }
736
- ```
737
-
738
- Sent when an error occurs during the conversation.
739
-
740
- ## Projects
741
-
742
- ### List projects
743
-
744
- ```ts
745
- const result = await phonic.projects.list();
746
- ```
747
-
748
- ### Get project
749
-
750
- Returns a project by name or ID.
751
-
752
- ```ts
753
- const result = await phonic.projects.get("main");
754
- ```
755
-
756
- ### Create project
757
-
758
- ```ts
759
- const result = await phonic.projects.create({
760
- name: "customer-support",
761
- });
762
- ```
763
-
764
- ### Update project
765
-
766
- ```ts
767
- const result = await phonic.projects.update("customer-support", {
768
- name: "updated-customer-support",
769
- defaultAgent: "another-agent",
770
- });
771
- ```
772
-
773
- ### Delete project
774
-
775
- ```ts
776
- const result = await phonic.projects.delete("customer-support");
777
- ```
778
-
779
- ## License
780
-
781
- MIT
782
-
783
14
  ## Reference
784
15
 
785
16
  A full reference for this library is available [here](https://github.com/Phonic-Co/phonic-node/blob/HEAD/./reference.md).
@@ -798,7 +29,7 @@ await client.agents.create({
798
29
  name: "support-agent",
799
30
  phone_number: "assign-automatically",
800
31
  timezone: "America/Los_Angeles",
801
- voice_id: "sarah",
32
+ voice_id: "grant",
802
33
  audio_speed: 1,
803
34
  welcome_message: "Hi {{customer_name}}. How can I help you today?",
804
35
  system_prompt: "You are an expert in {{subject}}. Be friendly, helpful and concise.",