atta866A

Send message to Voiceflow from external app

I have this code

if (vfUserId) {
try {
console.log("Triggering Voiceflow custom action for user:", vfUserId)
const continueResponse = await fetch(
https://general-runtime.voiceflow.com/state/user/userID/interact,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "VF.DM.68725b6764978a40d4cd4e4d.RXxxvHEA2cMn0MSq",
},
body: JSON.stringify({
action: {type: "next"}
}),
},
)
const traces = await continueResponse.json();
console.log("Continue response traces:", traces)
if(continueResponse.ok){
const customActionTrace = traces[traces.length - 1
if (customActionTrace && customActionTrace.type === "return_confirmation") {
const resultResponse = await fetch(
https://general-runtime.voiceflow.com/state/user/userID/interact,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "VF.DM.68725b6764978a40d4cd4e4d.RXxxvHEA2cMn0MSq",
},
body: JSON.stringify({
request: {
type: "intent",
payload: {
intent: {
name: "confirm_return" }
........
)
....


and this does responds me in my external app but on request i want to send success and i am redirecting back to voicflow so chat resumes ,
I have custom action waiting there for reply ,

Or is there a way i can just launch a intent from external app.
On button click i am redirecting back to voiceflow so there intent should be launched.
Was this page helpful?