diff --git a/ai-assistants-samples/assets/utils.private.js b/ai-assistants-samples/assets/utils.private.js index afcdf166..e4eb15c1 100644 --- a/ai-assistants-samples/assets/utils.private.js +++ b/ai-assistants-samples/assets/utils.private.js @@ -13,9 +13,8 @@ async function sendMessageToAssistant(context, assistantSid, body) { : context.TWILIO_REGION?.startsWith('dev') ? '.dev' : ''; - const url = `https://assistants${environmentPrefix}.twilio.com/v1/${assistantSid}/Messages`; + const url = `https://assistants${environmentPrefix}.twilio.com/v1/Assistants/${assistantSid}/Messages`; - // Attention! There's explicitly no "await" since we want to do a "fire & forget" const response = await fetch(url, { method: 'POST', body: JSON.stringify(body), diff --git a/ai-assistants-samples/functions/channels/conversations/flex-webchat.protected.js b/ai-assistants-samples/functions/channels/conversations/flex-webchat.protected.js index 9ef72e6a..e05d25c6 100644 --- a/ai-assistants-samples/functions/channels/conversations/flex-webchat.protected.js +++ b/ai-assistants-samples/functions/channels/conversations/flex-webchat.protected.js @@ -66,11 +66,12 @@ exports.handler = async function (context, event, callback) { params.append('_assistantIdentity', AssistantIdentity); } const body = { - Body, - Identity: identity, - SessionId: `conversations__${ChatServiceSid}/${ConversationSid}`, + body: Body, + identity, + // eslint-disable-next-line camelcase + session_id: `conversations__${ChatServiceSid}/${ConversationSid}`, // using a callback to handle AI Assistant responding - Webhook: `https://${ + webhook: `https://${ context.DOMAIN_NAME }/channels/conversations/response?${params.toString()}`, }; diff --git a/ai-assistants-samples/functions/channels/conversations/messageAdded.protected.js b/ai-assistants-samples/functions/channels/conversations/messageAdded.protected.js index 969ad3ce..cdf6b7c1 100644 --- a/ai-assistants-samples/functions/channels/conversations/messageAdded.protected.js +++ b/ai-assistants-samples/functions/channels/conversations/messageAdded.protected.js @@ -52,11 +52,12 @@ exports.handler = async function (context, event, callback) { params.append('_assistantIdentity', AssistantIdentity); } const body = { - Body: event.Body, - Identity: identity, - SessionId: `conversations__${ChatServiceSid}/${ConversationSid}`, + body: event.Body, + identity, + // eslint-disable-next-line camelcase + session_id: `conversations__${ChatServiceSid}/${ConversationSid}`, // using a callback to handle AI Assistant responding - Webhook: `https://${ + webhook: `https://${ context.DOMAIN_NAME }/channels/conversations/response?${params.toString()}`, }; diff --git a/ai-assistants-samples/functions/channels/messaging/incoming.protected.js b/ai-assistants-samples/functions/channels/messaging/incoming.protected.js index 3f06ffd3..f07d1ef0 100644 --- a/ai-assistants-samples/functions/channels/messaging/incoming.protected.js +++ b/ai-assistants-samples/functions/channels/messaging/incoming.protected.js @@ -20,12 +20,13 @@ exports.handler = async function (context, event, callback) { const token = await signRequest(context, event); const body = { - Body: event.Body, - Identity: event.From.startsWith('whatsapp:') + body: event.Body, + identity: event.From.startsWith('whatsapp:') ? event.From : `phone:${event.From}`, - SessionId: sessionId, - Webhook: `https://${context.DOMAIN_NAME}/channels/messaging/response?_token=${token}`, + // eslint-disable-next-line camelcase + session_id: sessionId, + webhook: `https://${context.DOMAIN_NAME}/channels/messaging/response?_token=${token}`, }; const response = new Twilio.Response();